com.caucho.hessian.io
Class SerializerFactory

java.lang.Object
  extended by com.caucho.hessian.io.AbstractSerializerFactory
      extended by com.caucho.hessian.io.SerializerFactory
Direct Known Subclasses:
BeanSerializerFactory

public class SerializerFactory
extends AbstractSerializerFactory

Factory for returning serialization methods.


Field Summary
private  Deserializer _arrayListDeserializer
           
private  java.util.concurrent.ConcurrentHashMap _cachedDeserializerMap
           
private  java.util.concurrent.ConcurrentHashMap _cachedSerializerMap
           
private  java.util.HashMap _cachedTypeDeserializerMap
           
protected  CollectionSerializer _collectionSerializer
           
private  ContextSerializerFactory _contextFactory
           
private static java.util.WeakHashMap<java.lang.ClassLoader,java.lang.ref.SoftReference<SerializerFactory>> _defaultFactoryRefMap
           
protected  Serializer _defaultSerializer
           
protected  java.util.ArrayList _factories
           
private  Deserializer _hashMapDeserializer
           
private  boolean _isAllowNonSerializable
           
private  boolean _isEnableUnsafeSerializer
           
private  java.lang.ClassLoader _loader
           
protected  MapSerializer _mapSerializer
           
private static java.util.HashMap _staticTypeMap
           
private static java.lang.ClassLoader _systemClassLoader
           
private static java.util.logging.Logger log
           
private static Deserializer OBJECT_DESERIALIZER
           
 
Constructor Summary
SerializerFactory()
           
SerializerFactory(java.lang.ClassLoader loader)
           
 
Method Summary
private static void addBasic(java.lang.Class cl, java.lang.String typeName, int type)
           
 void addFactory(AbstractSerializerFactory factory)
          Adds a factory.
static SerializerFactory createDefault()
           
 java.lang.ClassLoader getClassLoader()
           
protected  Deserializer getCustomDeserializer(java.lang.Class cl)
          Returns a custom serializer the class
protected  Deserializer getDefaultDeserializer(java.lang.Class cl)
          Returns the default serializer for a class that isn't matched directly.
protected  Serializer getDefaultSerializer(java.lang.Class cl)
          Returns the default serializer for a class that isn't matched directly.
 Deserializer getDeserializer(java.lang.Class cl)
          Returns the deserializer for a class.
 Deserializer getDeserializer(java.lang.String type)
          Returns a deserializer based on a string type.
 Deserializer getListDeserializer(java.lang.String type)
          Reads the object as a map.
 Deserializer getListDeserializer(java.lang.String type, java.lang.Class cl)
          Reads the object as a map.
 Deserializer getObjectDeserializer(java.lang.String type)
          Reads the object as a map.
 Deserializer getObjectDeserializer(java.lang.String type, java.lang.Class cl)
          Reads the object as a map.
 Serializer getObjectSerializer(java.lang.Class<?> cl)
          Returns the serializer for a class.
 Serializer getSerializer(java.lang.Class cl)
          Returns the serializer for a class.
 boolean isAllowNonSerializable()
          If true, non-serializable objects are allowed.
protected  Deserializer loadDeserializer(java.lang.Class cl)
           
protected  Serializer loadSerializer(java.lang.Class cl)
           
 java.lang.Object readList(AbstractHessianInput in, int length, java.lang.String type)
          Reads the object as a list.
 java.lang.Object readMap(AbstractHessianInput in, java.lang.String type)
          Reads the object as a map.
 java.lang.Object readObject(AbstractHessianInput in, java.lang.String type, java.lang.String[] fieldNames)
          Reads the object as a map.
 void setAllowNonSerializable(boolean allow)
          If true, non-serializable objects are allowed.
 void setSendCollectionType(boolean isSendType)
          Set true if the collection serializer should send the java type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log

OBJECT_DESERIALIZER

private static final Deserializer OBJECT_DESERIALIZER

_systemClassLoader

private static final java.lang.ClassLoader _systemClassLoader

_staticTypeMap

private static final java.util.HashMap _staticTypeMap

_defaultFactoryRefMap

private static final java.util.WeakHashMap<java.lang.ClassLoader,java.lang.ref.SoftReference<SerializerFactory>> _defaultFactoryRefMap

_contextFactory

private ContextSerializerFactory _contextFactory

_loader

private java.lang.ClassLoader _loader

_defaultSerializer

protected Serializer _defaultSerializer

_factories

protected java.util.ArrayList _factories

_collectionSerializer

protected CollectionSerializer _collectionSerializer

_mapSerializer

protected MapSerializer _mapSerializer

_hashMapDeserializer

private Deserializer _hashMapDeserializer

_arrayListDeserializer

private Deserializer _arrayListDeserializer

_cachedSerializerMap

private java.util.concurrent.ConcurrentHashMap _cachedSerializerMap

_cachedDeserializerMap

private java.util.concurrent.ConcurrentHashMap _cachedDeserializerMap

_cachedTypeDeserializerMap

