Class TransientInjectableObjectOutputStream
java.lang.Object
java.io.OutputStream
java.io.ObjectOutputStream
com.vaadin.kubernetes.starter.sessiontracker.serialization.SerializationOutputStream
com.vaadin.kubernetes.starter.sessiontracker.serialization.TransientInjectableObjectOutputStream
- All Implemented Interfaces:
Closeable,DataOutput,Flushable,ObjectOutput,ObjectStreamConstants,AutoCloseable
An
ObjectOutputStream implementation that adds to the binary stream
information about transient fields that can potentially be injected on
deserialization.
It inspects instances of classes to get information about transient fields
and related instance identifiers. When injectable transient candidates are
detected, an object holding transient field details and a reference to the
current instance is written into the stream. This object will then be used
during deserialization to try to automatically inject values into transient
fields of the deserialized object.
Object inspection if performed by a pluggable TransientHandler object
whose aim is to provide information about transient fields along with an
object identifier for the instance being serialized, in the form of
TransientDescriptor objects.
To improve performance, a filter can be provided to inspect only classes
known to have injectable transient fields. For example inspection can be
restricted to only some packages. Classes from Java Platform are excluded
regardless of the configured filters.
new TransientInjectableObjectOutputStream(os, handler,
type -> type.getPackageName().startsWith("com.vaadin.app"))
.writeWithTransients(target);
Output of this class is meant to be read by
TransientInjectableObjectInputStream.-
Nested Class Summary
Nested classes/interfaces inherited from class java.io.ObjectOutputStream
ObjectOutputStream.PutField -
Field Summary
Fields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, SERIAL_FILTER_PERMISSION, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectIn debug mode notify handler of not Serializable Object and potentially replace current object with a serializable instance or with null, to prevent NotSerializableException and continue the inspection on other objectsnewInstance(OutputStream out, TransientHandler inspector) newInstance(OutputStream out, TransientHandler inspector, Predicate<Class<?>> injectableFilter) protected ObjectreplaceObject(Object obj) protected voidvoidwriteWithTransients(Object object) Methods inherited from class java.io.ObjectOutputStream
annotateClass, annotateProxyClass, close, defaultWriteObject, drain, enableReplaceObject, flush, putFields, reset, useProtocolVersion, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFields, writeFloat, writeInt, writeLong, writeObject, writeObjectOverride, writeShort, writeStreamHeader, writeUnshared, writeUTFMethods inherited from class java.io.OutputStream
nullOutputStream
-
Method Details
-
newInstance
public static TransientInjectableObjectOutputStream newInstance(OutputStream out, TransientHandler inspector) throws IOException - Throws:
IOException
-
newInstance
public static TransientInjectableObjectOutputStream newInstance(OutputStream out, TransientHandler inspector, Predicate<Class<?>> injectableFilter) throws IOException - Throws:
IOException
-
writeWithTransients
- Specified by:
writeWithTransientsin classSerializationOutputStream- Throws:
IOException
-
writeClassDescriptor
- Overrides:
writeClassDescriptorin classObjectOutputStream- Throws:
IOException
-
replaceObject
- Overrides:
replaceObjectin classObjectOutputStream
-
handleNotSerializable
In debug mode notify handler of not Serializable Object and potentially replace current object with a serializable instance or with null, to prevent NotSerializableException and continue the inspection on other objects
-