Can I inject a SessionBean into a JEE AroundInvoke-Interceptor?

Posted by Michael Locher on Stack Overflow See other posts from Stack Overflow or by Michael Locher
Published on 2009-05-25T13:40:39Z Indexed on 2010/04/05 7:03 UTC
Read the original article Hit count: 345

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

© Stack Overflow or respective owner

Related posts about interceptor

Related posts about java-ee