org.jboss.ha.framework.server
Class SimpleCachableMarshalledValue

java.lang.Object
  extended by org.jboss.ha.framework.server.SimpleCachableMarshalledValue
All Implemented Interfaces:
Externalizable, Serializable, CachableMarshalledValue, org.jboss.util.stream.IMarshalledValue

public class SimpleCachableMarshalledValue
extends Object
implements Externalizable, CachableMarshalledValue

Variation on the standard JBoss org.jboss.invocation.MarshalledValue that only converts the wrapped object to a serialized form during serialization itself. Allows the marshalled value to be cached without adding the memory overhead of maintaining a byte[] version of the wrapped object.

Version:
$Revision: 37459 $
Author:
Brian Stansberry
See Also:
Serialized Form

Constructor Summary
SimpleCachableMarshalledValue()
          Exposed for externalization.
SimpleCachableMarshalledValue(Serializable obj)
           
SimpleCachableMarshalledValue(Serializable obj, ObjectStreamSource streamSource)
           
 
Method Summary
 boolean equals(Object obj)
           
 Serializable get()
           
 ObjectStreamSource getObjectStreamSource()
           
 int hashCode()
          Return a hash code for the wrapped object.
 byte[] peekSerializedForm()
           
 Serializable peekUnderlyingObject()
           
 void readExternal(ObjectInput in)
          The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.
 void setObjectStreamSource(ObjectStreamSource objectStreamSource)
           
 byte[] toByteArray()
          Serialize any deserialized wrapped object to a byte[] and release any references to the deserialized form.
 String toString()
           
 void writeExternal(ObjectOutput out)
          The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleCachableMarshalledValue

public SimpleCachableMarshalledValue()
Exposed for externalization.


SimpleCachableMarshalledValue

public SimpleCachableMarshalledValue(Serializable obj)

SimpleCachableMarshalledValue

public SimpleCachableMarshalledValue(Serializable obj,
                                     ObjectStreamSource streamSource)
Method Detail

get

public Serializable get()
                 throws IOException,
                        ClassNotFoundException
Specified by:
get in interface org.jboss.util.stream.IMarshalledValue
Throws:
IOException
ClassNotFoundException

toByteArray

public byte[] toByteArray()
                   throws IOException
Description copied from interface: CachableMarshalledValue
Serialize any deserialized wrapped object to a byte[] and release any references to the deserialized form.

Specified by:
toByteArray in interface CachableMarshalledValue
Returns:
the serialized form of the wrapped object, or null if there was no wrapped object.
Throws:
IOException

peekUnderlyingObject

public Serializable peekUnderlyingObject()

peekSerializedForm

public byte[] peekSerializedForm()

getObjectStreamSource

public ObjectStreamSource getObjectStreamSource()

setObjectStreamSource

public void setObjectStreamSource(ObjectStreamSource objectStreamSource)

hashCode

public int hashCode()
Return a hash code for the wrapped object.

Overrides:
hashCode in class Object
Returns:
the serialized form value hash.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Specified by:
readExternal in interface Externalizable
Parameters:
in - the stream to read data from in order to restore the object
Throws:
IOException - if I/O errors occur
ClassNotFoundException - If the class for an object being restored cannot be found.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Specified by:
writeExternal in interface Externalizable
Parameters:
out - the stream to write the object to
Throws:
IOException - Includes any I/O exceptions that may occur


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.