小编Mic*_*her的帖子

我可以将SessionBean注入Java EE AroundInvoke-Interceptor吗?

我有一个带模块的EAR:

  • FOO-api.jar文件
  • FOO-impl.jar中
  • interceptor.jar

在foo-api中有:

@Local
FooService // (interface of a local stateless session bean)
Run Code Online (Sandbox Code Playgroud)

在foo-impl中有:

@Stateless
FooServiceImpl implements FooService //(implementation of the foo service)
Run Code Online (Sandbox Code Playgroud)

在interceptor.jar我想要

public class BazInterceptor {

  @EJB
  private FooService foo;

  @AroundInvoke
  public Object intercept( final InvocationContext i) throws Exception {
    // do someting with foo service
    return i.proceed();
  }
Run Code Online (Sandbox Code Playgroud)

问题是:

Java EE 5兼容的应用程序服务器(例如JBoss 5)是否会注入拦截器?如果不是,访问会话bean的好策略是什么?

考虑:

  • 部署订购/竞争条件

java jboss dependency-injection java-ee interceptor

6
推荐指数
2
解决办法
6111
查看次数

标签 统计

dependency-injection ×1

interceptor ×1

java ×1

java-ee ×1

jboss ×1