Class KryoSessionSerializer
- java.lang.Object
-
- ratpack.session.serialization.kryo.KryoSessionSerializer
-
- All Implemented Interfaces:
JavaSessionSerializer
,SessionSerializer
public class KryoSessionSerializer extends java.lang.Object implements JavaSessionSerializer
-
-
Constructor Summary
Constructors Constructor Description KryoSessionSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
configureKryo(com.esotericsoftware.kryo.kryo5.Kryo kryo)
<T> T
deserialize(java.lang.Class<T> type, java.io.InputStream in, SessionTypeFilter typeFilter)
Reads the bytes of the given input stream, creating a new object.<T> void
serialize(java.lang.Class<T> type, T value, java.io.OutputStream out, SessionTypeFilter typeFilter)
Writes the given value to the output stream as bytes.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ratpack.session.SessionSerializer
deserialize, serialize
-
-
-
-
Method Detail
-
configureKryo
protected void configureKryo(com.esotericsoftware.kryo.kryo5.Kryo kryo)
-
serialize
public <T> void serialize(java.lang.Class<T> type, T value, java.io.OutputStream out, SessionTypeFilter typeFilter) throws java.lang.Exception
Description copied from interface:SessionSerializer
Writes the given value to the output stream as bytes.Implementations MUST take care to check that all types serialized are allowed to be as per
typeFilter
. This includes the type ofvalue
and the transitive types referenced by it. Implementations should useSessionTypeFilter.assertAllowed(String)
.To enable backwards compatibility, the default implementation delegates to
SessionSerializer.serialize(Class, Object, OutputStream)
after logging a warning about the inherent security vulnerability in not checking the suitability of types. All implementations should implement this method and not that method.- Specified by:
serialize
in interfaceSessionSerializer
- Type Parameters:
T
- the type of the object- Parameters:
type
- the declared type of the objectvalue
- the value to serializeout
- the destination for the bytestypeFilter
- the filter that determines whether a type is session safe and allowed to be serialized- Throws:
java.lang.Exception
- if the value could not be serialized
-
deserialize
public <T> T deserialize(java.lang.Class<T> type, java.io.InputStream in, SessionTypeFilter typeFilter) throws java.lang.Exception
Description copied from interface:SessionSerializer
Reads the bytes of the given input stream, creating a new object.Implementations MUST take care to check that all types to be deserialized are allowed to be as per
typeFilter
. This includes the type of the object being deserialized and the transitive types referenced by it. Implementations should useSessionTypeFilter.assertAllowed(String)
.To enable backwards compatibility, the default implementation delegates to
SessionSerializer.deserialize(Class, InputStream)
after logging a warning about the inherent security vulnerability in not checking the suitability of types. All implementations should implement this method and not that method.- Specified by:
deserialize
in interfaceSessionSerializer
- Type Parameters:
T
- the type of the object- Parameters:
type
- the expected type of the objectin
- the source of the bytestypeFilter
- the filter that determines whether a type is session safe and allowed to be deserialized- Returns:
- the object
- Throws:
java.io.IOException
- any thrown byin
java.lang.Exception
- the the value could not be deserialized
-
-