org.iids.aos.util
Class Marshaller

java.lang.Object
  extended by org.iids.aos.util.Marshaller

public class Marshaller
extends java.lang.Object

Marshaller used by SystemServiceHandler and SystemServiceProxy. It (un)marshalls the method invocations between the proxy and handler and (un)marshalls return results. Every invocation/result is identified by a reference ID. This id is used to match invocations and the corresponding results. The marshallers are optimized to re-use any ObjectInputStream and ObjectOutputStreams. (creating such objects can be costly, especially when they are used very often. They use MyObjectInputStream and MyObjectOutputStream as specialized streams that do not write any stream headers, so they can be reused more easily.

Author:
michel

Nested Class Summary
static class Marshaller.MethodInvocation
           
static class Marshaller.MethodResults
           
 
Method Summary
protected  void finalize()
           
static Marshaller getInstance()
           
 int getRefId(byte[] bytearray)
          Returns the refId of a request or reply that must have been generated by marshallInvocation or marshallResults.
 byte[] marshallInvocation(java.lang.Object ProxiedObject, java.lang.reflect.Method M, java.lang.Object[] Args, int refId)
           
 byte[] marshallObject(java.lang.Object o)
          Generic method to marshall an Object to a byte array.
 byte[] marshallResults(boolean IsException, java.lang.Object Results, int refId)
           
static void releaseInstance(Marshaller m)
           
 void unmarshallInvocation(byte[] Request, Marshaller.MethodInvocation mi)
           
 java.lang.Object unmarshallObject(byte[] array)
          Generic method to unmarshall an Object from a byte array.
 java.lang.Object unmarshallObject(byte[] array, java.lang.ClassLoader loader)
          Generic method to unmarshall an Object from a byte array using a specified classloader.
 void unmarshallResults(byte[] Results, Marshaller.MethodResults mr)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Marshaller getInstance()

releaseInstance

public static void releaseInstance(Marshaller m)

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

marshallInvocation

public byte[] marshallInvocation(java.lang.Object ProxiedObject,
                                 java.lang.reflect.Method M,
                                 java.lang.Object[] Args,
                                 int refId)
                          throws java.io.IOException
Throws:
java.io.IOException

unmarshallInvocation

public void unmarshallInvocation(byte[] Request,
                                 Marshaller.MethodInvocation mi)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

marshallResults

public byte[] marshallResults(boolean IsException,
                              java.lang.Object Results,
                              int refId)
                       throws java.io.IOException
Throws:
java.io.IOException

unmarshallResults

public void unmarshallResults(byte[] Results,
                              Marshaller.MethodResults mr)
                       throws java.io.IOException,
                              java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

getRefId

public int getRefId(byte[] bytearray)
             throws java.io.IOException
Returns the refId of a request or reply that must have been generated by marshallInvocation or marshallResults.

Parameters:
bytearray - request or reply for which refId must be returned
Returns:
refId
Throws:
java.io.IOException

marshallObject

public byte[] marshallObject(java.lang.Object o)
                      throws java.io.IOException
Generic method to marshall an Object to a byte array.

Parameters:
o - object to be marshalled
Returns:
byte array of marshalled object.
Throws:
java.io.IOException

unmarshallObject

public java.lang.Object unmarshallObject(byte[] array)
                                  throws java.io.IOException,
                                         java.lang.ClassNotFoundException
Generic method to unmarshall an Object from a byte array.

Parameters:
array - marshalled object
Returns:
unmarshalled object
Throws:
java.io.IOException
java.lang.ClassNotFoundException

unmarshallObject

public java.lang.Object unmarshallObject(byte[] array,
                                         java.lang.ClassLoader loader)
                                  throws java.io.IOException,
                                         java.lang.ClassNotFoundException
Generic method to unmarshall an Object from a byte array using a specified classloader.

Parameters:
array - marshalled object
Returns:
unmarshalled object
Throws:
java.io.IOException
java.lang.ClassNotFoundException


Copyright ? 2003, 2004 IIDS Group. All Rights Reserved.