Class InterceptorChain
- All Implemented Interfaces:
MessageInterceptor
message interceptors that
can be used to build chains of interceptors.
Just like any other MessageInterceptor, the InterceptorChain is used to process
a message before it is consumed by message consumers
on the receiver-side, or before it is sent by a message sender
to the channel infrastructure.
The interceptors of the InterceptorChain will be called in order. The result of the first interceptor is propagated to the next interceptor, and so on.
If an interceptor returns null, the chain will return null without further processing of the message.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty InterceptorChain.InterceptorChain(com.google.common.collect.ImmutableList<MessageInterceptor> messageInterceptors) -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.collect.ImmutableList<MessageInterceptor>Returns the immutable list of registeredmessage interceptors.intercept(TextMessage message) Intercepts a message using all registered interceptors and returns the resulting message.
-
Constructor Details
-
InterceptorChain
public InterceptorChain()Creates an empty InterceptorChain. -
InterceptorChain
public InterceptorChain(com.google.common.collect.ImmutableList<MessageInterceptor> messageInterceptors)
-
-
Method Details
-
getInterceptors
Returns the immutable list of registeredmessage interceptors.- Returns:
- registered message interceptors
-
intercept
Intercepts a message using all registered interceptors and returns the resulting message.The interceptors are called in order. The result of one interceptor is propagated to the next interceptor in the chain, until the end of the chain is reached, or one interceptor has returned null.
If
nullis returned, the message must be dropped by theAbstractMessageEndpoint.Every interceptor may transform the message, or may take additional actions like, for example, logging, monitoring or other things.
- Specified by:
interceptin interfaceMessageInterceptor- Parameters:
message- the message to intercept- Returns:
- the (possibly modified) message, or null if the message should be dropped.
-