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  java.util.HashMap _cachedDeserializerMap
           
private  java.util.HashMap _cachedSerializerMap
           
private  java.util.HashMap _cachedTypeDeserializerMap
           
protected  CollectionSerializer _collectionSerializer
           
protected  Serializer _defaultSerializer
           
protected  java.util.ArrayList _factories
           
private  Deserializer _hashMapDeserializer
           
private  boolean _isAllowNonSerializable
           
private static java.util.HashMap _staticDeserializerMap
           
private static java.util.HashMap _staticSerializerMap
           
private static java.util.HashMap _staticTypeMap
           
private static java.util.logging.Logger log
           
private static Deserializer OBJECT_DESERIALIZER
           
 
Constructor Summary
SerializerFactory()
           
 
Method Summary
private static void addBasic(java.lang.Class cl, java.lang.String typeName, int type)
           
 void addFactory(AbstractSerializerFactory factory)
          Adds a factory.
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 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 getSerializer(java.lang.Class cl)
          Returns the serializer for a class.
 boolean isAllowNonSerializable()
          If true, non-serializable objects are allowed.
 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 Deserializer OBJECT_DESERIALIZER

_staticSerializerMap

private static java.util.HashMap _staticSerializerMap

_staticDeserializerMap

private static java.util.HashMap _staticDeserializerMap

_staticTypeMap

private static java.util.HashMap _staticTypeMap

_defaultSerializer

protected Serializer _defaultSerializer

_factories

protected java.util.ArrayList _factories

_collectionSerializer

protected CollectionSerializer _collectionSerializer

_hashMapDeserializer

private Deserializer _hashMapDeserializer

_cachedSerializerMap

private java.util.HashMap _cachedSerializerMap

_cachedDeserializerMap

private java.util.HashMap _cachedDeserializerMap

_cachedTypeDeserializerMap

private java.util.HashMap _cachedTypeDeserializerMap

_isAllowNonSerializable

private boolean _isAllowNonSerializable
Constructor Detail

SerializerFactory

public SerializerFactory()
Method Detail

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.


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

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

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

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)