KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > PwcWebModule


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.web;
25
26 import java.util.Enumeration JavaDoc;
27 import org.apache.catalina.Wrapper;
28 import org.apache.catalina.core.StandardContext;
29 import org.apache.catalina.core.StandardWrapper;
30 import com.sun.enterprise.web.session.SessionCookieConfig;
31
32 /**
33  * Class representing a web module (servlet context).
34  */

35 public abstract class PwcWebModule extends StandardContext {
36
37     // ----------------------------------------------------- Class Variables
38

39
40     // ----------------------------------------------------- Instance Variables
41

42     // The id of this web module as specified in the configuration.
43
private String JavaDoc _id = null;
44
45     // The session cookie configuration for this web module.
46
private SessionCookieConfig _cookieConfig = null;
47
48     private boolean _useResponseCTForHeaders = false;
49
50    /**
51     * Determines whether or not we should encode the cookies.
52     * By default cookies are not URL encoded.
53     */

54     private boolean _encodeCookies = false;
55
56     private int pollInterval = -1;
57
58     private int reapInterval = -1;
59
60     // START OF IASRI 4731830
61
/**
62      * Maximum number of SingleThreadModel instances for each wrapper
63      * in this context.
64      */

65     private int stmPoolSize = 5;
66     // END OF IASRI 4731830
67

68     // START S1AS8PE 4920021
69
/**
70      * Rave required attribute
71      * True if the web-module implements web services endpoints.
72      */

73     private boolean hasWebServices = false;
74
75     /**
76      * Rave required attribute
77      * An array of URL addresses defined in this web-module to invoke
78      * web services endpoints implementations.
79      */

80     private String JavaDoc[] endpointAddresses = null;
81     // END S1AS8PE 4920021
82

83     // The web module context root
84
private String JavaDoc contextRoot;
85
86     // Indicates whether this WebModule has a web.xml deployment descriptor
87
private boolean hasWebXml;
88
89     private String JavaDoc moduleName;
90
91     private String JavaDoc[] cacheControls;
92
93     protected String JavaDoc formHintField = null;
94
95     protected String JavaDoc defaultCharset;
96
97         
98     /**
99      * Gets this web module's identifier.
100      *
101      * @return Web module identifier
102      */

103     public String JavaDoc getID() {
104         return _id;
105     }
106
107
108     /**
109      * Sets this web module's identifier.
110      *
111      * @param id Web module identifier
112      */

113     public void setID(String JavaDoc id) {
114         _id = id;
115     }
116
117
118     /**
119      * Return the session cookie configuration for this web module.
120      */

121     public SessionCookieConfig getSessionCookieConfig() {
122         return _cookieConfig;
123     }
124
125
126     /**
127      * Set the session cookie configuration for this web module.
128      *
129      * @param cookieConfig The new session cookie configuration
130      */

131     public void setSessionCookieConfig(SessionCookieConfig cookieConfig) {
132         _cookieConfig = cookieConfig;
133     }
134
135
136     /**
137      * return parameter-encoding form-hint-field attribute value
138      */

139     public String JavaDoc getFormHintField() {
140         return formHintField;
141     }
142
143
144     /**
145      * Gets the value of the default-charset attribute of the
146      * parameter-encoding element
147      *
148      * @return Value of the default-charset attribute of the
149      * parameter-encoding element, or null if not present
150      */

151     public String JavaDoc getDefaultCharset() {
152         return defaultCharset;
153     }
154
155
156     /**
157      * sets _useResponseCTForHeaders property value. When
158      * _useResponseCTForHeaders is set to true, it means that
159      * we send the response header in the same encoding of the
160      * response charset instead of UTF-8, (see the method sendHeaders
161      * in com.sun.enterprise.web.connector.nsapi.nsapiNSAPIResponse)
162      */

163     public void setResponseCTForHeaders() {
164         _useResponseCTForHeaders = true;
165     }
166
167
168     /**
169      * Determines whether cookies should be encoded or not.
170      * If the property encodeCookies is set to false in sun-web.xml,
171      * cookies will not be URL encoded. The default behaviuor is that
172      * we always encode the cookies unless the property encodeCookies
173      * is set to false in sun-web.xml.
174      */

175     public void setEncodeCookies(boolean flag) {
176         _encodeCookies = flag;
177     }
178
179
180     /**
181      * return _useResponseCTForHeaders property value
182      */

183     public boolean getResponseCTForHeaders() {
184         return _useResponseCTForHeaders;
185     }
186
187
188     /**
189      * return _encodeCookies property value
190      */

191     public boolean getEncodeCookies() {
192         return _encodeCookies;
193     }
194
195
196     /**
197      * Return maximum number of instances that will be allocated when a single
198      * thread model servlet is used in this web module.
199      */

200     public int getSTMPoolSize() {
201         return (this.stmPoolSize);
202     }
203
204      
205     /**
206      * Set the maximum number of instances that will be allocated when a single
207      * thread model servlet is used in this web module.
208      *
209      * @param newPoolSize New value of SingleThreadModel servlet pool size
210      */

211     public void setSTMPoolSize(int newPoolSize) {
212      
213         int oldPoolSize = this.stmPoolSize;
214         this.stmPoolSize = newPoolSize;
215         support.firePropertyChange("stmPoolSize", new Integer JavaDoc(oldPoolSize),
216                                    new Integer JavaDoc(this.stmPoolSize));
217     }
218
219          
220     /**
221      * Factory method to create and return a new Wrapper instance, of
222      * the Java implementation class appropriate for this Context
223      * implementation. The constructor of the instantiated Wrapper
224      * will have been called, but no properties will have been set.
225      */

226     public Wrapper createWrapper() {
227         Wrapper wrapper = super.createWrapper();
228         ((StandardWrapper) wrapper).setMaxInstances(stmPoolSize);
229         return wrapper;
230     }
231
232
233     // START S1AS8PE 4920021
234
/**
235      * Return the hasWebServices flag for this web module.
236      */

237     public boolean getHasWebServices() {
238         return hasWebServices;
239     }
240
241
242     /**
243      * Set the hasWebServices boolean flag for this web module.
244      *
245      * @param hasWebServices boolean flag hasWebServices for this web module
246      */

247     public void setHasWebServices(boolean hasWebServices) {
248         this.hasWebServices = hasWebServices;
249     }
250
251
252    /**
253     * Gets the URL addresses corresponding to the web services endpoints of
254     * this web module.
255     *
256     * @return Array of URL addresses corresponding to the web services
257     * endpoints of this web module
258     */

259     public String JavaDoc[] getEndpointAddresses() {
260         return endpointAddresses;
261     }
262
263
264     /**
265      * Sets the URL addresses corresponding to the web services endpoints of
266      * this web module.
267      *
268      * @param endpointAddresses Array of URL addresses corresponding to the
269      * web services endpoints of this web module
270      */

271     public void setEndpointAddresses(String JavaDoc[] endpointAddresses) {
272         this.endpointAddresses = (String JavaDoc[])endpointAddresses.clone();
273     }
274     // END S1AS8PE 4920021
275

276
277     /**
278      * Gets this web module's context root.
279      *
280      * @return Web module context root
281      */

282     public String JavaDoc getContextRoot(){
283         return contextRoot;
284     }
285
286
287     /**
288      * Sets this web module's context root.
289      *
290      * @param contextRoot Web module context root
291      */

292     public void setContextRoot(String JavaDoc contextRoot){
293         this.contextRoot = contextRoot;
294     }
295
296     
297     /*
298      * @param hasWebXml true if this WebModule has a web.xml deployment
299      * descriptor, false otherwise
300      */

301     void setHasWebXml(boolean hasWebXml) {
302         this.hasWebXml = hasWebXml;
303     }
304
305
306     /*
307      * @return true if this WebModule has a web.xml deployment descriptor,
308      * false otherwise
309      */

310     boolean hasWebXml() {
311         return hasWebXml;
312     }
313
314
315     /**
316      * Sets this web module's name.
317      *
318      * @param moduleName Web module name
319      */

320     public void setModuleName(String JavaDoc moduleName) {
321         this.moduleName = moduleName;
322     }
323
324
325     /**
326      * Gets this web module's name.
327      *
328      * @return Web module name
329      */

330     public String JavaDoc getModuleName() {
331         return this.moduleName;
332     }
333
334
335     /**
336      * Sets the Cache-Control configuration for this web module.
337      *
338      * @param cacheControls Cache-Control configuration settings for this
339      * web module
340      */

341     public void setCacheControls(String JavaDoc[] cacheControls) {
342         this.cacheControls = cacheControls;
343     }
344
345
346     /**
347      * Gets the Cache-Control settings of this web module.
348      *
349      * @return Cache-Control settings of this web module, or null if
350      * no such settings exist for this web module.
351      */

352     public String JavaDoc[] getCacheControls() {
353         return cacheControls;
354     }
355
356
357     /**
358      * Returns true if this web module specifies a locale-charset-map in its
359      * sun-web.xml, false otherwise.
360      *
361      * @return true if this web module specifies a locale-charset-map in its
362      * sun-web.xml, false otherwise
363      */

364     public abstract boolean hasLocaleToCharsetMapping();
365
366
367     /**
368      * Matches the given request locales against the charsets specified in
369      * the locale-charset-map of this web module's sun-web.xml, and returns
370      * the first matching charset.
371      *
372      * @param locales Request locales
373      *
374      * @return First matching charset, or null if this web module does not
375      * specify any locale-charset-map in its sun-web.xml, or no match was
376      * found
377      */

378     public abstract String JavaDoc mapLocalesToCharset(Enumeration JavaDoc locales);
379
380 }
381
Popular Tags