【发布时间】:2014-08-11 16:09:07
【问题描述】:
我有一个复杂的场景,我不知道该怎么做:
我的 ejb 在远程服务器上运行。
而我的 Web 应用程序在不同的服务器上运行。
我有一个 ApplicationContext,它会根据域、语言、国家等不同而有所不同。
我希望将此应用程序上下文匿名传递给远程 EJB,这样开发人员就不必使用 ApplicationContext 作为参数来调用他们的所有后端请求。
这是场景,假设我有一个远程无状态 EJB:
@Stateless
public class MyStateless implements MyStatelessRemote{
//The application context that needs to be supplied form the front-end
@Inject //probably define a producer method to always supply a new one.
private ApplicationContext applicationContext;
public void doCheckSomething(final MySomethingData data){}
}
在前端:
@SessionScoped
@Named
public class MyController implements Serializable{
@EJB
private MyStatelessRemote statelessRemote
//The current application/session context to be passed to the Stateless ejb on every invocation.
@Inject
private ApplicationContext executionContext;
public void doSomeOrderOrSomethingSimilar(){
//At this point, the current application context needs to be supplied to the remote EJB
//Which it may use to check on order validity based on configurations such as country
//language etc.
statelessRemote.doCheckSomething(mySomething);
}
}
拥有超过 20 个 EJBS,每个 EJBS 平均有 8 到 10 个方法,并且考虑到几乎每个 ejb 都可能需要知道调用者的执行上下文的可能性, 是否可以在调用任何方法期间通过配置或其他方式解析当前执行上下文到 ejb?
- 我将 Wildfly8 与远程 ejb3.1、CDI1.1、JSF2.2 一起使用
- 应用程序上下文可能会在例如用户更改他/她的语言时发生变化
编辑:
我正在寻找类似于 Web Service 入站和出站拦截器的东西。
【问题讨论】:
标签: java jakarta-ee cdi ejb-3.1 wildfly-8