|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.fikin.classmarshaling.MarshaledObject
public class MarshaledObject
Wraps an object into a serializable representation.
Unlike straight forward implementation with java.io.Serializable, this object wraps object's class information in addition to the object itself thus allowing the object to be de-serialized in an environment where the class information might be missing.
During serialization, MarshaledObject
will serialize the object
and all its classes, which ClassSelector.isClassToBeMarshaled(Class)
indicates.
During de-serializing, MarshaledObject
will resolve the classes
either from the default classloader or from the serialization stream.
An example how to serialize an object:
where following:
import net.sf.fikin.classmarshaling.MarshaledObject;
import net.sf.fikin.classmarshaling.Selector;
import net.sf.fikin.classmarshaling.util.NamePrefixedClassSelector;
Selector selector = new NamePrefixedClassSelector({ "mypkg", "mycls" });
// not serialize the "mo" instead of "myObj"
MarshaledObject mo = new MarshaledObject( myObj, selector );
To de-serialize the object:
created on Aug 2, 2005
import net.sf.fikin.classmarshaling.MarshaledObject;
// de-serialize the "mo"
MarshaledObject mo = ...;
MyCls myObj = (MyCls) mo.get();
Constructor Summary | |
---|---|
MarshaledObject(java.lang.Object obj,
ClassSelector selector)
Wrapper for the object and selected classes of his, represented internally in a serialized form. |
Method Summary | |
---|---|
java.lang.Object |
get()
Returns a new instance of the contained marshaled (serialized) object. |
java.lang.Object |
get(java.lang.ClassLoader parent)
Returns a new instance of the contained marshaled (serialized) object. |
protected java.util.Map |
getClassBytecodes()
Get a new instance of the serialized classes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MarshaledObject(java.lang.Object obj, ClassSelector selector) throws java.io.IOException
Once wrapped, a new instance of the object can be extracted via
get()
and get(ClassLoader)
.
obj
- to be marshaledselector
- is selecting which classes are to be serialized together
with the object
java.io.IOException
- in case an internal error occurred during
serializing the object or its classesMethod Detail |
---|
public java.lang.Object get() throws java.io.IOException, java.lang.ClassNotFoundException
Context class loader is used to initially resolve classes.
If not found then the list with serialized classes is checked.
If not found there either de-serialization will fail with
ClassNotFoundException
.
java.io.IOException
- in case an internal error occurred while
de-serializing the object or its classes.
java.lang.ClassNotFoundException
- when during the object
de-serialization, some class was needed but not found by the given
classloader, neither in the serialized classes.
could not be foundpublic java.lang.Object get(java.lang.ClassLoader parent) throws java.io.IOException, java.lang.ClassNotFoundException
Given class loader is used to initially resolve classes.
If not found then the list with serialized classes is checked.
If not found there either de-serialization will fail with
ClassNotFoundException
.
parent
- classloader
java.io.IOException
- in case an internal error occurred while
de-serializing the object or its classes.
java.lang.ClassNotFoundException
- when during the object
de-serialization, some class was needed but not found by the given
classloader, neither in the serialized classes.
could not be foundprotected java.util.Map getClassBytecodes() throws java.io.IOException, java.lang.ClassNotFoundException
Returned map is used by MarshaledClassLoader
, which is
responsible for de-serializing the object.
java.io.IOException
- in case of internal de-serialization error
java.lang.ClassNotFoundException
- in case the serialized map with classes
cannot be de-serialized because of missing class
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |