当我在接口中使用camel @Header注释,并直接调用bean (实现它)时,标头值就会被填充。但是当我用spring代理它时,带@ ProxyFactoryBean注释的参数是空的。可能我做错了什么,或者我遗漏了配置的一部分。
public interface Foo {
public void execute(@Header("FooHeader") String headerValue);
}
public class FooImpl implements Foo {
public void execute(String headerValue) {
System.out.println(headerValue);
}
}
public class FooInterceptor implements org.aopalliance.intercept.MethodInterceptor {
public Object invoke(final MethodInvocation invocation) throws Throwable {
return invocation.proceed();
}
}spring上下文:
<bean id="foo" class="FooImpl"/>
<bean id="fooInterceptor" class="FooInterceptor"/>
<bean id="fooProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target" ref="foo"/>
<property name="interfaces">
<list>
<value>Foo</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>fooInterceptor</value>
</list>
</property>
</bean>camel路由DSL:
from("foo-queue").to("bean:foo?method=execute");打印标题的值,但路由:
from("foo-queue").to("bean:fooProxy?method=execute");打印null。似乎在我的设置中,camel没有“看到”代理实现的接口上的头注释。
那么,如何让camel看到注释并将头的值作为参数注入到方法中呢?
发布于 2016-02-18 15:43:30
ProxyFactoryBean是一个弹簧,而不是骆驼,因此它不知道那些骆驼注释。
相反,请看这里如何在Spring XML文件中使用Camel代理:http://camel.apache.org/using-camelproxy.html
https://stackoverflow.com/questions/35463631
复制相似问题