Class AbstractInternalDeserializer
java.lang.Object
com.pnfsoftware.jeb.util.serialization.AbstractInternalDeserializer
Base class for deserializers. Client code should not extend.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanTrue if deserialization was cancelled.protected List<ClassLoader> Class loaders used to resolve serialized types.Cache of constructor-related objects by class.protected static Map<Class<?>, com.pnfsoftware.jeb.util.serialization.AbstractInternalDeserializer.CustomMethods> Cached custom serialization methods by class.protected ITypeIdProviderOptional caller-provided type-id provider.protected List<com.pnfsoftware.jeb.util.serialization.IPreObject> Objects whose construction is deferred until the object map is available.protected intExpected number of objects to deserialize, if known.protected LEDataInputStreamInput stream providing serialized data.protected ObjectPlaceholder object used for unresolved references.protected ITypeIdProviderNative type-id provider.protected MultiMap<Class<?>, IDeserializationEventHandler> Object-created hooks by target class.protected org.objenesis.ObjenesisStdObject instantiator used for deserialization.Object ids whose post-graph initialization completed.Deserialized objects by serialized object id.protected List<IProgressCallback> Progress callbacks to notify during deserialization. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractInternalDeserializer(ITypeIdProvider customTypeIdProvider, List<ClassLoader> classloaders, LEDataInputStream in) Create an internal deserializer. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddObjectCreatedHook(Class<?> c, IDeserializationEventHandler handler) voidaddProgressCallback(IProgressCallback callback) voidclose()Close the underlying input stream.protected com.pnfsoftware.jeb.util.serialization.AbstractInternalDeserializer.CustomMethodsgetCustomMethods(Object o, Class<?> targetClass) Retrieve serialization custom methods for a target object or class.intprotected Class<?> Resolve a serialized class name.protected voidLog the current object id map for diagnostics.protected voidnotifyDeserializationEvent(int type, Class<?> c, Object o) Notify deserialization event handlers.protected voidNotify registered progress callbacks.read()Read one object, optionally into an existing object or as a target class.protected abstract ObjectreadInternal(Object object, Class<?> c) Read one object from the serialized stream.protected voidregisterObject(boolean isLeafObject, int objectId, Object o) Register a deserialized object by id.voidremoveObjectCreatedHook(Class<?> c, IDeserializationEventHandler handler) voidremoveProgressCallback(IProgressCallback callback) protected voidResolve deferred objects using the current object map.voidrestoreFields(Object o, Class<?> targetClass) Restore serialized fields on an object.protected voidrestoreFieldValue(Object o, Class<?> targetClass, int fieldId, Object fieldObject) Restore one serialized field value on an object.voidsetExpectedObjectCount(int count)
-
Field Details
-
in
Input stream providing serialized data. -
nativeTypeIdProvider
Native type-id provider. -
customTypeIdProvider
Optional caller-provided type-id provider. -
classloaders
Class loaders used to resolve serialized types. -
objenesis
protected org.objenesis.ObjenesisStd objenesisObject instantiator used for deserialization. -
cancelled
protected boolean cancelledTrue if deserialization was cancelled. -
constructorMap
Cache of constructor-related objects by class. -
mootObject
Placeholder object used for unresolved references. -
objmap
Deserialized objects by serialized object id. -
objIdPostgraphDone
Object ids whose post-graph initialization completed. -
deferredObjects
Objects whose construction is deferred until the object map is available. -
customMethods
protected static Map<Class<?>,com.pnfsoftware.jeb.util.serialization.AbstractInternalDeserializer.CustomMethods> customMethodsCached custom serialization methods by class. -
expectedObjectCount
protected int expectedObjectCountExpected number of objects to deserialize, if known. -
progressCallbacks
Progress callbacks to notify during deserialization. -
objectCreatedHookMap
Object-created hooks by target class.
-
-
Constructor Details
-
AbstractInternalDeserializer
protected AbstractInternalDeserializer(ITypeIdProvider customTypeIdProvider, List<ClassLoader> classloaders, LEDataInputStream in) Create an internal deserializer.- Parameters:
customTypeIdProvider- optional custom type-id providerclassloaders- class loaders used to resolve serialized typesin- serialized data input stream
-
-
Method Details
-
getObjectCount
public int getObjectCount() -
getObjects
-
getStream
-
deserializeInternal
- Throws:
IOException
-
close
Close the underlying input stream.- Throws:
IOException- on stream close error
-
read
- Throws:
IOException
-
read
Read one object, optionally into an existing object or as a target class.- Parameters:
object- optional existing object to populatec- optional target class- Returns:
- deserialized object
- Throws:
IOException- on deserialization error
-
readInternal
Read one object from the serialized stream.- Parameters:
object- optional existing object to populatec- optional target class- Returns:
- deserialized object
- Throws:
IOException- on deserialization error
-
registerObject
Register a deserialized object by id.- Parameters:
isLeafObject- true if the object should be stored in the object mapobjectId- serialized object ido- deserialized object
-
loadClass
Resolve a serialized class name.- Parameters:
typeName- fully-qualified type name- Returns:
- resolved class
- Throws:
ClassNotFoundException- if the class cannot be resolved
-
restoreFieldValue
protected void restoreFieldValue(Object o, Class<?> targetClass, int fieldId, Object fieldObject) throws SerializationException Restore one serialized field value on an object.- Parameters:
o- target objecttargetClass- optional class declaring the fieldfieldId- serialized field idfieldObject- field value- Throws:
SerializationException- on reflection or assignment error
-
getCustomMethods
protected com.pnfsoftware.jeb.util.serialization.AbstractInternalDeserializer.CustomMethods getCustomMethods(Object o, Class<?> targetClass) throws SerializationException Retrieve serialization custom methods for a target object or class.- Parameters:
o- target objecttargetClass- optional target class- Returns:
- custom method descriptors
- Throws:
SerializationException- if a custom method has an invalid prototype
-
resolveDeferredObjects
protected void resolveDeferredObjects()Resolve deferred objects using the current object map. -
setExpectedObjectCount
public void setExpectedObjectCount(int count) -
addProgressCallback
-
removeProgressCallback
-
notifyProgressCallbacks
protected void notifyProgressCallbacks()Notify registered progress callbacks. -
addObjectCreatedHook
-
removeObjectCreatedHook
-
notifyDeserializationEvent
Notify deserialization event handlers.- Parameters:
type- event type: 1= object created (post creation)c- object classo- deserialized object
-
logObjectMap
protected void logObjectMap()Log the current object id map for diagnostics. -
restoreFields
Restore serialized fields on an object.- Parameters:
o- target objecttargetClass- optional target class- Throws:
IOException- on deserialization error
-