org.objectweb.jac.core
Class SerializedJacObject

java.lang.Object
  extended byorg.objectweb.jac.core.SerializedJacObject
All Implemented Interfaces:
Serializable

public class SerializedJacObject
extends Object
implements Serializable

This class defines all the needed information when (de)serializing a JAC object.

It is used to (de)serialize a JacObject by JacObjectInputStream and JacObjectOutputStream. To ensure the correct use of these streams, use only JacObject.(de)serialize().

Any aspect component can use a SerializedJacObject to add any relevant information during the serialization process (whenSerialized()) or to extract any relevant information during the deserialization process (whenDeserialized()).

Author:
Renaud Pawlak
See Also:
JacObjectOutputStream, AspectComponent.whenSerialized(Wrappee,SerializedJacObject), JacObjectInputStream, AspectComponent.whenDeserialized(SerializedJacObject,Wrappee), Serialized Form

Field Summary
protected  HashMap acInfos
          Extra Aspect Component related infos to be serialized.
protected  HashMap fields
          The serialized fields for this JAC object.
protected  boolean forwarder
          If true, the deserialized object will be a forwarder towards the actual object.
protected  String jacObjectClassName
          The class name of the serialized JAC object.
static String STATELESS
           
 
Constructor Summary
SerializedJacObject(String jacObjectClassName)
          The constructor of a serialized JacObject.
 
Method Summary
 void addField(String name, Object value)
          Add a field to be serialized.
static Object deserialize(byte[] data)
          Deserialize an object from an array of bytes.
static Object deserializeArgs(byte[] data)
          Deserialize the arguments of a method.
 void disableForwarding()
          Disable the forwarding.
 void enableForwarding()
          Enable the forwarding.
 Object getACInfos(String acName)
          Get some aspect component related infos to be deserialized.
 Object getField(String name)
          Get a serialized field value.
 HashMap getFields()
          Returns a hashtable that contains the field names to be serialized and their values.
 String getJacObjectClassName()
          Returns the serialized JAC object class name.
 boolean isForwarder()
          Tells if the serialized object is a forwarder.
static byte[] serialize(Object src)
          Serialize an object into an array of bytes.
static byte[] serializeArgs(Object[] args, Boolean[] refs)
          Serialize the arguments of a method.
 void setACInfos(String acName, Object infos)
          Add some aspect component related infos to be serialized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATELESS

public static final String STATELESS
See Also:
Constant Field Values

jacObjectClassName

protected String jacObjectClassName
The class name of the serialized JAC object.


fields

protected HashMap fields
The serialized fields for this JAC object.


acInfos

protected HashMap acInfos
Extra Aspect Component related infos to be serialized.


forwarder

protected boolean forwarder
If true, the deserialized object will be a forwarder towards the actual object. Default is true.

Constructor Detail

SerializedJacObject

public SerializedJacObject(String jacObjectClassName)
The constructor of a serialized JacObject.

The programmer do not need to call this method since it is implicitly called by JacObjectOutputStream.

Parameters:
jacObjectClassName - the class name of the serialized JAC object
See Also:
JacObjectOutputStream
Method Detail

serialize

public static byte[] serialize(Object src)
Serialize an object into an array of bytes.

If the programmer uses this method, the aspect components are upcalled (whenSerialized()) to parametrize the serialization by filling a SerializedJacObject instance.

A symetric process is implemented by deserialize()

Parameters:
src - the object to serialize
Returns:
an array of bytes
See Also:
AspectComponent.whenSerialized(Wrappee,SerializedJacObject), SerializedJacObject, deserialize(byte[]), JacObjectOutputStream

serializeArgs

public static byte[] serializeArgs(Object[] args,
                                   Boolean[] refs)
Serialize the arguments of a method.


deserialize

public static Object deserialize(byte[] data)
Deserialize an object from an array of bytes.

If the programmer uses this method, the aspect components are upcalled (whenDeserialized() method) to parametrize the deserialization by using a corresponding SerializedJacObject instance.

A symetric process is implemented by serialize()

Parameters:
data - the array of bytes
Returns:
the object or null if a error has been encountered
See Also:
AspectComponent.whenDeserialized(SerializedJacObject,Wrappee), SerializedJacObject, serialize(Object), JacObjectInputStream

deserializeArgs

public static Object deserializeArgs(byte[] data)
Deserialize the arguments of a method.


getFields

public HashMap getFields()
Returns a hashtable that contains the field names to be serialized and their values.

Returns:
the serialized fields

addField

public void addField(String name,
                     Object value)
Add a field to be serialized.

Parameters:
name - the field name
value - its value

getField

public Object getField(String name)
Get a serialized field value.

This value has been added with the addField method.

Parameters:
name - the name of the serialized field
Returns:
its value
See Also:
addField(String,Object)

getJacObjectClassName

public String getJacObjectClassName()
Returns the serialized JAC object class name.

Returns:
the class name

setACInfos

public void setACInfos(String acName,
                       Object infos)
Add some aspect component related infos to be serialized.

This method can be used by an aspect component within the whenSerialized() method. It allows the aspect programmer to add some relevant informations to be serialized (for instance when transmiting JAC objects to remote host or saving them on the disk).

During the deserialization, an aspect component can retrieve these added information by using getACInfos().

Parameters:
acName - the name of the aspect component that has set this information
infos - any serializable object
See Also:
AspectComponent, AspectComponent.whenSerialized(Wrappee,SerializedJacObject), getACInfos(String)

getACInfos

public Object getACInfos(String acName)
Get some aspect component related infos to be deserialized.

This method can be used by an aspect component within the whenDeserialized() method. It allows the aspect programmer to get some relevant informations to be deserialized (for instance when transmiting JAC objects to remote host or saving them on the disk).

The retrieved informations are usually set during the serialization by using setACInfos().

Parameters:
acName - the name of the aspect component that has set this information
Returns:
the information
See Also:
AspectComponent, AspectComponent.whenDeserialized(SerializedJacObject,Wrappee), setACInfos(String,Object)

isForwarder

public boolean isForwarder()
Tells if the serialized object is a forwarder. By default, all the serialized JAC objects are forwarders.

When a serialized JAC object is a forwarder, then if, when deserialized, no name-corresponding JAC object is found, then the deserialized object is wrapped by a binding wrapper so that the binding aspect is able to resolve the actual object later on. Of course, if a corresponding JAC object is found, then the deserialized JAC object is replaced by the actual object.

When a serialized JAC object is not a forwarder, then no replacement or binding mechanism occurs.

Returns:
true if forwarder
See Also:
NamingAC.whenSerialized(Wrappee,SerializedJacObject), BindingAC.whenDeserialized(SerializedJacObject,Wrappee)

disableForwarding

public void disableForwarding()
Disable the forwarding.

If this method is called, the isForwarder method will return false.

See Also:
isForwarder(), enableForwarding()

enableForwarding

public void enableForwarding()
Enable the forwarding.

If this method is called, the isForwarder method will return true (default).

See Also:
isForwarder(), disableForwarding()