Package io.micronaut.core.serialize
Class JdkSerializer
- java.lang.Object
-
- io.micronaut.core.serialize.JdkSerializer
-
- All Implemented Interfaces:
ObjectSerializer
public class JdkSerializer extends java.lang.Object implements ObjectSerializer
AObjectSerializer
that uses JDK serialization.- Since:
- 1.0
-
-
Field Summary
-
Fields inherited from interface io.micronaut.core.serialize.ObjectSerializer
JDK
-
-
Constructor Summary
Constructors Constructor Description JdkSerializer()
Default constructor.JdkSerializer(ConversionService<?> conversionService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.io.ObjectInputStream
createObjectInput(java.io.InputStream inputStream, java.lang.Class<?> requiredType)
protected java.io.ObjectOutputStream
createObjectOutput(java.io.OutputStream outputStream)
<T> java.util.Optional<T>
deserialize(java.io.InputStream inputStream, Argument<T> requiredType)
Deserialize the given object to bytes.<T> java.util.Optional<T>
deserialize(java.io.InputStream inputStream, java.lang.Class<T> requiredType)
Deserialize the given object to bytes.void
serialize(java.lang.Object object, java.io.OutputStream outputStream)
Serialize the given object to a byte[].-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.core.serialize.ObjectSerializer
deserialize, deserialize, deserialize, serialize
-
-
-
-
Constructor Detail
-
JdkSerializer
public JdkSerializer(ConversionService<?> conversionService)
- Parameters:
conversionService
- The conversion service
-
JdkSerializer
public JdkSerializer()
Default constructor.
-
-
Method Detail
-
serialize
public void serialize(java.lang.Object object, java.io.OutputStream outputStream) throws SerializationException
Description copied from interface:ObjectSerializer
Serialize the given object to a byte[].- Specified by:
serialize
in interfaceObjectSerializer
- Parameters:
object
- The object to serializeoutputStream
- The output stream- Throws:
SerializationException
- if there is a serialization problem
-
deserialize
public <T> java.util.Optional<T> deserialize(java.io.InputStream inputStream, java.lang.Class<T> requiredType) throws SerializationException
Description copied from interface:ObjectSerializer
Deserialize the given object to bytes.- Specified by:
deserialize
in interfaceObjectSerializer
- Type Parameters:
T
- The required generic type- Parameters:
inputStream
- The input streamrequiredType
- The required type- Returns:
- An
Optional
of the object - Throws:
SerializationException
- if there is a serialization problem
-
deserialize
public <T> java.util.Optional<T> deserialize(java.io.InputStream inputStream, Argument<T> requiredType) throws SerializationException
Description copied from interface:ObjectSerializer
Deserialize the given object to bytes.- Specified by:
deserialize
in interfaceObjectSerializer
- Type Parameters:
T
- The required generic type- Parameters:
inputStream
- The input streamrequiredType
- The required type- Returns:
- An
Optional
of the object - Throws:
SerializationException
- if there is a serialization problem
-
createObjectOutput
protected java.io.ObjectOutputStream createObjectOutput(java.io.OutputStream outputStream) throws java.io.IOException
- Parameters:
outputStream
- The output stream- Returns:
- A new
ObjectOutputStream
- Throws:
java.io.IOException
- if there is an error
-
createObjectInput
protected java.io.ObjectInputStream createObjectInput(java.io.InputStream inputStream, java.lang.Class<?> requiredType) throws java.io.IOException
- Parameters:
inputStream
- The input streamrequiredType
- The required type- Returns:
- A
ObjectOutputStream
- Throws:
java.io.IOException
- if there is an error
-
-