@ThreadSafe public final class InterceptorChain extends java.lang.Object implements 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.
| Constructor and Description |
|---|
InterceptorChain()
Creates an unknown InterceptorChain.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
com.google.common.collect.ImmutableList<MessageInterceptor> |
getInterceptors()
Returns the immutable list of
registered
message interceptors. |
int |
hashCode() |
Message<java.lang.String> |
intercept(Message<java.lang.String> interceptedMessage)
Intercepts a message using all registered interceptors and returns the resulting message.
|
void |
register(MessageInterceptor messageInterceptor) |
public com.google.common.collect.ImmutableList<MessageInterceptor> getInterceptors()
registered
message interceptors.public void register(MessageInterceptor messageInterceptor)
@Nullable public Message<java.lang.String> intercept(@Nonnull Message<java.lang.String> interceptedMessage)
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 null is returned, the message must be dropped by the AbstractMessageEndpoint.
Every interceptor may transform the message, or may take additional actions like, for example, logging, monitoring or other things.
intercept in interface MessageInterceptorinterceptedMessage - the message to interceptpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object