Implement RESTful views of EJB applications using JAX-RS
If we have enterprise JavaBeans (EJB) applications, we can expose a RESTful interface to the enterprise bean using Java API for RESTful Web Services (JAX-RS). By implementing JAX-RS annotated enterprise beans, we keep the EJB functionality including transaction support, injection of Java EE components and resources, and other EJB session bean capabilities.
Before EJB 3.1, enterprise beans that required an EJB local client view also needed a separate Java interface, usually located in a separate file, that declared the local view methods. The enterprise bean specified that it implemented the EJB local view interface using deployment descriptors or EJB annotations.
Using the EJB 3.1 specification, we have the option of exposing a local view of an enterprise bean without an explicit EJB local interface. Instead, the enterprise bean has a no-interface client view based on the public methods of the bean class. No-interface view enterprise beans can be more simple to develop than a local view enterprise bean for the following reasons:
- No-interface view enterprise beans do not require a separate Java interface declaration
- No-interface view enterprise beans do not require specifying additional metadata in the deployment descriptor or when using annotations
See the EJB 3.1 specification for more details on the no-interface views of an enterprise bean.
JAX-RS supports the use of enterprise beans that declare a local business interface and no-interface view enterprise beans.
- Configure the development environment.
- Define resources in JAX-RS web applications.
- Configure the JAX-RS application.
- Implement RESTful views of enterprise beans.
- Assemble JAX-RS web applications.
- Deploy JAX-RS web applications.
Results
You have enabled an enterprise bean so that JAX-RS resources are exposed for consumption.
Subtopics
- Configure the development environment.
- Define resources in JAX-RS web applications.
- Configure the JAX-RS application.
- Implement RESTful views of enterprise beans.
- Assemble JAX-RS web applications.
- Deploy JAX-RS web applications.
Related tasks
Implement RESTful views of a no-interface EJB Implement RESTful views of an EJB with local interfaces Develop a session bean to have a No-Interface Local view Develop singleton session beans
Web services specifications and APIs EJB application specifications and APIs