Source Code Cross Referenced for RpcProtocol.java in  » Net » JGroups-2.4.1-sp3 » org » jgroups » stack » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » JGroups 2.4.1 sp3 » org.jgroups.stack 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // $Id: RpcProtocol.java,v 1.6 2005/11/03 11:42:59 belaban Exp $
002:
003:        package org.jgroups.stack;
004:
005:        import org.jgroups.*;
006:        import org.jgroups.blocks.MethodCall;
007:        import org.jgroups.util.RspList;
008:        import org.jgroups.util.Util;
009:
010:        import java.util.Vector;
011:
012:        /**
013:         * Base class for group RMC peer protocols.
014:         * @author Bela Ban
015:         */
016:        public class RpcProtocol extends MessageProtocol {
017:
018:            public String getName() {
019:                return "RpcProtocol";
020:            }
021:
022:            public RspList callRemoteMethods(Vector dests, String method_name,
023:                    Object[] args, Class[] types, int mode, long timeout) {
024:                MethodCall method_call = new MethodCall(method_name, args,
025:                        types);
026:                return callRemoteMethods(dests, method_call, mode, timeout);
027:            }
028:
029:            public RspList callRemoteMethods(Vector dests, String method_name,
030:                    Object[] args, String[] signature, int mode, long timeout) {
031:                MethodCall method_call = new MethodCall(method_name, args,
032:                        signature);
033:                return callRemoteMethods(dests, method_call, mode, timeout);
034:            }
035:
036:            public RspList callRemoteMethods(Vector dests,
037:                    MethodCall method_call, int mode, long timeout) {
038:                byte[] buf = null;
039:                Message msg = null;
040:
041:                try {
042:                    buf = Util.objectToByteBuffer(method_call);
043:                } catch (Exception e) {
044:                    if (log.isErrorEnabled())
045:                        log.error("exception=" + e);
046:                    return null;
047:                }
048:
049:                msg = new Message(null, null, buf);
050:                return castMessage(dests, msg, mode, timeout);
051:            }
052:
053:            public Object callRemoteMethod(Address dest, String method_name,
054:                    int mode, long timeout) throws TimeoutException,
055:                    SuspectedException {
056:                return callRemoteMethod(dest, method_name, new Object[] {},
057:                        new Class[] {}, mode, timeout);
058:            }
059:
060:            public Object callRemoteMethod(Address dest, String method_name,
061:                    Object[] args, Class[] types, int mode, long timeout)
062:                    throws TimeoutException, SuspectedException {
063:                MethodCall method_call = new MethodCall(method_name, args,
064:                        types);
065:                return callRemoteMethod(dest, method_call, mode, timeout);
066:            }
067:
068:            public Object callRemoteMethod(Address dest, String method_name,
069:                    Object[] args, String[] signature, int mode, long timeout)
070:                    throws TimeoutException, SuspectedException {
071:                MethodCall method_call = new MethodCall(method_name, args,
072:                        signature);
073:                return callRemoteMethod(dest, method_call, mode, timeout);
074:            }
075:
076:            public Object callRemoteMethod(Address dest,
077:                    MethodCall method_call, int mode, long timeout)
078:                    throws TimeoutException, SuspectedException {
079:                byte[] buf = null;
080:                Message msg = null;
081:
082:                try {
083:                    buf = Util.objectToByteBuffer(method_call);
084:                } catch (Exception e) {
085:                    if (log.isErrorEnabled())
086:                        log.error("exception=" + e);
087:                    return null;
088:                }
089:
090:                msg = new Message(dest, null, buf);
091:                return sendMessage(msg, mode, timeout);
092:            }
093:
094:            /**
095:             Message contains MethodCall. Execute it against *this* object and return result.
096:             Use MethodCall.invoke() to do this. Return result.
097:             */
098:            public Object handle(Message req) {
099:                Object body = null;
100:                MethodCall method_call;
101:
102:                if (req == null || req.getLength() == 0) {
103:                    if (log.isErrorEnabled())
104:                        log.error("message or message buffer is null");
105:                    return null;
106:                }
107:
108:                try {
109:                    body = req.getObject();
110:                } catch (Exception e) {
111:                    if (log.isErrorEnabled())
112:                        log.error("exception=" + e);
113:                    return e;
114:                }
115:
116:                if (body == null || !(body instanceof  MethodCall)) {
117:                    if (log.isErrorEnabled())
118:                        log
119:                                .error("message does not contain a MethodCall object");
120:                    return null;
121:                }
122:
123:                method_call = (MethodCall) body;
124:                try {
125:                    return method_call.invoke(this );
126:                } catch (Throwable x) {
127:                    if (log.isErrorEnabled())
128:                        log.error("failed invoking method "
129:                                + method_call.getName(), x);
130:                    return x;
131:                }
132:            }
133:
134:            /**
135:             Handle up event. Return false if it should not be passed up the stack.
136:             */
137:            public boolean handleUpEvent(Event evt) {
138:                return true;
139:            }
140:
141:            /**
142:             Handle down event. Return false if it should not be passed down the stack.
143:             */
144:            public boolean handleDownEvent(Event evt) {
145:                return true;
146:            }
147:
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.