TPTP 4.4.0 Platform Project
Public API Specification

org.eclipse.hyades.execution.invocation
Class Marshaller

java.lang.Object
  extended byorg.eclipse.hyades.execution.invocation.Marshaller

public class Marshaller
extends java.lang.Object

This class knows how to marshal and unmarshal method calls. No instances of this class can be created. All data members are class (static )members and all methods are class methods. This class will be loaded in both the local and remote VMs, and all of its state will be properly initialized when the class is loaded.


Method Summary
static void addInstanceToMap(java.lang.Integer uniqueId, java.lang.Object instance)
          Add an object to the instance map.
static java.lang.Object getInstanceFromMap(java.lang.Integer uniqueId)
          Get an object from the instance map.
static boolean isReturnDataAvailable()
          Are there any return values in the queue?
static byte[] marshalMethodCall(CallData callData)
          Marshals a method call into a byte[].
static byte[] marshalReturnValue(ReturnData rtnData)
          Marshals the return value from a method call into a byte[].
static ReturnData peekReturnValue()
          Get a copy of the return value at the front of the queue.
static void queueReturnValue(ReturnData value)
          Add the result of a method invocation to the return data queue.
static void removeInstanceFromMap(java.lang.Integer uniqueId)
          Remove an object from the instance map.
static CallData unmarshalMethodCall(byte[] callData)
          Unmarshals a method call into a CallData instance.
static ReturnData unmarshalReturnValue(byte[] data)
          Unmarshals the result of a method call into a ReturnData instance.
static ReturnData unqueueReturnValue()
          Pull the result of a method invocation off of the return data queue.
static void waitForReturnData()
          Deprecated. use waitForReturnDataWithTimeout so you can distinguish between return data received and timeout exceeded condition
static void waitForReturnDataWithTimeout()
          Wait until there is data in the return queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addInstanceToMap

public static void addInstanceToMap(java.lang.Integer uniqueId,
                                    java.lang.Object instance)
Add an object to the instance map.

Parameters:
uniqueId -
instance -

getInstanceFromMap

public static java.lang.Object getInstanceFromMap(java.lang.Integer uniqueId)
Get an object from the instance map.

Parameters:
uniqueId -
Returns:

removeInstanceFromMap

public static void removeInstanceFromMap(java.lang.Integer uniqueId)
Remove an object from the instance map.

Parameters:
uniqueId -

marshalMethodCall

public static byte[] marshalMethodCall(CallData callData)
                                throws java.io.IOException
Marshals a method call into a byte[]. The data is serialized as follows:
  1. a unique id that is associated with the target object. This value is an int.
  2. an array of Class objects representing the method argument types. For methods that do not accept arguments, this is a zero-length array.
  3. an array of Object s that are the arguments of the method to be invoked. For methods that do not accept arguments, this is a zero-length array.
  4. the name of the method to be invoked. This is a String.

Parameters:
callData -
Returns:
Throws:
java.io.IOException

unmarshalMethodCall

public static CallData unmarshalMethodCall(byte[] callData)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException
Unmarshals a method call into a CallData instance. The order of objects expected in the input byte array are specified in the documentation for marshalMethodCall.

Parameters:
callData -
Returns:
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
marshalMethodCall(CallData)

marshalReturnValue

public static byte[] marshalReturnValue(ReturnData rtnData)
                                 throws java.io.IOException
Marshals the return value from a method call into a byte[]. The data is serialized as follows:
  1. a unique id that is associated with the target object -- the object on which the method was invoked. This value is an int.
  2. an array of Class objects representing the method argument types. For methods that do not accept arguments, this is a zero-length array.
  3. the name of the method to be invoked. This is a String.
  4. an indicator signifying the presence (or lack thereof) of a return value. This value is one of the int constants defined in this class.
  5. CONDITIONALan Object that is the value returned as a result of the method invocation.

Returns:
Throws:
java.io.IOException

unmarshalReturnValue

public static ReturnData unmarshalReturnValue(byte[] data)
                                       throws java.io.IOException,
                                              java.lang.ClassNotFoundException
Unmarshals the result of a method call into a ReturnData instance. The order of objects expected in the input byte array are specified in the documentation for marshalReturnValue.

Parameters:
data -
Returns:
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
marshalReturnValue(ReturnData)

queueReturnValue

public static void queueReturnValue(ReturnData value)
Add the result of a method invocation to the return data queue.

Parameters:
value -

unqueueReturnValue

public static ReturnData unqueueReturnValue()
Pull the result of a method invocation off of the return data queue.

Returns:

peekReturnValue

public static ReturnData peekReturnValue()
Get a copy of the return value at the front of the queue. This method is used by remote stubs as a part of the check to ensure that a return value is the result of a given method invocation. This helps to insure that a remote stub doesn't pull the wrong value off of the queue.

Returns:

isReturnDataAvailable

public static boolean isReturnDataAvailable()
Are there any return values in the queue?

Returns:

waitForReturnData

public static void waitForReturnData()
Deprecated. use waitForReturnDataWithTimeout so you can distinguish between return data received and timeout exceeded condition

Wait until there is data in the return queue. This method blocks the calling thread until return data is present in the queue or the timeout occurs.


waitForReturnDataWithTimeout

public static void waitForReturnDataWithTimeout()
                                         throws java.lang.InterruptedException
Wait until there is data in the return queue. This method blocks the calling thread until return data is present in the queue or the timeout occurs. If the timeout occurs, an InterruptedException is thrown (to allow callers to distinguish between return data received and timeout exceeded.)

Throws:
java.lang.InterruptedException - if the return data timeout is exceeded
Provisional API: This API is subject to change in the next release.

TPTP 4.4.0 Platform Project
Public API Specification