Search in sources :

Example 1 with AnnotatedMethodFilter

use of org.springframework.integration.util.AnnotatedMethodFilter in project spring-integration by spring-projects.

the class MessagingMethodInvokerHelper method prepareEvaluationContext.

private void prepareEvaluationContext() throws Exception {
    StandardEvaluationContext context = getEvaluationContext(false);
    Class<?> targetType = AopUtils.getTargetClass(this.targetObject);
    if (this.method != null) {
        context.registerMethodFilter(targetType, new FixedMethodFilter(this.method));
        if (this.expectedType != null) {
            Assert.state(context.getTypeConverter().canConvert(TypeDescriptor.valueOf((this.method).getReturnType()), this.expectedType), "Cannot convert to expected type (" + this.expectedType + ") from " + this.method);
        }
    } else {
        AnnotatedMethodFilter filter = new AnnotatedMethodFilter(this.annotationType, this.methodName, this.requiresReply);
        Assert.state(canReturnExpectedType(filter, targetType, context.getTypeConverter()), "Cannot convert to expected type (" + this.expectedType + ") from " + this.method);
        context.registerMethodFilter(targetType, filter);
    }
    context.setVariable("target", this.targetObject);
    context.registerFunction("requiredHeader", ParametersWrapper.class.getDeclaredMethod("getHeader", Map.class, String.class));
}
Also used : FixedMethodFilter(org.springframework.integration.util.FixedMethodFilter) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) AnnotatedMethodFilter(org.springframework.integration.util.AnnotatedMethodFilter) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)1 AnnotatedMethodFilter (org.springframework.integration.util.AnnotatedMethodFilter)1 FixedMethodFilter (org.springframework.integration.util.FixedMethodFilter)1