【发布时间】:2014-04-04 10:22:15
【问题描述】:
从 WAR 与 EJB 容器定义/运行 EJB 时,EJB 的功能有什么不同吗?决定一种方法与另一种方法的优缺点是什么。
从 WAR 访问它时我们会失去哪些能力?
在我们的例子中,开发人员希望使用 EJB 来创建/访问 REST Web 服务。
我们的一位建筑师在下面提到。出于这个原因,他希望有一个单独的 EJB,可以将其添加(jar)到 EAR 中,也可以添加到 WAR 中,以将其用作 REST 端点。我不想在多个地方都有它
I’d prefer our approach to put transaction/service based code in EJBs to
leverage Container Managed Transactions, JPA, MDB and all the good stuff EJBs
have to offer.
从我阅读的关于使用 EJB 作为 REST 服务实现的文档中,它说
Add the EJB class to the WEB-INF/classes directory of your WAR file or to a
JAR that is located in your WEB-INF/lib directory. When a client makes a request
to a JAX-RS annotated enterprise bean, the JAX-RS runtime environment looks up
and uses an EJB instance of the class to invoke the resource method.
所以,我想知道,如果我们将 EJB 放在 WAR 中 - 就像在 WAR 的源中创建源一样,以便在构建 WAR 时将类添加到 WEB-INF/classes 中,而不是让根据用途将同一个 ejb jar 放在两个不同的地方 - 作为 REST Web 服务端点与其他功能,它会满足所有要求还是我必须将 jar 放在两个地方?
如果答案不同,我正在使用带有 EJB 3.1 的 Websphere 8.5。
【问题讨论】:
标签: websphere java-ee-6 ejb-3.1