Java Reference
In-Depth Information
The
servlet-name
is the fully qualified class name of your
Application
class. With this
configuration, you can also omit the
@ApplicationPath
annotation entirely.
Deployment Within a JAX-RS-Unaware Container
If you are running in 2.x or older Servlet containers, you'll have to manually configure your
web.xml
file to load your JAX-RS implementation's proprietary servlet class. For example:
<?
xml version
=
"1.0"
?>
<
web
-
app
>
<
servlet
>
<
servlet
-
name
>
JAXRS
</
servlet
-
name
>
<
servlet
-
class
>
org
.
jboss
.
resteasy
.
plugins
.
server
.
servlet
.
HttpServletDispatcher
</
servlet
-
class
>
<
init
-
param
>
<
param
-
name
>
javax
.
ws
.
rs
.
Application
</
param
-
name
>
<
param
-
value
>
com
.
restfully
.
shop
.
services
.
ShoppingApplication
</
param
-
value
>
</
init
-
param
>
</
servlet
>
<
servlet
-
mapping
>
<
servlet
-
name
>
JAXRS
</
servlet
-
name
>
<
url
-
pattern
>/*</
url
-
pattern
>
</
servlet
-
mapping
>
</
web
-
app
>
Here, we've registered and initialized the RESTEasy JAX-RS implementation with the
ShoppingApplication
class we created earlier in this chapter. The
<servlet-mapping>
element specifies the base URI path for the JAX-RS runtime. The
/* <url-pattern>
speci-
fies that all incoming requests should be routed through our JAX-RS implementation.
Configuration
All the examples in this topic so far have been simple and pretty self-contained. Your REST-
ful web services will probably need to sit in front of a database and interact with other local
and remote services. Your services will also need configuration settings that are described
outside of code. I don't want to get into too much detail, but the servlet and Java EE specific-
ations provide annotations and XML configurations that allow you to get access to various