Class MarshalledInstance
- All Implemented Interfaces:
Serializable
MarshalledInstance contains an object in serialized form. The contained object can
be deserialized on demand when explicitly requested. This allows an object to be sent from one VM
to another in a way that allows the receiver to control when and if the object is deserialized.
The contained object is specified at construction time and can either be provided in
unserialized or serialized form. If provided in unserialized form it will be serialized during
construction with the serialization semantics defined by MarshalOutputStream. In
particular, classes are annotated with a codebase URL from which the class can be loaded (if
available).
If the MarshalledInstance needs to deserialize the contained object
then the contained object will be deserialized with the deserialization semantics defined by
MarshalInputStream. In particular, the codebase annotations associated with the
contained object may be used to load classes referenced by the contained object.
MarshalledInstance provides functionality similar to
java.rmi.MarshalledObject, but additionally provides for the verification of
codebase integrity. Unlike java.rmi.MarshalledObject, it does not perform remote
object-to-stub replacement.
- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMarshalledInstance(Object obj) Creates a newMarshalledInstancethat contains the marshalled representation of the current state of the supplied object.MarshalledInstance(Object obj, Collection context) Creates a newMarshalledInstancethat contains the marshalled representation of the current state of the supplied object.Creates a newMarshalledInstancefrom an existingMarshalledObject. -
Method Summary
Modifier and TypeMethodDescriptionCreates a newMarshalledObjectthat will contain an object equivalent to the object contained in thisMarshalledInstanceobject.booleanCompares thisMarshalledInstanceto another object.booleanfullyEquals(Object obj) Compares thisMarshalledInstanceto another object.get(boolean verifyCodebaseIntegrity) Returns a new copy of the contained object.get(ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader, Collection context) Returns a new copy of the contained object.inthashCode()Returns the hash code for thisMarshalledInstance.
-
Field Details
-
USE_GZIP_PROPERTY
- See Also:
-
-
Constructor Details
-
MarshalledInstance
Creates a newMarshalledInstancethat contains the marshalled representation of the current state of the supplied object. The object is serialized with the semantics defined byMarshalOutputStream. The output stream used to marshal the object implementsObjectStreamContextand returns an empty collection from itsgetObjectStreamContextmethod.- Parameters:
obj- The Object to be contained in the newMarshalledInstance- Throws:
IOException- if the object cannot be serialized
-
MarshalledInstance
Creates a newMarshalledInstancethat contains the marshalled representation of the current state of the supplied object. The object is serialized with the semantics defined byMarshalOutputStream. The output stream used to marshal the object implementsObjectStreamContextand returns the given collection from itsgetObjectStreamContextmethod.- Parameters:
obj- The Object to be contained in the newMarshalledInstancecontext- the collection of context information objects- Throws:
IOException- if the object cannot be serializedNullPointerException- ifcontextisnull
-
MarshalledInstance
Creates a newMarshalledInstancefrom an existingMarshalledObject. An object equivalent to the object contained in the passedMarshalledObjectwill be contained in the newMarshalledInstance.The object contained in the passed
MarshalledObjectwill not be unmarshalled as part of this call.- Parameters:
mo- TheMarshalledObjectthat contains the object the newMarshalledInstanceshould contain- Throws:
NullPointerException- ifmoisnull
-
-
Method Details
-
convertToMarshalledObject
Creates a newMarshalledObjectthat will contain an object equivalent to the object contained in thisMarshalledInstanceobject.The object contained in this
MarshalledInstanceobject will not be unmarshalled as part of this call.- Returns:
- A new
MarshalledObjectwhich contains an object equivalent to the object contained in thisMarshalledInstance
-
get
Returns a new copy of the contained object. Deserialization is performed with the semantics defined byMarshalInputStream. The input stream used to unmarshal the object implementsObjectStreamContextand returns a collection from itsgetObjectStreamContextmethod which contains a single element of typeIntegrityEnforcement; theintegrityEnforcedmethod of this element returns the specifiedverifyCodebaseIntegrityvalue.MarshalledInstance implements this method by calling
.get(null, verifyCodebaseIntegrity, null, null)- Parameters:
verifyCodebaseIntegrity- iftruethen codebase integrity is verified, otherwise code base integrity is not verified- Returns:
- a new copy of the contained object
- Throws:
IOException- if anIOExceptionoccurs while deserializing the object from its internal representationClassNotFoundException- if any classes necessary for reconstructing the contained object can not be found or ifverifyCodebaseIntegrityistrueand the integrity of the contained object's codebase cannot be confirmed
-
get
public Object get(ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader, Collection context) throws IOException, ClassNotFoundException Returns a new copy of the contained object. Deserialization is performed with the semantics defined byMarshalInputStream. Ifcontextis notnullthe input stream used to unmarshal the object implementsObjectStreamContextand returns the given collection from itsgetObjectStreamContextmethod.If
contextisnullthe input stream used to unmarshal the object implementsObjectStreamContextand returns a collection from itsgetObjectStreamContextmethod which contains a single element of typeIntegrityEnforcement; theintegrityEnforcedmethod of this element returns the specifiedverifyCodebaseIntegrityvalue.- Parameters:
defaultLoader- the class loader value (possiblynull) to pass as thedefaultLoaderargument toRMIClassLoadermethodsverifyCodebaseIntegrity- iftruethen codebase integrity is verified, otherwise code base integrity is not verifiedverifierLoader- the class loader value (possiblynull) to pass toSecurity.verifyCodebaseIntegrity, ifverifyCodebaseIntegrityistruecontext- the collection of context information objects ornull- Returns:
- a new copy of the contained object
- Throws:
IOException- if anIOExceptionoccurs while deserializing the object from its internal representationClassNotFoundException- if any classes necessary for reconstructing the contained object can not be found or ifverifyCodebaseIntegrityistrueand the integrity of the contained object's codebase cannot be confirmed
-
fullyEquals
Compares thisMarshalledInstanceto another object. Returns true if and only if the argument refers to an instance ofMarshalledInstancethat contains exactly the same serialized form for its contained object as this object does and has the same class codebase annotations.- Parameters:
obj- the object to compare with thisMarshalledInstance- Returns:
trueif the argument contains an object with an equivalent serialized form and codebase; otherwise returnsfalse
-
equals
Compares thisMarshalledInstanceto another object. Returns true if and only if the argument refers to an instance ofMarshalledInstancethat contains exactly the same serialized form for its contained object as this object does. The comparison ignores any class codebase annotations, so that two objects can be equivalent if they have the same serialized representation, except for the codebase of each class in the serialized representation. -
hashCode
public int hashCode()Returns the hash code for thisMarshalledInstance. The hash code is calculated only from the serialized form of the contained object.
-