Debian Codegraph @

jersey-servlet/src/main/java/com/sun/jersey/spi/container/servlet/package-info.java

raw
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.
5 *
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common Development
8 * and Distribution License("CDDL") (collectively, the "License"). You
9 * may not use this file except in compliance with the License. You can
10 * obtain a copy of the License at
11 * http://glassfish.java.net/public/CDDL+GPL_1_1.html
12 * or packager/legal/LICENSE.txt. See the License for the specific
13 * language governing permissions and limitations under the License.
14 *
15 * When distributing the software, include this License Header Notice in each
16 * file and include the License file at packager/legal/LICENSE.txt.
17 *
18 * GPL Classpath Exception:
19 * Oracle designates this particular file as subject to the "Classpath"
20 * exception as provided by Oracle in the GPL Version 2 section of the License
21 * file that accompanied this code.
22 *
23 * Modifications:
24 * If applicable, add the following below the License Header, with the fields
25 * enclosed by brackets [] replaced by your own identifying information:
26 * "Portions Copyright [year] [name of copyright owner]"
27 *
28 * Contributor(s):
29 * If you wish your version of this file to be governed by only the CDDL or
30 * only the GPL Version 2, indicate your decision by adding "[Contributor]
31 * elects to include this software in this distribution under the [CDDL or GPL
32 * Version 2] license." If you don't indicate a single choice of license, a
33 * recipient has the option to distribute your version of this file under
34 * either the CDDL, the GPL Version 2 or to extend the choice of license to
35 * its licensees as provided above. However, if you add GPL Version 2 code
36 * and therefore, elected the GPL Version 2 license, then the option applies
37 * only if the new code is made subject to such option by the copyright
38 * holder.
39 */
40 /**
41 * Provides support for servlet-based and filter-based Web applications.
42 * <p>
43 * Web application support is enabled by referencing the servlet
44 * {@link com.sun.jersey.spi.container.servlet.ServletContainer} in the
45 * web.xml.
46 * <p>
47 * For example, the following will deploy Jersey and automatically
48 * register any root resource or provider classes present in the directory
49 * "/WEB-INF/classes" or jar files present in the directory "/WEB-INF/lib":
50 * <blockquote><pre>
51 * &lt;web-app&gt;
52 * &lt;servlet&gt;
53 * &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
54 * &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
55 * &lt;/servlet&gt;
56 * &lt;servlet-mapping&gt;
57 * &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
58 * &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
59 * &lt;/servlet-mapping&gt;
60 * &lt;/web-app&gt;
61 * </blockquote></pre>
62 * <p>
63 * A deployment approach, that is more portable with respect to maven and
64 * application servers, is to declare the package names where root resource and provider
65 * classes reside. For example, the following will deploy Jersey and
66 * automatically register any root resource or provider classes present
67 * in the package "managed", or any sub-packages.
68 * <blockquote><pre>
69 * &lt;web-app&gt;
70 * &lt;servlet&gt;
71 * &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
72 * &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
73 * &lt;init-param&gt;
74 * &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
75 * &lt;param-value&gt;managed&lt;/param-value&gt;
76 * &lt;/init-param>
77 * &lt;/servlet&gt;
78 * &lt;servlet-mapping&gt;
79 * &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
80 * &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
81 * &lt;/servlet-mapping&gt;
82 * &lt;/web-app&gt;
83 * </blockquote></pre>
84 * The deployment approach that is portable accross JAX-RS implementations is to
85 * register an implementation of {@link javax.ws.rs.core.Application}. For
86 * example given an implementation as follows:
87 * <blockquote><pre>
88 * package com.foo;
89 *
90 * import ...
91 *
92 * public class MyApplicaton extends Application {
93 * public Set&lt;Class&lt;?&gt;&gt; getClasses() {
94 * Set&lt;Class&lt;?&gt;&gt; s = new HashSet&lt;Class&lt;?&gt;&gt;();
95 * s.add(HelloWorldResource.class);
96 * return s;
97 * }
98 * }
99 * </blockquote></pre>
100 * then that implementation can be registered as follows:
101 * <blockquote><pre>
102 * &lt;web-app&gt;
103 * &lt;servlet&gt;
104 * &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
105 * &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
106 * &lt;init-param&gt;
107 * &lt;param-name&gt;javax.ws.rs.Application&lt;/param-name&gt;
108 * &lt;param-value&gt;com.foo.MyApplication&lt;/param-value&gt;
109 * &lt;/init-param>
110 * &lt;/servlet&gt;
111 * &lt;servlet-mapping&gt;
112 * &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
113 * &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
114 * &lt;/servlet-mapping&gt;
115 * &lt;/web-app&gt;
116 * </blockquote></pre>
117 * It is possible to combine package-based registration and
118 * {@link javax.ws.rs.core.Application}
119 * registered by extending {@link com.sun.jersey.api.core.PackagesResourceConfig}
120 * and registering the extended class, for example:
121 * <blockquote><pre>
122 * public class MyApplication extends PackagesResourceConfig {
123 * public MyApplication() {
124 * super("org.foo.rest;org.bar.rest");
125 * }
126 * }
127 * </blockquote></pre>
128 * The above examples apply to Servlet-based configurations but they equally
129 * applicable to Filter-based configurations. For example, the following
130 * presents the same package-based configuration as above but utilizing a filter:
131 * <blockquote><pre>
132 * &lt;web-app&gt;
133 * &lt;filter&gt;
134 * &lt;filter-name&gt;Jersey Web Application&lt;/filter-name&gt;
135 * &lt;filter-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/filter-class&gt;
136 * &lt;init-param&gt;
137 * &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
138 * &lt;param-value&gt;managed&lt;/param-value&gt;
139 * &lt;/init-param>
140 * &lt;/filter&gt;
141 * &lt;filter-mapping&gt;
142 * &lt;filter-name&gt;Jersey Web Application&lt;/filter-name&gt;
143 * &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
144 * &lt;/filter-mapping&gt;
145 * &lt;/web-app&gt;
146 * </blockquote></pre>
147 *
148 */
149 package com.sun.jersey.spi.container.servlet;