Example usage for org.springframework.integration.util MessagingAnnotationUtils findAnnotatedMethod

List of usage examples for org.springframework.integration.util MessagingAnnotationUtils findAnnotatedMethod

Introduction

In this page you can find the example usage for org.springframework.integration.util MessagingAnnotationUtils findAnnotatedMethod.

Prototype

public static Method findAnnotatedMethod(Object target, final Class<? extends Annotation> annotationType) 

Source Link

Usage

From source file:org.springframework.integration.config.ReleaseStrategyFactoryBean.java

@Override
public void afterPropertiesSet() throws Exception {
    if (this.target instanceof ReleaseStrategy && !StringUtils.hasText(this.methodName)) {
        this.strategy = (ReleaseStrategy) this.target;
        return;//from   w w  w . ja  v a  2 s .  co m
    }
    if (this.target != null) {
        if (StringUtils.hasText(this.methodName)) {
            this.strategy = new MethodInvokingReleaseStrategy(this.target, this.methodName);
        } else {
            Method method = MessagingAnnotationUtils.findAnnotatedMethod(this.target,
                    org.springframework.integration.annotation.ReleaseStrategy.class);
            if (method != null) {
                this.strategy = new MethodInvokingReleaseStrategy(this.target, method);
            } else {
                if (logger.isWarnEnabled()) {
                    logger.warn("No ReleaseStrategy annotated method found on "
                            + this.target.getClass().getSimpleName()
                            + "; falling back to SequenceSizeReleaseStrategy, target:" + this.target
                            + ", methodName:" + this.methodName);
                }
            }
        }
    } else {
        if (logger.isWarnEnabled()) {
            logger.warn("No target supplied; falling back to SequenceSizeReleaseStrategy");
        }
    }
}