public class DefaultClassMapper extends java.lang.Object implements ClassMapper, org.springframework.beans.factory.InitializingBean
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.
setIdClassMapping(Map) can be used to map tokens in the
"__TypeId__" header to classes. If this class is not a
Spring-managed bean, call afterPropertiesSet() to set up the class to id
mapping.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_CLASSID_FIELD_NAME |
| Constructor and Description |
|---|
DefaultClassMapper() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
fromClass(java.lang.Class<?> clazz,
MessageProperties properties) |
java.lang.String |
getClassIdFieldName()
The name of the header that contains the type id.
|
void |
setDefaultMapClass(java.lang.Class<?> defaultMapClass)
Set the type of
Map to use. |
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)
Set a map of type Ids (in the "__TypeId__" header) to
classes.
|
void |
setTrustedPackages(java.lang.String... trustedPackages)
Specify a set of packages to trust during deserialization.
|
java.lang.Class<?> |
toClass(MessageProperties properties) |
public static final java.lang.String DEFAULT_CLASSID_FIELD_NAME
public void setDefaultType(java.lang.Class<?> defaultType)
toClass(MessageProperties) if no type information
is found in the message properties.defaultType - the defaultType to set.public void setDefaultMapClass(java.lang.Class<?> defaultMapClass)
Map to use. For outbound messages, set the
"__TypeId__" header to HashTable. For inbound messages,
if the "__TypeId__" header is Hashtable convert to this
class.defaultMapClass - the map class.DEFAULT_CLASSID_FIELD_NAMEpublic java.lang.String getClassIdFieldName()
DEFAULT_CLASSID_FIELD_NAMEpublic void setIdClassMapping(java.util.Map<java.lang.String,java.lang.Class<?>> idClassMapping)
idClassMapping - the map of IDs to classes.public void setTrustedPackages(java.lang.String... trustedPackages)
*) means trust all.trustedPackages - the trusted Java packages for deserializationpublic void afterPropertiesSet()
throws java.lang.Exception
Creates the reverse mapping from class to type id.
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionpublic void fromClass(java.lang.Class<?> clazz,
MessageProperties properties)
fromClass in interface ClassMapperpublic java.lang.Class<?> toClass(MessageProperties properties)
toClass in interface ClassMapper