- All Implemented Interfaces:
public class MarshalledValue
- extends Object
- implements Serializable
Wrapper that wraps cached data, providing lazy deserialization using the calling thread's context class loader.
MarshalledValueInterceptor handles transparent wrapping/unwrapping of cached
NOTE: the equals() method of this class will either compare binary representations (byte arrays) or
delegate to the wrapped instance's equals() method, depending on whether both instances being compared are
in serialized or deserialized form. If one of the instances being compared is in one form and the other in another
form, then one instance is either serialized or deserialized, the preference will be to compare object representations,
unless the instance is
compact(boolean, boolean)ed and a preference is set accordingly.
Note also that this will affect the way keys stored in the cache will work, if storeAsBinary is used, since
comparisons happen on the key which will be wrapped by a
MarshalledValue. Implementers of equals()
methods of their keys need to be aware of this.
This class can be marshalled either via its externalizer or via the JVM
serialization. The reason for supporting both methods is to enable
third-party libraries to be able to marshall/unmarshall them using standard
JVM serialization rules. The Infinispan marshalling layer will always
chose the most performant one, aka the externalizer method.
- Manik Surtani (email@example.com), Mircea.Markus@jboss.com, Galder Zamarreño, Sanne Grinovero
- See Also:
protected volatile Object instance
protected volatile MarshalledValueByteStream raw
protected volatile int serialisedSize
public MarshalledValue(Object instance,
public MarshalledValueByteStream serialize()
public Object deserialize()
public void compact(boolean preferSerializedRepresentation,
- Compacts the references held by this class to a single reference. If only one representation exists this method
is a no-op unless the 'force' parameter is used, in which case the reference held is forcefully switched to the
Either way, a call to compact() will ensure that only one representation is held.
preferSerializedRepresentation - if true and both representations exist, the serialized representation is
favoured. If false, the deserialized representation is preferred.
force - ensures the preferred representation is maintained and the other released,
even if this means serializing or deserializing.
public MarshalledValueByteStream getRaw()
public Object get()
- Returns the 'cached' instance
public boolean equals(Object o)
equals in class
public int hashCode()
hashCode in class
public String toString()
toString in class
public MarshalledValue setEqualityPreferenceForInstance(boolean equalityPreferenceForInstance)
public static boolean isTypeExcluded(Class<?> type)
- Tests whether the type should be excluded from MarshalledValue wrapping.
type - type to test. Should not be null.
- true if it should be excluded from MarshalledValue wrapping.
Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.