Package com.ibm.ws.serialization
Interface SerializationService
public interface SerializationService
A service for serializing user objects that can contain references to
product internal objects.
As an alternative to this service, if the serialization/deserialization
will always happen using an application thread context class loader, then DeserializationObjectInputStream
could
be used with thread context class loader if the necessary classes are all
exported with the thread-context attribute. This approach does not work if
an application thread context class loader is not used or if replacers or
resolvers are needed.
-
Method Summary
Modifier and TypeMethodDescriptionCreates a deserialization context that uses all globally registeredDeserializationObjectResolver
andDeserializationClassProvider
, and which allows additional customizations.createObjectInputStream
(InputStream input, ClassLoader classLoader) Create a stream for deserializing objects using a default context, which uses all registeredDeserializationClassProvider
andDeserializationObjectReplacer
.createObjectOutputStream
(OutputStream output) Create a stream for serializing objects using a default context, which uses all registeredSerializationObjectReplacer
.Creates a serialization context that uses all globally registeredSerializationObjectReplacer
, and which allows additional customizations.replaceObjectForSerialization
(Object object) Attempt to return an object appropriate for serialization.resolveObject
(Object object) Resolve an object returned by replaceObjectForSerialization.resolveObjectWithException
(Object object) Resolve an object returned by replaceObjectForSerialization.
-
Method Details
-
createSerializationContext
SerializationContext createSerializationContext()Creates a serialization context that uses all globally registeredSerializationObjectReplacer
, and which allows additional customizations. -
createObjectOutputStream
Create a stream for serializing objects using a default context, which uses all registeredSerializationObjectReplacer
.- Parameters:
output
- the output stream to write serialized object data- Returns:
- a stream for serialization
- Throws:
IOException
- if theObjectOutputStream
constructor throws an exception
-
createDeserializationContext
DeserializationContext createDeserializationContext()Creates a deserialization context that uses all globally registeredDeserializationObjectResolver
andDeserializationClassProvider
, and which allows additional customizations. -
createObjectInputStream
ObjectInputStream createObjectInputStream(InputStream input, ClassLoader classLoader) throws IOException Create a stream for deserializing objects using a default context, which uses all registeredDeserializationClassProvider
andDeserializationObjectReplacer
. When deserializing application objects, the specified class loader is typically the thread context class loader.- Parameters:
input
- the input stream containing serialized object dataclassLoader
- the class loader for resolving classes- Returns:
- a stream for deserialization
- Throws:
IOException
- if theObjectInputStream
constructor throws an exception
-
replaceObjectForSerialization
Attempt to return an object appropriate for serialization. This can be used by services that need to know whether or not an object can be serialized. If non-null is returned, the object should be passed to ObjectOutputStream.writeObject.- Parameters:
object
- an object potentially for serialization- Returns:
- an object for serialization, or null if the object cannot be serialized
- See Also:
-
resolveObject
Resolve an object returned by replaceObjectForSerialization. If an error occurs while resolving an object, a RuntimeException will be thrown.- Parameters:
object
- an object returned byreplaceObjectForSerialization(java.lang.Object)
- Returns:
- a resolved object, or the input object if it does not need to be resolved
- Throws:
RuntimeException
- if an error occurs while resolving the object
-
resolveObjectWithException
Resolve an object returned by replaceObjectForSerialization.- Parameters:
object
- an object returned byreplaceObjectForSerialization(java.lang.Object)
- Returns:
- a resolved object, or the input object if it does not need to be resolved
- Throws:
IOException
-