org.springframework.amqp.support.converter
Class DefaultClassMapper

java.lang.Object
  extended by org.springframework.amqp.support.converter.DefaultClassMapper
All Implemented Interfaces:
ClassMapper, org.springframework.beans.factory.InitializingBean

public class DefaultClassMapper
extends java.lang.Object
implements ClassMapper, org.springframework.beans.factory.InitializingBean

Maps to/from JSON using type information in the MessageProperties; the default name of the message property containing the type is '__TypeId__'. An optional property setDefaultType(Class) is provided that allows mapping to a statically defined type, if no message property is found in the message properties.


Field Summary
static java.lang.String DEFAULT_CLASSID_FIELD_NAME
           
 
Constructor Summary
DefaultClassMapper()
           
 
Method Summary
 void afterPropertiesSet()
           
 void fromClass(java.lang.Class<?> clazz, MessageProperties properties)
           
 java.lang.String getClassIdFieldName()
           
 void setDefaultHashtableClass(java.lang.Class<?> defaultHashtableClass)
           
 void setDefaultType(java.lang.Class<?> defaultType)
          The type returned by toClass(MessageProperties) if no type information is found in the message properties.
 void setIdClassMapping(java.util.Map<java.lang.String,java.lang.Class<?>> idClassMapping)
           
 java.lang.Class<?> toClass(MessageProperties properties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CLASSID_FIELD_NAME

public static final java.lang.String DEFAULT_CLASSID_FIELD_NAME
See Also:
Constant Field Values
Constructor Detail

DefaultClassMapper

public DefaultClassMapper()
Method Detail

setDefaultType

public void setDefaultType(java.lang.Class<?> defaultType)
The type returned by toClass(MessageProperties) if no type information is found in the message properties.

Parameters:
defaultType - the defaultType to set

setDefaultHashtableClass

public void setDefaultHashtableClass(java.lang.Class<?> defaultHashtableClass)

getClassIdFieldName

public java.lang.String getClassIdFieldName()

setIdClassMapping

public void setIdClassMapping(java.util.Map<java.lang.String,java.lang.Class<?>> idClassMapping)

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

fromClass

public void fromClass(java.lang.Class<?> clazz,
                      MessageProperties properties)
Specified by:
fromClass in interface ClassMapper

toClass

public java.lang.Class<?> toClass(MessageProperties properties)
Specified by:
toClass in interface ClassMapper