I have injected with the help of CDI 1.1 as below.
beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
cxf-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="callerInfoInterceptor" class="my.CallerInfoInterceptor" />
<cxf:bus>
<cxf:inInterceptors>
<ref bean="callerInfoInterceptor" />
</cxf:inInterceptors>
<cxf:properties>
......
.....
</cxf:properties>
</cxf:bus>
</beans>
CallerInfoInterceptor.java (CXF Interceptor)
public class CallerInfoInterceptor extends AbstractPhaseInterceptor<Message> {
@Inject CallerInfoBean callerInfo; // bean
public CallerInfoInterceptor() {
super(Phase.RECEIVE);
}
@Override
public void handleMessage(Message message){
...........
if (callerInfo == null) {
callerInfo =
javax.enterprise.inject.spi.CDI.current().select(CallerInfoBean.class).get();
}
}
handleMessge()
and not in the constructor. Please see my answer below. – Truism