org.apache.muse.core.serializer
Class SerializerRegistry

java.lang.Object
  extended byorg.apache.muse.core.serializer.SerializerRegistry

public class SerializerRegistry
extends java.lang.Object

SerializerRegistry is a singleton component that keeps track of what Java types have Muse Serializers for use by SOAP handlers and user code. The class will automatically register all of Muse's built-in serializers for basic types when it is instantiated; the Muse core engine will also register user-defined serializers when it finds them in the deployment descriptor. Although the deployment descriptor is the preferred way of adding a serializer to the registry, there is nothing preventing a user from doing so programmtically using the registerSerializer() method.

Author:
Dan Jemiolo (danj)

Method Summary
static SerializerRegistry getInstance()
           
 Serializer getSerializer(java.lang.Class type)
           
 void registerSerializer(java.lang.Class type, Serializer ser)
          Associates the given serializer with the type and any of its sub-types.
protected  Serializer searchClassHierarchy(java.lang.Class type)
          Looks through the parent class and interfaces of the given type to see if one of them has a registered serializer that could be used on the sub-type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static SerializerRegistry getInstance()
Returns:
The singleton instance of this class.

getSerializer

public Serializer getSerializer(java.lang.Class type)
Parameters:
type - The Java class that will be serialized to XML (and back).
Returns:
The Serializer that can handle the given Java type.

registerSerializer

public void registerSerializer(java.lang.Class type,
                               Serializer ser)
Associates the given serializer with the type and any of its sub-types. An ArraySerializer is also created for arrays of the type.

Parameters:
type -
ser -

searchClassHierarchy

protected Serializer searchClassHierarchy(java.lang.Class type)
Looks through the parent class and interfaces of the given type to see if one of them has a registered serializer that could be used on the sub-type. The paren classes are considered first, then the interfaces of the type, then the interfaces of each parent class.

Parameters:
type -
Returns:
A serializer for one of the type's parent classes or interfaces, or null if no possible serializer is found.