osl.handler
Class RequestMsg

java.lang.Object
  |
  +--osl.handler.RequestMsg

public class RequestMsg
extends java.lang.Object
implements java.io.Externalizable

This class encodes a message sent between request handler sessions. The fields in this class indicate whether or not a message represents a request, a reply to a request (e.g. for RPC requests), or an exception caused by a request which should be delivered back to the calling client. Custom serialization routines are implemented for efficiency purposes. Note that the only information we include about the parties involved in the request is the Name of the sender. The reason is that request messages are transmitted via TransportMessages, which already include sender and receiver PhysicalAddresses. Including that information here would result in transmitting (and worse, serializing) duplicate information.

Version:
$Revision: 1.6 $ ($Date: 1998/10/05 15:47:36 $)
See Also:
RequestHandler, Serialized Form

Constructor Summary
RequestMsg()
          The default constructor sets the message type as UNKNOWN with no id and no return value.
RequestMsg(java.lang.Object rVal, long msgID, int mType, RequestMsg oReq)
          This constructor useful for building a reply to an RPC request or for returning an exception given the original request message, the id of the reply, and the value to send as the reply.
RequestMsg(PhysicalAddress oSend, Name dName, int theType, long theId, long theSrcID, java.lang.Object theRVal, java.lang.String target, java.lang.Object[] theArgs, long[] rGC, java.lang.String cName, byte[] cData)
          This is the full version of the RequestMsg constructor.
RequestMsg(PhysicalAddress oSender, Name dest, int type, java.lang.String targMeth, java.lang.Object[] theArgs, long theID)
          This constructor useful for building REQUESTS or RPC_REQUESTS.
 
Method Summary
 void readExternal(java.io.ObjectInput in)
          Deserialize into a new instnace of RequestMesg by reading from the given input stream.
 void writeExternal(java.io.ObjectOutput out)
          Serialize the contents of this class to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestMsg

public RequestMsg(PhysicalAddress oSend,
                  Name dName,
                  int theType,
                  long theId,
                  long theSrcID,
                  java.lang.Object theRVal,
                  java.lang.String target,
                  java.lang.Object[] theArgs,
                  long[] rGC,
                  java.lang.String cName,
                  byte[] cData)
This is the full version of the RequestMsg constructor.
Parameters:
oSend - The PhysicalAddress of the original sender of this message. We need this data so that replies are correctly routed in the case of forwarded requests.
dName - The Name of the receiver.
theType - The int type of this message.
theId - The int ID for this message. Should be unique relative to the sender.
theSrcID - In the case of an RPC reply, the int id of the original request message.
theRVal - In the case of an RPC reply, the Object which holds the returned value. In the case of an exception, the Exception which was returned by the receiver. This will either be a RemoteException or a NoSuchMethodException.
target - The String naming the method to invoke on the receiver.
theArgs - An object array (i.e. Object[]) giving the arguments to pass to the target method.

RequestMsg

public RequestMsg(PhysicalAddress oSender,
                  Name dest,
                  int type,
                  java.lang.String targMeth,
                  java.lang.Object[] theArgs,
                  long theID)
This constructor useful for building REQUESTS or RPC_REQUESTS.
Parameters:
oSender - The PhysicalAddress of the original sender of the message.
dest - The Name of the receiver.
type - The type of the message. Will usually be either MTYPE_REQUEST or MTYPE_RPC_REQUEST.
targMeth - A String naming the method to invoke on the target.
theArgs - The object array holding the arguments to pass to the target method.
theId - The integer ID of this message. Should be unique relative to the sender.

RequestMsg

public RequestMsg(java.lang.Object rVal,
                  long msgID,
                  int mType,
                  RequestMsg oReq)
This constructor useful for building a reply to an RPC request or for returning an exception given the original request message, the id of the reply, and the value to send as the reply.
Parameters:
rVal - The object to send as the return value for the original request.
msgID - The id of the reply message. Should be unique relative to the sender.
mType - The type of reply: either MTYPE_RPC_REPLY or MTYPE_RPC_EXCEPTION.
oReq - The original request message.

RequestMsg

public RequestMsg()
The default constructor sets the message type as UNKNOWN with no id and no return value. Note that this is not a legal message.
Method Detail

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException,
                          RequestException
Serialize the contents of this class to the output stream.
Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - The OutputStream to which we should write this instance.

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException,
                         java.lang.ClassCastException,
                         RequestException
Deserialize into a new instnace of RequestMesg by reading from the given input stream.
Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - The InputStream from which we should deserialize this instance.
Throws:
java.io.IOException - Thrown if an I/O error is encountered while reading the input stream.
java.lang.ClassNotFoundException - Thrown if a class being deserialized from the input stream cannot be found by the class loader.
java.lang.ClassCastException - Thrown if a class deserialized from the input stream had an unexpected type.
RequestException - Thrown if the message deserialized from the input stream has an unknown type.