Class ContentEnricher
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractMessageProducingHandler
org.springframework.integration.handler.AbstractReplyProducingMessageHandler
org.springframework.integration.transformer.ContentEnricher
- All Implemented Interfaces:
- org.reactivestreams.Subscriber<Message<?>>,- Aware,- BeanClassLoaderAware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Lifecycle,- Ordered,- ExpressionCapable,- Orderable,- MessageProducer,- HeaderPropagationAware,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- ManageableLifecycle,- TrackableComponent,- MessageHandler,- reactor.core.CoreSubscriber<Message<?>>
public class ContentEnricher
extends AbstractReplyProducingMessageHandler
implements ManageableLifecycle
Content Enricher is a Message Transformer that can augment a message's payload with
 either static values or by optionally invoking a downstream message flow via its
 request channel and then applying values from the reply Message to the original
 payload.
- Since:
- 2.1
- Author:
- Mark Fisher, Gunnar Hillert, Gary Russell, Artem Bilan, Liujiong, Kris Jacyna
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandlerAbstractReplyProducingMessageHandler.RequestHandlerNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandlermessagingTemplateFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voiddoInit()Initialize the Content Enricher.Subclasses may implement this method to provide component type information.Return a pattern type this component implements.protected ObjecthandleRequestMessage(Message<?> requestMessage) Subclasses must implement this method to handle the request Message.booleanLifecycle implementation.voidsetErrorChannel(MessageChannel errorChannel) Set the content enricher error channel to allow the error handling flow to return of an alternative object to use for enrichment if exceptions occur in the downstream flow.voidsetErrorChannelName(String errorChannelName) voidsetHeaderExpressions(Map<String, HeaderValueMessageProcessor<?>> headerExpressions) Provide the map ofHeaderValueMessageProcessorto evaluate when enriching the target MessageHeaders.voidsetIntegrationEvaluationContext(EvaluationContext evaluationContext) voidsetNullResultHeaderExpressions(Map<String, HeaderValueMessageProcessor<?>> nullResultHeaderExpressions) voidsetNullResultPropertyExpressions(Map<String, Expression> nullResultPropertyExpressions) voidsetPropertyExpressions(Map<String, Expression> propertyExpressions) Provide the map of expressions to evaluate when enriching the target payload.voidsetReplyChannel(MessageChannel replyChannel) Set the content enricher reply channel.voidsetReplyChannelName(String replyChannelName) voidsetReplyTimeout(Long replyTimeout) Set the timeout value for receiving reply messages.voidsetRequestChannel(MessageChannel requestChannel) Set the content enricher request channel.voidsetRequestChannelName(String requestChannelName) voidsetRequestPayloadExpression(Expression requestPayloadExpression) By default the original message's payload will be used as the actual payload that will be send to the request-channel.voidsetRequestTimeout(Long requestTimeout) Set the timeout value for sending request messages.voidsetShouldClonePayload(boolean shouldClonePayload) Specify whether to clone payload objects to create the target object.voidstart()Lifecycle implementation.voidstop()Lifecycle implementation.Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandlerdoInvokeAdvisedRequestHandler, getBeanClassLoader, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReplyMethods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandleraddNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeadersMethods inherited from class org.springframework.integration.handler.AbstractMessageHandlerhandleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupportbuildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscribercurrentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Constructor Details- 
ContentEnricherpublic ContentEnricher()
 
- 
- 
Method Details- 
setNullResultPropertyExpressions
- 
setNullResultHeaderExpressionspublic void setNullResultHeaderExpressions(Map<String, HeaderValueMessageProcessor<?>> nullResultHeaderExpressions) 
- 
setPropertyExpressionsProvide the map of expressions to evaluate when enriching the target payload. The keys should simply be property names, and the values should be Expressions that will evaluate against the reply Message as the root object.- Parameters:
- propertyExpressions- The property expressions.
 
- 
setHeaderExpressionsProvide the map ofHeaderValueMessageProcessorto evaluate when enriching the target MessageHeaders. The keys should simply be header names, and the values should be Expressions that will evaluate against the reply Message as the root object.- Parameters:
- headerExpressions- The header expressions.
 
