Java Reference
In-Depth Information
set . add ( json );
set . add ( service );
return set ;
The @ApplicationPath annotation here will set up a base path to whatever the WAR's con-
text root is, with root appended.
You can fully leverage the servlet class scanning abilities if you have both getClasses()
and getSingletons() return an empty set. For example:
package com . restfully . shop . services ;
import ;
import ;
@ApplicationPath ( "/root" )
public class
class ShoppingApplication
ShoppingApplication extends
extends Application {
// complete
When scanning, the application server will look within WEB-INF/classes and any JAR file
within the WEB-INF/lib directory. It will add any class annotated with @Path or @Provider
to the list of things that need to be deployed and registered with the JAX-RS runtime. You
can also deploy as many Application classes as you want in one WAR. The scanner will
also ignore any Application classes not annotated with @ApplicationPath .
You can also override the @ApplicationPath annotation via a simple servlet mapping with-
in web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns= ""
xmlns:xsi= ""
xsi:schemaLocation= ""
version= "3.0" >
<servlet-name> </servlet-name>
<url-pattern> /* </url-pattern>
Search WWH ::

Custom Search