Can I inject a SessionBean into a JEE AroundInvoke-Interceptor?
- by Michael Locher
I have an EAR with modules:
foo-api.jar
foo-impl.jar
interceptor.jar
In foo-api there is:
@Local
FooService // (interface of a local stateless session bean)
In foo-impl there is:
@Stateless
FooServiceImpl implements FooService //(implementation of the foo service)
In interceptor.jar I want
public class BazInterceptor {
@EJB
private FooService foo;
@AroundInvoke
public Object intercept( final InvocationContext i) throws Exception {
// do someting with foo service
return i.proceed();
}
The question is:
Will a Java EE 5 compliant application server (e.g. JBoss 5) inject into the interceptor?
If no, what is good strategy for accessing the session bean?
To consider:
Deployment ordering / race conditions