private java.util.HashMap _cachedTypeDeserializerMap

_isAllowNonSerializable

private boolean _isAllowNonSerializable

_isEnableUnsafeSerializer

private boolean _isEnableUnsafeSerializer
Constructor Detail

SerializerFactory

public SerializerFactory()

SerializerFactory

public SerializerFactory(java.lang.ClassLoader loader)
Method Detail

createDefault

public static SerializerFactory createDefault()

getClassLoader

public java.lang.ClassLoader getClassLoader()

setSendCollectionType

public void setSendCollectionType(boolean isSendType)
Set true if the collection serializer should send the java type.


addFactory

public void addFactory(AbstractSerializerFactory factory)
Adds a factory.


setAllowNonSerializable

public void setAllowNonSerializable(boolean allow)
If true, non-serializable objects are allowed.


isAllowNonSerializable

public boolean isAllowNonSerializable()
If true, non-serializable objects are allowed.


getObjectSerializer

public Serializer getObjectSerializer(java.lang.Class<?> cl)
                               throws HessianProtocolException
Returns the serializer for a class.

Parameters:
cl - the class of the object that needs to be serialized.
Returns:
a serializer object for the serialization.
Throws:
HessianProtocolException

getSerializer

public Serializer getSerializer(java.lang.Class cl)
                         throws HessianProtocolException
Returns the serializer for a class.

Specified by:
getSerializer in class AbstractSerializerFactory
Parameters:
cl - the class of the object that needs to be serialized.
Returns:
a serializer object for the serialization.
Throws:
HessianProtocolException

loadSerializer

protected Serializer loadSerializer(java.lang.Class cl)
                             throws HessianProtocolException
Throws:
HessianProtocolException

getDefaultSerializer

protected Serializer getDefaultSerializer(java.lang.Class cl)
Returns the default serializer for a class that isn't matched directly. Application can override this method to produce bean-style serialization instead of field serialization.

Parameters:
cl - the class of the object that needs to be serialized.
Returns:
a serializer object for the serialization.

getDeserializer

public Deserializer getDeserializer(java.lang.Class cl)
                             throws HessianProtocolException
Returns the deserializer for a class.

Specified by:
getDeserializer in class AbstractSerializerFactory
Parameters:
cl - the class of the object that needs to be deserialized.
Returns:
a deserializer object for the serialization.
Throws:
HessianProtocolException

loadDeserializer

protected Deserializer loadDeserializer(java.lang.Class cl)
                                 throws HessianProtocolException
Throws:
HessianProtocolException

getCustomDeserializer

protected Deserializer getCustomDeserializer(java.lang.Class cl)
Returns a custom serializer the class

Parameters:
cl - the class of the object that needs to be serialized.
Returns:
a serializer object for the serialization.

getDefaultDeserializer

protected Deserializer getDefaultDeserializer(java.lang.Class cl)
Returns the default serializer for a class that isn't matched directly. Application can override this method to produce bean-style serialization instead of field serialization.

Parameters:
cl - the class of the object that needs to be serialized.
Returns:
a serializer object for the serialization.

readList

public java.lang.Object readList(AbstractHessianInput in,
                                 int length,
                                 java.lang.String type)
                          throws HessianProtocolException,
                                 java.io.IOException
Reads the object as a list.

Throws:
HessianProtocolException
java.io.IOException

readMap

public java.lang.Object readMap(AbstractHessianInput in,
                                java.lang.String type)
                         throws HessianProtocolException,
                                java.io.IOException
Reads the object as a map.

Throws:
HessianProtocolException
java.io.IOException

readObject

public java.lang.Object readObject(AbstractHessianInput in,
                                   java.lang.String type,
                                   java.lang.String[] fieldNames)
                            throws HessianProtocolException,
                                   java.io.IOException
Reads the object as a map.

Throws:
HessianProtocolException
java.io.IOException

getObjectDeserializer

public Deserializer getObjectDeserializer(java.lang.String type,
                                          java.lang.Class cl)
                                   throws HessianProtocolException
Reads the object as a map.

Throws:
HessianProtocolException

getObjectDeserializer

public Deserializer getObjectDeserializer(java.lang.String type)
                                   throws HessianProtocolException
Reads the object as a map.

Throws:
HessianProtocolException

getListDeserializer

public Deserializer getListDeserializer(java.lang.String type,
                                        java.lang.Class cl)
                                 throws HessianProtocolException
Reads the object as a map.

Throws:
HessianProtocolException

getListDeserializer

public Deserializer getListDeserializer(java.lang.String type)
                                 throws HessianProtocolException
Reads the object as a map.

Throws:
HessianProtocolException

getDeserializer

public Deserializer getDeserializer(java.lang.String type)
                             throws HessianProtocolException
Returns a deserializer based on a string type.

Throws:
HessianProtocolException

addBasic

private static void addBasic(java.lang.Class cl,
                             java.lang.String typeName,
                             int type)


Copyright 2003-2011. All Rights Reserved.