Applications utilizing the IBM JAX-RS runtime can be deployed into any web container. The following steps walk through the deployment process.
Before you can package your JAX-RS application, you have to identify which classes will represent the root resources available in your RESTful service. Root resources are the ones that will be accessible at the root level of your application. In other words, they are the resources that will appear just below the context root. For our AddressBook sample, there is only one root resource, "/address".
Once you have identified your root resources, they need to be surfaced to the runtime via the javax.ws.rs.core.Application configuration mechanism. JAX-RS defines this class as a means for aggregating the JAX-RS related artifacts that exist in an application. Classes included in the Application configuration will be treated as root-level resources in the JAX-RS service. As defined by the specification, this is the only portable means of configuring a JAX-RS application.
To create the config class, create a new class in your environment that extends javax.ws.rs.core.Application. This subclass will provide a set of root resources and providers (if any exist) to the runtime. The code sample below demonstrates a sample Application class. This code is based on the AddressBook sample that was developed here.
|
JAX-RS applications can be deployed in a JavaEE 5 web container as a Web Archive Module(WAR). There are two ways to package applicatons for use in a web container environment. You can package the application using the provided ant script or package the application manually. Although we recommend using the automated build script, we understand that is not possible in all circumstances.
Instructions for using the provided build script can be found here
The steps below describe what is needed to package the WAR module manually.
|
Deploy the configured WAR into a web container. The root level JAX-RS resources should be available at URL patterns of the form:
|
Consider the following resource:
|
If this were deployed in a WAR whose context root was "/rest", the URL to the resource would be:
|