de.otto.synapse.annotation.MessageInterceptor Maven / Gradle / Ivy
Show all versions of synapse-core Show documentation
package de.otto.synapse.annotation;
import de.otto.synapse.configuration.SynapseAutoConfiguration;
import de.otto.synapse.endpoint.EndpointType;
import de.otto.synapse.message.Message;
import de.otto.synapse.message.TextMessage;
import java.lang.annotation.*;
/**
* An annotation that marks a method to be used as a {@link de.otto.synapse.endpoint.MessageInterceptor}.
*
* The annotated method must expect a single argument with parameter type
* {@link TextMessage}, or {@link Message Message<String>}. The return type can either be
* {@code Textmessage}, {@code Message<String>} or void.
*
*
{@code MessageInterceptors} can be used as {@link de.otto.synapse.endpoint.MessageFilter}: If
* the annotated method is returning {@code null}, the intercepted message will be dropped, without
* sending and/or processing it.
*
* Processing of {@code @MessageInterceptor} annotations is performed by
* a {@link MessageInterceptorBeanPostProcessor} that is auto-configured in
* {@link SynapseAutoConfiguration}.
*
* @see TextMessage
* @see de.otto.synapse.endpoint.MessageInterceptor
* @see MessageInterceptorBeanPostProcessor
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MessageInterceptor {
/**
* The optional regexp pattern used to select channels by name.
*
*
By default, all channels will be intercepted.
*
* @return regexp
*/
String channelNamePattern() default ".*";
/**
* The optional {@code EndpointType}(s) that will be intercepted.
*
* By default, both {@link EndpointType#SENDER} and {@link EndpointType#RECEIVER} endpoints will
* be intercepted.
*
* @return intercepted {@code EndpointType}(s)
*/
EndpointType[] endpointType() default {EndpointType.SENDER, EndpointType.RECEIVER};
}