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_collectionSerializerprotected Serializer_defaultSerializerprotected java.util.ArrayList_factoriesprotected 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 voidaddFactory(AbstractSerializerFactory factory)Adds a factory.static SerializerFactorycreateDefault()java.lang.ClassLoadergetClassLoader()protected DeserializergetCustomDeserializer(java.lang.Class cl)Returns a custom serializer the classprotected DeserializergetDefaultDeserializer(java.lang.Class cl)Returns the default serializer for a class that isn't matched directly.protected SerializergetDefaultSerializer(java.lang.Class cl)Returns the default serializer for a class that isn't matched directly.DeserializergetDeserializer(java.lang.Class cl)Returns the deserializer for a class.DeserializergetDeserializer(java.lang.String type)Returns a deserializer based on a string type.DeserializergetListDeserializer(java.lang.String type)Reads the object as a map.DeserializergetListDeserializer(java.lang.String type, java.lang.Class cl)Reads the object as a map.DeserializergetObjectDeserializer(java.lang.String type)Reads the object as a map.DeserializergetObjectDeserializer(java.lang.String type, java.lang.Class cl)Reads the object as a map.SerializergetObjectSerializer(java.lang.Class<?> cl)Returns the serializer for a class.SerializergetSerializer(java.lang.Class cl)Returns the serializer for a class.booleanisAllowNonSerializable()If true, non-serializable objects are allowed.protected DeserializerloadDeserializer(java.lang.Class cl)protected SerializerloadSerializer(java.lang.Class<?> cl)java.lang.ObjectreadList(AbstractHessianInput in, int length, java.lang.String type)Reads the object as a list.java.lang.ObjectreadMap(AbstractHessianInput in, java.lang.String type)Reads the object as a map.java.lang.ObjectreadObject(AbstractHessianInput in, java.lang.String type, java.lang.String[] fieldNames)Reads the object as a map.voidsetAllowNonSerializable(boolean allow)If true, non-serializable objects are allowed.voidsetSendCollectionType(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:
getSerializerin 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:
getDeserializerin 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:
HessianProtocolExceptionjava.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:
HessianProtocolExceptionjava.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:
HessianProtocolExceptionjava.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
-
-