How to inject a CDI bean in Apache CXF Interceptor ?
Issue
-
Is it possible to make CDI bean injected in an Apache CXF Interceptor ?
-
We have a demo application, and within which we have a CXF interceptor,
CXF Interceptor:
public class TestServiceInterceptor extends AbstractPhaseInterceptor<Message> {
@Inject
Logger logger;
public TestServiceInterceptor() {
super(Phase.RECEIVE);
}
-
In the above, the
@Injectis not injecting the required Logger class. -
However, the same
@Injectwith Logger is injected and works fine in a JAX-WS handler,
JAX-WS handler:
public class TestServiceHandler implements LogicalHandler<LogicalMessageContext> {
@Inject Logger logger;
@Override
public boolean handleMessage(final LogicalMessageContext context) {
logger.info("call came handleMessage");
return true;
}
Environment
- Red Hat Enterprise Application Platform (EAP)
- 6.x
- 7.x
- Web Services
- JBossWS-CXF
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.