I'm trying to use @BeanInject
in a processor but it is always null
.
I can access the bean in a RouteBuilder
, and also in a Processor if it is defined in the RouteBuilder
but not if the Processor class is in its own file.
Is this not supported or am I missing something?
[Updated] I'm using Apache Camel 2.17.2 and the code is taken from camel-example-cdi The code below prints the object instance in the first processor but not the second. The code is run in a unit test.
public class MyRoutes extends RouteBuilder {
final static Logger LOG = LoggerFactory.getLogger(MyRoutes.class);
@Inject
@Uri("timer:foo?period=5000" )
private Endpoint inputEndpoint;
@Inject
@Uri("log:output")
private Endpoint resultEndpoint;
@BeanInject
private SomeBean someBean;
@Override
public void configure() {
from("timer:foo?period=500")
.to("bean:counterBean")
.process(new Processor(){
@Override
public void process(Exchange exchange) throws Exception {
LOG.info("[" + someBean + "]");
}
})
.process(new MyProcessor())
.to("mock:result");
}
}
The processor
public class MyProcessor implements Processor {
final static Logger LOG = LoggerFactory.getLogger(MyProcessor.class);
@BeanInject
private SomeBean someBean;
@Override
public void process(Exchange exchange) throws Exception {
LOG.info("In processor [" + someBean + "]");
}
}