Can I insert SessionBean in Java EE AroundInvoke-Interceptor?

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 arises:

Will a Java EE 5 interceptor server (e.g. JBoss 5) be deployed? If not, what is a good strategy for accessing a bean session?

Think:

  • Deployment / placement conditions
+5
source share
2 answers

Yes, the injection should happen in the interceptor, as mentioned, for example, in Introduction to the Java EE 5 Platform (bold - mine)

Easier access to resources through dependency injection

- . , , . Java EE 5 , , . Java EE 5 - EJB , .

, @Resource , , @EJB @WebServiceRef . , :

  • SessionContext
  • DataSources
  • UserTransaction
  • EntityManager
  • TimerService
  • beans
  • -
  • (, , ..)

, , . EJB , , :

  • EJB
  • Java API - XML (JAX-WS) Java API XML-RPC (JAX-RPC)

- , :

  • , ,
  • ,
  • beans

login .

. EJB Interceptors JBoss EJB 3.0:

bean, . , ENC, bean .

...

, , bean, . , bean .

+6

, : EJB (Entity, Session Message) .

-1

All Articles