IBM WebSphere Extended Deployment (XD)TM, Release 6.1
ObjectGrid API Specification

com.ibm.websphere.objectgrid.plugins
Interface ObjectTransformer


public interface ObjectTransformer

An ObjectTransformer can be used to serialize map entries that are not defined to be Serializable. This plugin is essential to high performance. Java serialization is a very costly operation. Serialization is the default mechanism for copying objects as well as transmitting objects over the network. Java serialization will normally take around 60-70% of the total CPU cost. If an application provides an ObjectTransformer for each BackingMap, this cost can drop to less than 5%, a significant performance improvement. If a customer has a performance problem, the #1 advice is to provide ObjectTransformers for every Map.

Since:
WAS XD 6.0
See Also:
BackingMap.setObjectTransformer(ObjectTransformer)

Method Summary
 java.lang.Object copyKey(java.lang.Object key)
          Creates a copy of a key object.
 java.lang.Object copyValue(java.lang.Object value)
          Creates a copy of a value object.
 java.lang.Object inflateKey(java.io.ObjectInputStream stream)
          Reads a key object from the specified stream.
 java.lang.Object inflateValue(java.io.ObjectInputStream stream)
          Reads a value object from the specified stream.
 void serializeKey(java.lang.Object key, java.io.ObjectOutputStream stream)
          Writes a key object to the specified stream.
 void serializeValue(java.lang.Object value, java.io.ObjectOutputStream stream)
          Writes a value object to the specified stream.
 

Method Detail

serializeKey

void serializeKey(java.lang.Object key,
                  java.io.ObjectOutputStream stream)
                  throws java.io.IOException
Writes a key object to the specified stream.

The default implementation simply performs a writeObject invocation passing in the key object.

Parameters:
key - the key object to serialize
stream - the ObjectOutputStream object to write the key object to
Throws:
java.io.IOException - if an error occurs during processing of this method

serializeValue

void serializeValue(java.lang.Object value,
                    java.io.ObjectOutputStream stream)
                    throws java.io.IOException
Writes a value object to the specified stream.

The default implementation simply performs a writeObject invocation passing in the value object. A proper implementation needs to handle null values if they are supported.

Parameters:
value - the value object to serialize (may be null)
stream - the ObjectOutputStream object to write the value object to
Throws:
java.io.IOException - if an error occurs during processing of this method
See Also:
BackingMap.setNullValuesSupported(boolean)

inflateKey

java.lang.Object inflateKey(java.io.ObjectInputStream stream)
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
Reads a key object from the specified stream.

The default implementation simply performs a readObject invocation.

Parameters:
stream - the ObjectInputStream object to read the key object from
Returns:
de-serialized key object
Throws:
java.io.IOException - if an error occurs during processing of this method
java.lang.ClassNotFoundException - if the key class isn't found
See Also:
serializeKey(Object, ObjectOutputStream)

inflateValue

java.lang.Object inflateValue(java.io.ObjectInputStream stream)
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
Reads a value object from the specified stream.

The default implementation simply performs a readObject invocation. A proper implementation needs to handle null values if they are supported.

Parameters:
stream - the ObjectInputStream object to read the value object from
Returns:
de-serialized value object (may be null)
Throws:
java.io.IOException - if an error occurs during processing of this method
java.lang.ClassNotFoundException - if the value class isn't found
See Also:
serializeValue(Object, ObjectOutputStream), BackingMap.setNullValuesSupported(boolean)

copyValue

java.lang.Object copyValue(java.lang.Object value)
Creates a copy of a value object.

The default implementation attempts to locate and use a defined clone() method on the value object. If the method isn't found, it copies the value object using serialization. A proper implementation needs to handle null values if they are supported.

Parameters:
value - the value object to copy (may be null)
Returns:
a copy of the value.
See Also:
CopyMode, BackingMap.setCopyMode(CopyMode, Class), BackingMap.setNullValuesSupported(boolean)

copyKey

java.lang.Object copyKey(java.lang.Object key)
Creates a copy of a key object.

The default implementation attempts to locate and use a defined clone() method on the key object. If the method isn't found, it copies the key object using serialization.

Parameters:
key - the key object to copy
Returns:
a copy of the key
See Also:
BackingMap.setCopyKey(boolean)

IBM WebSphere Extended Deployment (XD)TM, Release 6.1
ObjectGrid API Specification

© Copyright International Business Machines Corp 2005-2007. All rights reserved.