Class RpcDispatcher

  • All Implemented Interfaces:
    RequestHandler, ChannelListener

    public class RpcDispatcher
    extends MessageDispatcher
    implements ChannelListener
    This class allows a programmer to invoke remote methods in all (or single) group members and optionally wait for the return value(s). An application will typically create a channel and layer the RpcDispatcher building block on top of it, which allows it to dispatch remote methods (client role) and at the same time be called by other members (server role). This class is derived from MessageDispatcher. Is the equivalent of RpcProtocol on the application rather than protocol level.
    Author:
    Bela Ban
    • Field Detail

      • server_obj

        protected java.lang.Object server_obj
      • req_marshaller

        protected RpcDispatcher.Marshaller2 req_marshaller
        Marshaller to marshall requests at the caller and unmarshal requests at the receiver(s)
      • rsp_marshaller

        protected RpcDispatcher.Marshaller2 rsp_marshaller
        Marshaller to marshal responses at the receiver(s) and unmarshal responses at the caller
      • additionalChannelListeners

        protected final java.util.List additionalChannelListeners
    • Method Detail

      • getName

        public java.lang.String getName()
      • getServerObject

        public java.lang.Object getServerObject()
      • setServerObject

        public void setServerObject​(java.lang.Object server_obj)
      • setMethodLookup

        public void setMethodLookup​(MethodLookup method_lookup)
      • callRemoteMethods

        public RspList callRemoteMethods​(java.util.Vector dests,
                                         java.lang.String method_name,
                                         java.lang.Object[] args,
                                         java.lang.Class[] types,
                                         int mode,
                                         long timeout)
      • callRemoteMethods

        public RspList callRemoteMethods​(java.util.Vector dests,
                                         java.lang.String method_name,
                                         java.lang.Object[] args,
                                         java.lang.Class[] types,
                                         int mode,
                                         long timeout,
                                         boolean use_anycasting)
      • callRemoteMethods

        public RspList callRemoteMethods​(java.util.Vector dests,
                                         java.lang.String method_name,
                                         java.lang.Object[] args,
                                         java.lang.Class[] types,
                                         int mode,
                                         long timeout,
                                         boolean use_anycasting,
                                         RspFilter filter)
      • callRemoteMethods

        public RspList callRemoteMethods​(java.util.Vector dests,
                                         java.lang.String method_name,
                                         java.lang.Object[] args,
                                         java.lang.String[] signature,
                                         int mode,
                                         long timeout)
      • callRemoteMethods

        public RspList callRemoteMethods​(java.util.Vector dests,
                                         java.lang.String method_name,
                                         java.lang.Object[] args,
                                         java.lang.String[] signature,
                                         int mode,
                                         long timeout,
                                         boolean use_anycasting)
      • callRemoteMethods

        public RspList callRemoteMethods​(java.util.Vector dests,
                                         MethodCall method_call,
                                         int mode,
                                         long timeout)
      • callRemoteMethods

        public RspList callRemoteMethods​(java.util.Vector dests,
                                         MethodCall method_call,
                                         int mode,
                                         long timeout,
                                         boolean use_anycasting)
      • callRemoteMethods

        public RspList callRemoteMethods​(java.util.Vector dests,
                                         MethodCall method_call,
                                         int mode,
                                         long timeout,
                                         boolean use_anycasting,
                                         boolean oob)
      • callRemoteMethods

        public RspList callRemoteMethods​(java.util.Vector dests,
                                         MethodCall method_call,
                                         int mode,
                                         long timeout,
                                         boolean use_anycasting,
                                         boolean oob,
                                         RspFilter filter)
      • callRemoteMethod

        public java.lang.Object callRemoteMethod​(Address dest,
                                                 java.lang.String method_name,
                                                 java.lang.Object[] args,
                                                 java.lang.Class[] types,
                                                 int mode,
                                                 long timeout)
                                          throws java.lang.Throwable
        Throws:
        java.lang.Throwable
      • callRemoteMethod

        public java.lang.Object callRemoteMethod​(Address dest,
                                                 java.lang.String method_name,
                                                 java.lang.Object[] args,
                                                 java.lang.String[] signature,
                                                 int mode,
                                                 long timeout)
                                          throws java.lang.Throwable
        Throws:
        java.lang.Throwable
      • callRemoteMethod

        public java.lang.Object callRemoteMethod​(Address dest,
                                                 MethodCall method_call,
                                                 int mode,
                                                 long timeout)
                                          throws java.lang.Throwable
        Throws:
        java.lang.Throwable
      • callRemoteMethod

        public java.lang.Object callRemoteMethod​(Address dest,
                                                 MethodCall method_call,
                                                 int mode,
                                                 long timeout,
                                                 boolean oob)
                                          throws java.lang.Throwable
        Throws:
        java.lang.Throwable
      • handle

        public java.lang.Object handle​(Message req)
        Message contains MethodCall. Execute it against *this* object and return result. Use MethodCall.invoke() to do this. Return result.
        Specified by:
        handle in interface RequestHandler
        Overrides:
        handle in class MessageDispatcher
      • addChannelListener

        public boolean addChannelListener​(ChannelListener l)
        Add a new channel listener to be notified on the channel's state change.
        Returns:
        true if the listener was added or false if the listener was already in the list.
      • removeChannelListener

        public boolean removeChannelListener​(ChannelListener l)
        Returns:
        true if the channel was removed indeed.