Package com.caucho.hessian.io
Class SerializerFactory
- java.lang.Object
-
- com.caucho.hessian.io.AbstractSerializerFactory
-
- com.caucho.hessian.io.SerializerFactory
-
- Direct Known Subclasses:
BeanSerializerFactory
public class SerializerFactory extends AbstractSerializerFactory
Factory for returning serialization methods.
-
-
Field Summary
Fields Modifier and Type Field Description protected CollectionSerializer
_collectionSerializer
protected Serializer
_defaultSerializer
protected java.util.ArrayList
_factories
protected MapSerializer
_mapSerializer
-
Constructor Summary
Constructors Constructor Description SerializerFactory()
SerializerFactory(java.lang.ClassLoader loader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 classprotected 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.
-
-
-
Field Detail
-
_defaultSerializer
protected Serializer _defaultSerializer
-
_factories
protected java.util.ArrayList _factories
-
_collectionSerializer
protected CollectionSerializer _collectionSerializer
-
_mapSerializer
protected MapSerializer _mapSerializer
-
-
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 classAbstractSerializerFactory
- 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 classAbstractSerializerFactory
- 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
-
-