KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > appclient > jws > JWSAdHocServletInfo


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.appclient.jws;
25
26 import com.sun.enterprise.web.AdHocServletInfo;
27 import java.util.HashMap JavaDoc;
28
29 import javax.servlet.http.HttpServletRequest JavaDoc;
30 import javax.servlet.http.HttpServletResponse JavaDoc;
31
32 /**
33  *Info describing the ad hoc servlet that is dynamically registered with the web
34  *container to receive Java Web Start's requests for the JNLP document.
35  *<p>
36  *The web container uses this information in setting up the dynamic mapping
37  *from URLs to our code.
38  *
39  * @author tjquinn
40  */

41 public class JWSAdHocServletInfo implements AdHocServletInfo {
42     
43     /** holds init parameter names and values that will be available to the servlet */
44     private HashMap JavaDoc<String JavaDoc,String JavaDoc> initParams;
45     
46     /** holds the name that distinguishes ad hoc servlets within an app */
47     private String JavaDoc servletName;
48     
49     /** Creates a new instance of JWSAdHocServletInfo */
50     public JWSAdHocServletInfo(String JavaDoc virtualContextRoot, String JavaDoc category) {
51         setInitParams(virtualContextRoot, category);
52         servletName = virtualContextRoot;
53     }
54
55     /**
56      *Reports which class implements the ad hoc servlet to be run.
57      *@return Class for the ad hoc servlet class
58      */

59     public Class JavaDoc getServletClass() {
60         return JWSAdHocServlet.class;
61     }
62
63     /**
64      *Returns a map from servlet init param name to value.
65      *@return Map<String,String> of init param names to values
66      */

67     public java.util.Map JavaDoc<String JavaDoc, String JavaDoc> getServletInitParams() {
68         return initParams;
69     }
70
71     /**
72      *Reports the servlet's name.
73      *@return the name of the servlet for display purposes
74      */

75     public String JavaDoc getServletName() {
76         return servletName;
77     }
78     
79     /**
80      *Sets up the map of init param names to values that will be retrieved
81      *by the web container.
82      *@param the context root by which the ad hoc servlet will be addressed
83      *@param the category (basically either application or appclient)
84      */

85     private void setInitParams(String JavaDoc virtualContextRoot, String JavaDoc category) {
86         initParams = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
87         initParams.put(JWSAdHocServlet.CONTEXT_ROOT_PARAMETER_NAME, virtualContextRoot);
88         initParams.put(JWSAdHocServlet.CATEGORY_PARAMETER_NAME, category);
89     }
90 }
91
Popular Tags