- 
setRequestChannelSet the content enricher request channel. If specified, then an internal Gateway will be initialized. Setting a request channel is optional. Not setting a request channel is useful in situations where message payloads shall be enriched with static values only.- Parameters:
- requestChannel- The request channel.
 
- 
setRequestChannelName
- 
setReplyChannelSet the content enricher reply channel. If not specified, yet the request channel is set, an anonymous reply channel will automatically created for each request.- Parameters:
- replyChannel- The reply channel.
 
- 
setReplyChannelName
- 
setErrorChannelSet the content enricher error channel to allow the error handling flow to return of an alternative object to use for enrichment if exceptions occur in the downstream flow.- Parameters:
- errorChannel- The error channel.
- Since:
- 4.1
 
- 
setErrorChannelName
- 
setRequestTimeoutSet the timeout value for sending request messages. If not explicitly configured, the default is 30 seconds.- Parameters:
- requestTimeout- the timeout value in milliseconds. Must not be null.
 
- 
setReplyTimeoutSet the timeout value for receiving reply messages. If not explicitly configured, the default is 30 seconds.- Parameters:
- replyTimeout- the timeout value in milliseconds. Must not be null.
 
- 
setRequestPayloadExpressionBy default the original message's payload will be used as the actual payload that will be send to the request-channel.By providing a SpEL expression as value for this setter, a subset of the original payload, a header value or any other resolvable SpEL expression can be used as the basis for the payload, that will be send to the request-channel. For the Expression evaluation the full message is available as the root object. For instance the following SpEL expressions (among others) are possible: - payload.foo
- headers.foobar
- new java.util.Date()
- 'foo' + 'bar'
 If more sophisticated logic is required (e.g. changing the message headers etc.) please use additional downstream transformers. - Parameters:
- requestPayloadExpression- The request payload expression.
 
- 
setShouldClonePayloadpublic void setShouldClonePayload(boolean shouldClonePayload) Specify whether to clone payload objects to create the target object. This is only applicable for payload types that implement Cloneable.- Parameters:
- shouldClonePayload- true if the payload should be cloned.
 
- 
setIntegrationEvaluationContext
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- MessageHandlerSupport
 
- 
getIntegrationPatternTypeDescription copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
- getIntegrationPatternTypein interface- IntegrationPattern
- Overrides:
- getIntegrationPatternTypein class- AbstractReplyProducingMessageHandler
- Returns:
- the IntegrationPatternTypethis component implements.
 
- 
doInitprotected void doInit()Initialize the Content Enricher. Will instantiate an internal Gateway if the requestChannel is set.- Overrides:
- doInitin class- AbstractReplyProducingMessageHandler
 
- 
handleRequestMessageDescription copied from class:AbstractReplyProducingMessageHandlerSubclasses must implement this method to handle the request Message. The return value may be a Message, a MessageBuilder, or any plain Object. The base class will handle the final creation of a reply Message from any of those starting points. If the return value is null, the Message flow will end here.- Specified by:
- handleRequestMessagein class- AbstractReplyProducingMessageHandler
- Parameters:
- requestMessage- The request message.
- Returns:
- The result of handling the message, or null.
 
- 
startpublic void start()Lifecycle implementation. If no requestChannel is defined, this method has no effect as in that case no Gateway is initialized.- Specified by:
- startin interface- Lifecycle
- Specified by:
- startin interface- ManageableLifecycle
 
- 
stoppublic void stop()Lifecycle implementation. If no requestChannel is defined, this method has no effect as in that case no Gateway is initialized.- Specified by:
- stopin interface- Lifecycle
- Specified by:
- stopin interface- ManageableLifecycle
 
- 
isRunningpublic boolean isRunning()Lifecycle implementation. If no requestChannel is defined, this method will return always return true as no Gateway is initialized.- Specified by:
- isRunningin interface- Lifecycle
- Specified by:
- isRunningin interface- ManageableLifecycle
 
 
-