info.jedi.net
Class RMCCall

java.lang.Object
  |
  +--info.jedi.net.RMCCall

public class RMCCall
extends java.lang.Object

This class encapsulates a remote method call in the JEDI system. It is principly concerned with writing the data for a remote call to the network; but it also provides infrastructure for actually executing the call on the remote system using class Remote.

See Also:
RMCHandler, Remote

Constructor Summary
RMCCall(MailDaemon md, java.net.InetAddress address, int port, java.lang.String objectName, java.lang.String methodName, java.util.Vector args, int timeout)
          Creates a RMCCall object representing a remote method call.
RMCCall(MailDaemon md, InputPacket packet)
          Creates a RMCCall object from a JEDI InputPacket.
 
Method Summary
 void execute()
          Finds the object the method will be called on in the local repository, executes it, catches any exception thrown, and stores the result or exception in internal variables so they can be sent back to the caller.
 java.lang.Object getResponse()
          Waits on the socket associated with this method call for a packet that contains a response to this method call.
 void readResponse(InputPacket packet)
          This is called when a RMC reply packet comes in that has the return value for this call.
 void reportError(java.lang.Exception e)
          This is called when there is an error (usually a timeout) sending this RMCCall.
 void respond()
          Responds to the calling host by packing up the return value or exception and replying to the socket that send the request
 void send()
          Sends this RMCCall to the remote machine where it will be executed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RMCCall

public RMCCall(MailDaemon md,
               java.net.InetAddress address,
               int port,
               java.lang.String objectName,
               java.lang.String methodName,
               java.util.Vector args,
               int timeout)
Creates a RMCCall object representing a remote method call. This is the constructor used on the machine the call is coming from.
Parameters:
md - the MailDaemon to send the call from
address - the host where the remote object is
address - the port where the remote object is
objectName - the name the remote object is registered under (see info.jedi.Registry)
methodName - the method to call
args - the arguments to the call (in order). ints and booleans and the like should be packed in wrapper classes like Integer and Boolean.

RMCCall

public RMCCall(MailDaemon md,
               InputPacket packet)
        throws java.io.IOException
Creates a RMCCall object from a JEDI InputPacket. This is the constructor used on the machine the call will be executed on.
Parameters:
md - the MailDaemon this RMCCall came in on.
packet - the packet with the method call data
Throws:
java.io.IOException - if there is a problem reading the method call data from the InputPacket
Method Detail

send

public void send()
          throws java.io.IOException,
                 java.lang.InterruptedException
Sends this RMCCall to the remote machine where it will be executed. It then waits on this RMCCall object until the reply has received (which calls notifyAll()).
Throws:
java.io.IOException - if there is an error sending the remote method call request.
java.lang.InterruptedException - if this thread is interrupted while waiting for a response

reportError

public void reportError(java.lang.Exception e)
This is called when there is an error (usually a timeout) sending this RMCCall. It will be called instead of readResponse by the RMCHandler.
Parameters:
e - the error condition

readResponse

public void readResponse(InputPacket packet)
                  throws java.io.IOException
This is called when a RMC reply packet comes in that has the return value for this call. The method reads the return value (or exception) and notifies the thread that has been waiting for a reply
Parameters:
packet - the InputPacket that this method will read the return value from

getResponse

public java.lang.Object getResponse()
                             throws java.lang.Exception
Waits on the socket associated with this method call for a packet that contains a response to this method call. Returns a copy of the object returned on the remote machine, or throws an exception if there was a problem with network communication, or the remote procedure threw an exception, or the remote method or remote object didn't exist.
Returns:
the return value of the remote method.
Throws:
java.lang.Exception - if there was an error calling the remote method or the method threw an exception.

execute

public void execute()
Finds the object the method will be called on in the local repository, executes it, catches any exception thrown, and stores the result or exception in internal variables so they can be sent back to the caller.
See Also:
Repository, Remote

respond

public void respond()
             throws java.io.IOException
Responds to the calling host by packing up the return value or exception and replying to the socket that send the request
Throws:
java.io.IOException - if there is an error sending the reply.