org.openmrs.api.impl
Class SerializationServiceImpl

java.lang.Object
  extended by org.openmrs.api.impl.BaseOpenmrsService
      extended by org.openmrs.api.impl.SerializationServiceImpl
All Implemented Interfaces:
OpenmrsService, SerializationService

@Transactional
public class SerializationServiceImpl
extends BaseOpenmrsService
implements SerializationService

Contains methods for retrieving registered OpenmrsSerializer instances, and for persisting/retrieving/deleting objects using serialization


Field Summary
 org.apache.commons.logging.Log log
           
 
Constructor Summary
SerializationServiceImpl()
           
 
Method Summary
<T> T
deserialize(java.lang.String serializedObject, java.lang.Class<? extends T> objectClass, java.lang.Class<? extends OpenmrsSerializer> serializerClass)
          Deserialize the given string into a full object using the given OpenmrsSerializer class
 OpenmrsSerializer getDefaultSerializer()
          Returns the default serializer configured for the system.
 OpenmrsSerializer getSerializer(java.lang.Class<? extends OpenmrsSerializer> serializationClass)
          Returns the serializer that matches the passed class, or null if no such serializer exists.
 java.util.List<? extends OpenmrsSerializer> getSerializers()
          Gets the list of OpenmrsSerializers that have been registered with this service.
 java.lang.String serialize(java.lang.Object o, java.lang.Class<? extends OpenmrsSerializer> clazz)
          Serialize the passed object into an identifying string that can be retrieved later using the passed OpenmrsSerializer class
 void setSerializers(java.util.List<? extends OpenmrsSerializer> serializers)
           
 
Methods inherited from class org.openmrs.api.impl.BaseOpenmrsService
onShutdown, onStartup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openmrs.api.OpenmrsService
onShutdown, onStartup
 

Field Detail

log

public org.apache.commons.logging.Log log
Constructor Detail

SerializationServiceImpl

public SerializationServiceImpl()
Method Detail

getSerializer

public OpenmrsSerializer getSerializer(java.lang.Class<? extends OpenmrsSerializer> serializationClass)
Description copied from interface: SerializationService
Returns the serializer that matches the passed class, or null if no such serializer exists.

Specified by:
getSerializer in interface SerializationService
Parameters:
serializationClass - - the serialization class to retrieve
Returns:
OpenmrsSerializer that matches the passed class
See Also:
SerializationService.getSerializer(java.lang.Class)

getDefaultSerializer

public OpenmrsSerializer getDefaultSerializer()
Description copied from interface: SerializationService
Returns the default serializer configured for the system. This enables a user to serialize objects without needing to know the underlying serialization implementation class.

Specified by:
getDefaultSerializer in interface SerializationService
Returns:
OpenmrsSerializer the default configured serializer
See Also:
SerializationService.getDefaultSerializer()

serialize

public java.lang.String serialize(java.lang.Object o,
                                  java.lang.Class<? extends OpenmrsSerializer> clazz)
                           throws SerializationException
Description copied from interface: SerializationService
Serialize the passed object into an identifying string that can be retrieved later using the passed OpenmrsSerializer class

Specified by:
serialize in interface SerializationService
Parameters:
o - - the object to serialize
clazz - - the OpenmrsSerializer class to use for serialization
Returns:
String representing this object
Throws:
SerializationException
See Also:
SerializationService.serialize(java.lang.Object, java.lang.Class)

deserialize

public <T> T deserialize(java.lang.String serializedObject,
                         java.lang.Class<? extends T> objectClass,
                         java.lang.Class<? extends OpenmrsSerializer> serializerClass)
              throws SerializationException
Description copied from interface: SerializationService
Deserialize the given string into a full object using the given OpenmrsSerializer class

Specified by:
deserialize in interface SerializationService
Parameters:
serializedObject - - String to deserialize into an Object
objectClass - - The class to deserialize the Object into
serializerClass - - The OpenmrsSerializer class to use to perform the deserialization
Returns:
hydrated object of the appropriate type
Throws:
SerializationException
See Also:
SerializationService.deserialize(java.lang.String, java.lang.Class, java.lang.Class)

getSerializers

public java.util.List<? extends OpenmrsSerializer> getSerializers()
Description copied from interface: SerializationService
Gets the list of OpenmrsSerializers that have been registered with this service.

Modules are able to add more serializers by adding this in their moduleApplicationContext. e.g.:
        <bean parent="serializationServiceTarget">
                <property name="serializers">
                <list>
                        <ref bean="xstreamSerializer"/>
                </list>
                </property>
  </bean>
  <bean id="xstreamSerializer" class="org.openmrs.module.serialization.xstream.XStreamSerializer"/>
 

Specified by:
getSerializers in interface SerializationService
Returns:
the serializers

setSerializers

public void setSerializers(java.util.List<? extends OpenmrsSerializer> serializers)
Parameters:
serializers - the serializers to set
Expected behavior:
not reset serializers list when called multiple times

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change