Assists with the serialization process and performs additional functionality based on serialization.
This class throws exceptions for invalid null inputs.
Each method documents its behaviour in more detail.
| Modifier and Type | Class and Description |
|---|---|
| private static class | SerializationHelper.CustomObjectInputStream
By default, to resolve the classes being deserialized JDK serialization uses the classes loader which loaded the class which initiated the deserialization call. |
| Modifier and Type | Field and Description |
|---|---|
| private static final CoreMessageLogger |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Object | Returns: the cloned objectthe object)Serializable object to cloneDeep clone an |
| public static ClassLoader | |
| public static <T> T | Returns: the deserialized objectthe serialized object input stream, must not be null inputStream)Deserializes an object from the specified stream using the Thread Context ClassLoader (TCCL). |
| public static Object | Returns: the deserialized objectthe serialized object input stream, must not be null inputStream, ClassLoader The classloader to use loader)Deserializes an object from the specified stream using the Thread Context ClassLoader (TCCL). |
| public static Object | Returns: the deserialized objectthe serialized object, must not be null objectData)Deserializes an object from an array of bytes using the Thread Context ClassLoader (TCCL). |
| public static Object | Returns: the deserialized objectthe serialized object, must not be null objectData, ClassLoader The classloader to use loader)Deserializes an object from an array of bytes. |
| public static <T> T | doDeserialize(InputStream inputStream, ClassLoader loader, ClassLoader fallbackLoader1, ClassLoader fallbackLoader2)
|
| public static ClassLoader | |
| public static void | serialize(Serializable
the object to serialize to bytes, may be null obj, OutputStream the stream to write to, must not be null outputStream)Serializes an |
| public static byte[] | Returns: a byte[] with the converted Serializablethe object to serialize to bytes obj)Serializes an |
| private static InputStream |
| LOG | back to summary |
|---|---|
| private static final CoreMessageLogger LOG | |
| SerializationHelper | back to summary |
|---|---|
| private SerializationHelper() | |
| clone | back to summary |
|---|---|
| public static Object clone(Serializable object) throws SerializationException Deep clone an
This is many times slower than writing clone methods by hand
on all objects in your object graph. However, for complex object
graphs, or for those that don't support deep cloning this can
be a simple alternative implementation. Of course all the objects
must be
| |
| defaultClassLoader | back to summary |
|---|---|
| public static ClassLoader defaultClassLoader() Returns the Thread Context ClassLoader (TCCL).
| |
| deserialize | back to summary |
|---|---|
| public static <T> T deserialize(InputStream inputStream) throws SerializationException Deserializes an object from the specified stream using the Thread Context ClassLoader (TCCL).
Delegates to
| |
| deserialize | back to summary |
|---|---|
| public static Object deserialize(InputStream inputStream, ClassLoader loader) throws SerializationException Deserializes an object from the specified stream using the Thread Context ClassLoader (TCCL). If there is no TCCL set, the classloader of the calling class is used. The stream will be closed once the object is read. This avoids the need for a finally clause, and maybe also exception handling, in the application code. The stream passed in is not buffered internally within this method. This is the responsibility of the caller, if desired.
| |
| deserialize | back to summary |
|---|---|
| public static Object deserialize(byte[] objectData) throws SerializationException Deserializes an object from an array of bytes using the Thread Context ClassLoader (TCCL). If there is no TCCL set, the classloader of the calling class is used.
Delegates to
| |
| deserialize | back to summary |
|---|---|
| public static Object deserialize(byte[] objectData, ClassLoader loader) throws SerializationException Deserializes an object from an array of bytes.
Delegates to
| |
| doDeserialize | back to summary |
|---|---|
public static <T> T doDeserialize(InputStream inputStream, ClassLoader loader, ClassLoader fallbackLoader1, ClassLoader fallbackLoader2) throws SerializationException
| |
| hibernateClassLoader | back to summary |
|---|---|
| public static ClassLoader hibernateClassLoader() | |
| serialize | back to summary |
|---|---|
| public static void serialize(Serializable obj, OutputStream outputStream) throws SerializationException Serializes an
The stream will be closed once the object is written. This avoids the need for a finally clause, and maybe also exception handling, in the application code.
The stream passed in is not buffered internally within this method. This is the responsibility of your application if desired.
| |
| serialize | back to summary |
|---|---|
| public static byte[] serialize(Serializable obj) throws SerializationException Serializes an
| |
| wrap | back to summary |
|---|---|
| private static InputStream wrap(byte[] objectData) | |
| Modifier and Type | Field and Description |
|---|---|
| private final ClassLoader | |
| private final ClassLoader | |
| private final ClassLoader |
| Access | Constructor and Description |
|---|---|
| private | CustomObjectInputStream(InputStream in, ClassLoader loader1, ClassLoader loader2, ClassLoader loader3)
|
| Modifier and Type | Method and Description |
|---|---|
| private boolean | |
| protected Class | resolveClass(ObjectStreamClass
an instance of class v)ObjectStreamClassOverrides java. |
| loader1 | back to summary |
|---|---|
| private final ClassLoader loader1 | |
| loader2 | back to summary |
|---|---|
| private final ClassLoader loader2 | |
| loader3 | back to summary |
|---|---|
| private final ClassLoader loader3 | |
| CustomObjectInputStream | back to summary |
|---|---|
| private CustomObjectInputStream(InputStream in, ClassLoader loader1, ClassLoader loader2, ClassLoader loader3) throws IOException | |
| different | back to summary |
|---|---|
| private boolean different(ClassLoader one, ClassLoader other) | |
| resolveClass | back to summary |
|---|---|
| protected Class Overrides java. Doc from java. Load the local class equivalent of the specified stream class description. Subclasses may implement this method to allow classes to be fetched from an alternate source. The corresponding method in The default implementation of this method in
Class.forName(desc.getName(), false, loader) loader is the first class loader on the current
thread's stack (starting from the currently executing method) that is
neither the platform
class loader nor its ancestor; otherwise, loader is the
platform class loader. If this call results in a
ClassNotFoundException and the name of the passed
ObjectStreamClass instance is the Java language keyword
for a primitive type or void, then the Class object
representing that primitive type or void will be returned
(e.g., an ObjectStreamClass with the name
"int" will be resolved to Integer.TYPE).
Otherwise, the ClassNotFoundException will be thrown to
the caller of this method.
| |