我使用jersey实现了RESTful Web服务并将其部署在Tomcat上,我使用DAO类来操作数据库操作,实体包装数据库记录。 并在单独的包中进行处理。 我想使用EJB分发这个系统。 首先,做这个改变会很容易。 或者我需要从头开始重写。 其次,我仍然需要拥有REST WS,那么是否可以将EJB公开为REST WS以及如何? REST WS是在同一个EJB项目中还是在另一个项目中?
I have implemented a RESTful web service using jersey and deployed it on Tomcat, I have used DAO classes to manipulate database operations, entities to wrap database records. and did the processing in separate package. I want to make this system distributed using EJB. First of all would it be easy to do this change. or i need to rewrite things from scratch. Second, I still need to have the REST WS, so would it be possible to expose the EJB as a REST WS and how? would the REST WS be in the same EJB project or in a different one?
最满意答案
您绝对可以将其作为EJB和REST WS来实现。 将Tomcat安装升级到TomEE Plus ,然后将@Stateless或@Singleton添加到现有REST服务。
由于Java EE版本的Tomcat(TomEE)包含用于JAX-RS支持的CXF,因此您不再需要Jersey。
此示例没有详细记录,但显示了一个结合了EJB和JAX-RS的功能应用程序。
http://tomee.apache.org/examples-trunk/rest-on-ejb/README.html
You can definitely do it as an EJB and REST WS. Upgrade your Tomcat install to TomEE Plus, then just add @Stateless or @Singleton to the existing REST service.
You won't need Jersey in there anymore as the Java EE version of Tomcat (TomEE) includes CXF for JAX-RS support.
This example is not well documented, but shows a functional application that combines both EJB and JAX-RS.
http://tomee.apache.org/examples-trunk/rest-on-ejb/README.html
更多推荐
发布评论