org.springframework.integration.json
Class ObjectToJsonTransformer
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.transformer.AbstractTransformer
org.springframework.integration.json.ObjectToJsonTransformer
- 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 ObjectToJsonTransformer
- extends AbstractTransformer
Transformer implementation that converts a payload instance into a JSON string representation.
- Since:
- 2.0
- Author:
- Mark Fisher, James Carr, Oleg Zhurakousky, Gary Russell
Method Summary |
protected java.lang.Object |
doTransform(Message<?> message)
Subclasses must implement this method to provide the transformation
logic. |
void |
setContentType(java.lang.String contentType)
Sets the content-type header value |
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
JSON_CONTENT_TYPE
public static final java.lang.String JSON_CONTENT_TYPE
- See Also:
- Constant Field Values
ObjectToJsonTransformer
public ObjectToJsonTransformer(org.codehaus.jackson.map.ObjectMapper objectMapper)
ObjectToJsonTransformer
public ObjectToJsonTransformer()
setContentType
public void setContentType(java.lang.String contentType)
- Sets the content-type header value
- Parameters:
contentType
-
doTransform
protected java.lang.Object doTransform(Message<?> message)
throws java.lang.Exception
- Description copied from class:
AbstractTransformer
- Subclasses must implement this method to provide the transformation
logic. If the return value is itself a Message, it will be used as the
result. Otherwise, any non-null return value will be used as the payload
of the result Message.
- Specified by:
doTransform
in class AbstractTransformer
- Throws:
java.lang.Exception