RESTeasy is deployed as a WAR archive and thus depends on a Servlet container.
When you download RESTeasy and unzip it you will see that it contains an exploded WAR.
Make a deep copy of the WAR archive for your particular application. Place your JAX-RS annotated class resources and providers within
one or more jars within /WEB-INF/lib or your raw class files within /WEB-INF/classes. RESTeasy is configured by default
to scan jars and classes within these directories for JAX-RS annotated classes and deploy and register them within the system.
RESTeasy is implemented as a ServletContextListener and a Servlet and deployed within a WAR file. If you open up the WEB-INF/web.xml in your RESTeasy download you will see this:
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!-- set this if you map the Resteasy servlet to something other than /*
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/resteasy</param-value>
</context-param>
-->
<!-- if you are using Spring, Seam or EJB as your component model, remove the ResourceMethodSecurityInterceptor -->
<context-param>
<param-name>resteasy.resource.method-interceptors</param-name>
<param-value>
org.jboss.resteasy.core.ResourceMethodSecurityInterceptor
</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
The ResteasyBootstrap listener is responsible for initializing some basic components of RESTeasy as well as scanning for annotation classes you have in your WAR file. It receives configuration options from <context-param> elements. Here's a list of what options are available
This config variable must be set if your servlet-mapping for the Resteasy servlet has a url-pattern other than /. For example, if the url-pattern is
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/restful-services/*</url-pattern>
</servlet-mapping>
Then the value of resteasy-servlet.mapping.prefix must be:
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/restful-services</param-value>
</context-param>
Option Name | Default Value | Description |
|---|---|---|
resteasy.servlet.mapping.prefix | no default | If the url-pattern for the Resteasy servlet-mapping is not / |
resteasy.scan.providers | false | Scan for @Provider classes and register them |
resteasy.scan.resources | false | Scan for JAX-RS resource classes |
resteasy.scan | false | Scan for both @Provider and JAX-RS resource classes (@Path, @GET, @POST etc..) and register them |
resteasy.providers | no default | A comma delimited list of fully qualified @Provider class names you want to register |
resteasy.use.builtin.providers | true | Whether or not to register default, built-in @Provider classes. (Only available in 1.0-beta-5 and later) |
resteasy.resources | no default | A comma delimited list of fully qualified JAX-RS resource class names you want to register |
resteasy.jndi.resources | no default | A comma delimited list of JNDI names which reference objects you want to register as JAX-RS resources |
javax.ws.rs.core.Application | no default | Fully qualified name of Application class to bootstrap in a spec portable way |
The ResteasyBootstrap listener configures an instance of an ResteasyProviderFactory and Registry. You can obtain instances of a ResteasyProviderFactory and Registry from the ServletContext attributes org.jboss.resteasy.spi.ResteasyProviderFactory and org.jboss.resteasy.spi.Registry.
There are no comments on this article