|
1
|
|
/* Generated by AspectJ version 1.0.5 */
|
|
2
|
|
package org.apache.cactus.server;
|
|
3
|
|
import java.util.Enumeration;
|
|
4
|
|
import java.util.Hashtable;
|
|
5
|
|
import java.util.Vector;
|
|
6
|
|
import javax.servlet.ServletConfig;
|
|
7
|
|
import javax.servlet.ServletContext;
|
|
8
|
|
|
|
9
|
|
/**
|
|
10
|
|
* Wrapper around <code>ServletConfig</code> which overrides the
|
|
11
|
|
* <code>getServletContext()</code> method to return our own wrapper around
|
|
12
|
|
* <code>ServletContext</code>.
|
|
13
|
|
*
|
|
14
|
|
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
|
15
|
|
*
|
|
16
|
|
* @version $Id: ServletConfigWrapper.java,v 1.2 2002/04/14 10:15:03 vmassol Exp $
|
|
17
|
|
* @see ServletContext
|
|
18
|
|
*/
|
|
19
|
|
public class ServletConfigWrapper implements ServletConfig {
|
|
20
|
|
/**
|
|
21
|
|
* The original servlet config object
|
|
22
|
|
*/
|
|
23
|
|
private ServletConfig originalConfig;
|
|
24
|
|
/**
|
|
25
|
|
* List of parameters set using the <code>setInitParameter()</code> method.
|
|
26
|
|
*/
|
|
27
|
|
private Hashtable initParameters;
|
|
28
|
|
/**
|
|
29
|
|
* Simulated name of the servlet
|
|
30
|
|
*/
|
|
31
|
|
private String servletName;
|
|
32
|
|
/**
|
|
33
|
|
* @param theOriginalConfig the original servlet config object
|
|
34
|
|
*/
|
|
35
|
427
|
public ServletConfigWrapper(ServletConfig theOriginalConfig) {
|
|
36
|
427
|
super();
|
|
37
|
427
|
this.originalConfig = theOriginalConfig;
|
|
38
|
427
|
this.initParameters = new Hashtable();
|
|
39
|
|
}
|
|
40
|
|
/**
|
|
41
|
|
* Sets a parameter as if it were set in the <code>web.xml</code> file.
|
|
42
|
|
*
|
|
43
|
|
* @param theName the parameter's name
|
|
44
|
|
* @param theValue the parameter's value
|
|
45
|
|
*/
|
|
46
|
7
|
public void setInitParameter(String theName, String theValue) {
|
|
47
|
7
|
this.initParameters.put(theName, theValue);
|
|
48
|
|
}
|
|
49
|
|
|
|
50
|
|
/**
|
|
51
|
|
* Sets the servlet name. That will be the value returned by the
|
|
52
|
|
* <code>getServletName()</code> method.
|
|
53
|
|
*
|
|
54
|
|
* @param theServletName the servlet's name
|
|
55
|
|
*/
|
|
56
|
7
|
public void setServletName(String theServletName) {
|
|
57
|
7
|
this.servletName = theServletName;
|
|
58
|
|
}
|
|
59
|
|
|
|
60
|
|
/**
|
|
61
|
|
* @return our own wrapped servlet context object
|
|
62
|
|
*/
|
|
63
|
42
|
public ServletContext getServletContext() {
|
|
64
|
42
|
return new ServletContextWrapper(this.originalConfig.getServletContext());
|
|
65
|
|
}
|
|
66
|
|
|
|
67
|
|
/**
|
|
68
|
|
* @param theName the name of the parameter's value to return
|
|
69
|
|
* @return the value of the parameter, looking for it first in the list of
|
|
70
|
|
* parameters set using the <code>setInitParameter()</code> method
|
|
71
|
|
* and then in those set in <code>web.xml</code>.
|
|
72
|
|
*/
|
|
73
|
35
|
public String getInitParameter(String theName) {
|
|
74
|
35
|
String value = (String)this.initParameters.get(theName);
|
|
75
|
35
|
if (value == null) {
|
|
76
|
28
|
value = this.originalConfig.getInitParameter(theName);
|
|
77
|
|
}
|
|
78
|
35
|
return value;
|
|
79
|
|
}
|
|
80
|
|
|
|
81
|
|
/**
|
|
82
|
|
* @return the union of the parameters defined in the Redirector
|
|
83
|
|
* <code>web.xml</code> file and the one set using the
|
|
84
|
|
* <code>setInitParameter()</code> method.
|
|
85
|
|
*/
|
|
86
|
7
|
public Enumeration getInitParameterNames() {
|
|
87
|
7
|
Vector names = new Vector();
|
|
88
|
7
|
Enumeration enum = this.initParameters.keys();
|
|
89
|
7
|
while (enum.hasMoreElements()){
|
|
90
|
7
|
String value = (String)enum.nextElement();
|
|
91
|
7
|
names.add(value);
|
|
92
|
|
}
|
|
93
|
7
|
enum = this.originalConfig.getInitParameterNames();
|
|
94
|
7
|
while (enum.hasMoreElements()){
|
|
95
|
7
|
String value = (String)enum.nextElement();
|
|
96
|
7
|
names.add(value);
|
|
97
|
|
}
|
|
98
|
7
|
return names.elements();
|
|
99
|
|
}
|
|
100
|
|
|
|
101
|
|
/**
|
|
102
|
|
* @return the simulated servlet's name if defined or the redirector
|
|
103
|
|
* servlet's name
|
|
104
|
|
*/
|
|
105
|
11
|
public String getServletName() {
|
|
106
|
11
|
if (this.servletName != null) {
|
|
107
|
7
|
return this.servletName;
|
|
108
|
|
}
|
|
109
|
4
|
return this.originalConfig.getServletName();
|
|
110
|
|
}
|
|
111
|
|
|
|
112
|
|
}
|