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 ArrayList_factoriesprotected MapSerializer_mapSerializerprotected static Map<Class,Serializer>jdk8DateSerializeMap
-
Constructor Summary
Constructors Constructor Description SerializerFactory()SerializerFactory(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()ClassFactorygetClassFactory()ClassLoadergetClassLoader()protected DeserializergetCustomDeserializer(Class cl)Returns a custom serializer the classprotected DeserializergetDefaultDeserializer(Class cl)Returns the default serializer for a class that isn't matched directly.protected SerializergetDefaultSerializer(Class cl)Returns the default serializer for a class that isn't matched directly.DeserializergetDeserializer(Class cl)Returns the deserializer for a class.DeserializergetDeserializer(String type)Returns a deserializer based on a string type.FieldDeserializer2FactorygetFieldDeserializerFactory()DeserializergetListDeserializer(String type)Reads the object as a map.DeserializergetListDeserializer(String type, Class cl)Reads the object as a map.DeserializergetObjectDeserializer(String type)Reads the object as a map.DeserializergetObjectDeserializer(String type, Class cl)Reads the object as a map.SerializergetObjectSerializer(Class<?> cl)Returns the serializer for a class.SerializergetSerializer(Class cl)Returns the serializer for a class.booleanisAllowNonSerializable()If true, non-serializable objects are allowed.protected DeserializerloadDeserializer(Class cl)Class<?>loadSerializedClass(String className)protected SerializerloadSerializer(Class<?> cl)ObjectreadList(AbstractHessianInput in, int length, String type)Reads the object as a list.ObjectreadMap(AbstractHessianInput in, String type)Reads the object as a map.ObjectreadObject(AbstractHessianInput in, String type, 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
-
jdk8DateSerializeMap
protected static Map<Class,Serializer> jdk8DateSerializeMap
-
_defaultSerializer
protected Serializer _defaultSerializer
-
_factories
protected ArrayList _factories
-
_collectionSerializer
protected CollectionSerializer _collectionSerializer
-
_mapSerializer
protected MapSerializer _mapSerializer
-
-
Constructor Detail
-
SerializerFactory
public SerializerFactory()
-
SerializerFactory
public SerializerFactory(ClassLoader loader)
-
-
Method Detail
-
createDefault
public static SerializerFactory createDefault()
-
getClassLoader
public 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(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
-
loadSerializedClass
public Class<?> loadSerializedClass(String className) throws ClassNotFoundException
- Throws:
ClassNotFoundException
-
getClassFactory
public ClassFactory getClassFactory()
-
getFieldDeserializerFactory
public FieldDeserializer2Factory getFieldDeserializerFactory()
-
getSerializer
public Serializer getSerializer(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(Class<?> cl) throws HessianProtocolException
- Throws:
HessianProtocolException
-
getDefaultSerializer
protected Serializer getDefaultSerializer(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(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(Class cl) throws HessianProtocolException
- Throws:
HessianProtocolException
-
getCustomDeserializer
protected Deserializer getCustomDeserializer(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(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 Object readList(AbstractHessianInput in, int length, String type) throws HessianProtocolException, IOException
Reads the object as a list.- Throws:
HessianProtocolExceptionIOException
-
readMap
public Object readMap(AbstractHessianInput in, String type) throws HessianProtocolException, IOException
Reads the object as a map.- Throws:
HessianProtocolExceptionIOException
-
readObject
public Object readObject(AbstractHessianInput in, String type, String[] fieldNames) throws HessianProtocolException, IOException
Reads the object as a map.- Throws:
HessianProtocolExceptionIOException
-
getObjectDeserializer
public Deserializer getObjectDeserializer(String type, Class cl) throws HessianProtocolException
Reads the object as a map.- Throws:
HessianProtocolException
-
getObjectDeserializer
public Deserializer getObjectDeserializer(String type) throws HessianProtocolException
Reads the object as a map.- Throws:
HessianProtocolException
-
getListDeserializer
public Deserializer getListDeserializer(String type, Class cl) throws HessianProtocolException
Reads the object as a map.- Throws:
HessianProtocolException
-
getListDeserializer
public Deserializer getListDeserializer(String type) throws HessianProtocolException
Reads the object as a map.- Throws:
HessianProtocolException
-
getDeserializer
public Deserializer getDeserializer(String type) throws HessianProtocolException
Returns a deserializer based on a string type.- Throws:
HessianProtocolException
-
-