Spring Integration

org.springframework.integration.transformer
Class MapToObjectTransformer

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.transformer.AbstractTransformer
          extended by org.springframework.integration.transformer.AbstractPayloadTransformer<java.util.Map<?,?>,java.lang.Object>
              extended by org.springframework.integration.transformer.MapToObjectTransformer
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, NamedComponent, Transformer

public class MapToObjectTransformer
extends AbstractPayloadTransformer<java.util.Map<?,?>,java.lang.Object>

Will transform Map to an instance of Object. There are two ways to specify the type of the transformed Object. You can use one of two constructors. The constructor that takes the Class<?> as an argument will construct the Object of that type. There is another constructor that takes a 'beanName' as an argument and will populate this bean with transformed data. Such bean must be of 'prototype' scope otherwise MessageTransformationException will be thrown. This transformer is integrated with the ConversionService allowing values in the Map to be converted to types that represent the properties of the Object.

Since:
2.0
Author:
Oleg Zhurakousky

Field Summary
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
MapToObjectTransformer(java.lang.Class<?> targetClass)
           
MapToObjectTransformer(java.lang.String beanName)
           
 
Method Summary
protected  void onInit()
          Subclasses may implement this for initialization logic.
protected  java.lang.Object transformPayload(java.util.Map<?,?> payload)
           
 
Methods inherited from class org.springframework.integration.transformer.AbstractPayloadTransformer
doTransform
 
Methods inherited from class org.springframework.integration.transformer.AbstractTransformer
transform
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MapToObjectTransformer

public MapToObjectTransformer(java.lang.Class<?> targetClass)
Parameters:
targetClass -

MapToObjectTransformer

public MapToObjectTransformer(java.lang.String beanName)
Parameters:
beanName -
Method Detail

transformPayload

protected java.lang.Object transformPayload(java.util.Map<?,?> payload)
                                     throws java.lang.Exception
Specified by:
transformPayload in class AbstractPayloadTransformer<java.util.Map<?,?>,java.lang.Object>
Throws:
java.lang.Exception

onInit

protected void onInit()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class IntegrationObjectSupport

Spring Integration