org.springframework.core.serializer.support

Class SerializationDelegate

  • java.lang.Object
    • org.springframework.core.serializer.support.SerializationDelegate
  • All Implemented Interfaces:
    Deserializer<java.lang.Object>, Serializer<java.lang.Object>


    public class SerializationDelegate
    extends java.lang.Object
    implements Serializer<java.lang.Object>, Deserializer<java.lang.Object>
    A convenient delegate with pre-arranged configuration state for common serialization needs. Implements Serializer and Deserializer itself, so can also be passed into such more specific callback methods.
    Since:
    4.3
    Author:
    Juergen Hoeller
    • Constructor Summary

      Constructors 
      Constructor and Description
      SerializationDelegate(java.lang.ClassLoader classLoader)
      Create a SerializationDelegate with a default serializer/deserializer for the given ClassLoader.
      SerializationDelegate(Serializer<java.lang.Object> serializer, Deserializer<java.lang.Object> deserializer)
      Create a SerializationDelegate with the given serializer/deserializer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Object deserialize(java.io.InputStream inputStream)
      Read (assemble) an object of type T from the given InputStream.
      void serialize(java.lang.Object object, java.io.OutputStream outputStream)
      Write an object of type T to the given OutputStream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SerializationDelegate

        public SerializationDelegate(Serializer<java.lang.Object> serializer,
                                     Deserializer<java.lang.Object> deserializer)
        Create a SerializationDelegate with the given serializer/deserializer.
        Parameters:
        serializer - the Serializer to use (never null)
        deserializer - the Deserializer to use (never null)
    • Method Detail

      • serialize

        public void serialize(java.lang.Object object,
                              java.io.OutputStream outputStream)
                       throws java.io.IOException
        Description copied from interface: Serializer
        Write an object of type T to the given OutputStream.

        Note: Implementations should not close the given OutputStream (or any decorators of that OutputStream) but rather leave this up to the caller.

        Specified by:
        serialize in interface Serializer<java.lang.Object>
        Parameters:
        object - the object to serialize
        outputStream - the output stream
        Throws:
        java.io.IOException - in case of errors writing to the stream
      • deserialize

        public java.lang.Object deserialize(java.io.InputStream inputStream)
                                     throws java.io.IOException
        Description copied from interface: Deserializer
        Read (assemble) an object of type T from the given InputStream.

        Note: Implementations should not close the given InputStream (or any decorators of that InputStream) but rather leave this up to the caller.

        Specified by:
        deserialize in interface Deserializer<java.lang.Object>
        Parameters:
        inputStream - the input stream
        Returns:
        the deserialized object
        Throws:
        java.io.IOException - in case of errors reading from the stream