Class DefaultSerializer

  • All Implemented Interfaces:
    ClassLoaderAware, Serializer

    @Named("java")
    public final class DefaultSerializer
    extends Object
    implements Serializer, ClassLoaderAware
    A Serializer implementation that uses the ExternalizableHelper implementation for serialization and deserialization of objects.
    Since:
    Coherence 3.4
    Author:
    cp/jh 2006.07.21 (SimpleSerializer)
    • Constructor Detail

      • DefaultSerializer

        public DefaultSerializer()
        Default constructor.
      • DefaultSerializer

        public DefaultSerializer​(ClassLoader loader)
        Construct a DefaultSerializer that will use the passed ClassLoader.
        Parameters:
        loader - the ClassLoader to use for deserialization
    • Method Detail

      • serialize

        public void serialize​(WriteBuffer.BufferOutput out,
                              Object o)
                       throws IOException
        Description copied from interface: Serializer
        Serialize an object to a WriteBuffer by writing its state using the specified BufferOutput object.

        Note: Starting with Coherence 12.2.1 classes that need to designate an alternative object to be used by the Serializer when writing the object to the buffer should implement the SerializationSupport.writeReplace() method.

        Specified by:
        serialize in interface Serializer
        Parameters:
        out - the BufferOutput with which to write the object's state
        o - the object to serialize
        Throws:
        IOException - if an I/O error occurs
      • deserialize

        public Object deserialize​(ReadBuffer.BufferInput in)
                           throws IOException
        Description copied from interface: Serializer
        Deserialize an object from a ReadBuffer by reading its state using the specified BufferInput object.

        Note: Starting with Coherence 12.2.1 classes that need to designate an alternative object to be returned by the Serializer after an object is deserialized from the buffer should implement the SerializationSupport.readResolve() method.

        Specified by:
        deserialize in interface Serializer
        Parameters:
        in - the BufferInput with which to read the object's state
        Returns:
        the deserialized user type instance
        Throws:
        IOException - if an I/O error occurs
      • getName

        public String getName()
        Description copied from interface: Serializer
        Return the name of this serializer.
        Specified by:
        getName in interface Serializer
        Returns:
        the name of this serializer
      • setContextClassLoader

        public void setContextClassLoader​(ClassLoader loader)
        Description copied from interface: ClassLoaderAware
        Specify the context ClassLoader for this object. The context ClassLoader can be set when the object is created, and allows the creator to provide the appropriate class loader to be used by the object when when loading classes and resources.
        Specified by:
        setContextClassLoader in interface ClassLoaderAware
        Parameters:
        loader - the context ClassLoader for this object
      • toString

        public String toString()
        Return a description of this DefaultSerializer.
        Overrides:
        toString in class Object
        Returns:
        a String representation of the DefaultSerializer object