This project has retired. For details please refer to its
Attic page.
ServletContextAdapter xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.tiles.web.util;
22
23 import java.io.InputStream;
24 import java.net.MalformedURLException;
25 import java.net.URL;
26 import java.util.Enumeration;
27 import java.util.Hashtable;
28 import java.util.Set;
29
30 import javax.servlet.RequestDispatcher;
31 import javax.servlet.Servlet;
32 import javax.servlet.ServletConfig;
33 import javax.servlet.ServletContext;
34 import javax.servlet.ServletException;
35
36
37
38
39
40
41
42 @SuppressWarnings("deprecation")
43 public class ServletContextAdapter implements ServletContext {
44
45
46
47
48 private ServletContext rootContext;
49
50
51
52
53
54 private Hashtable<String, String> initParameters;
55
56
57
58
59
60
61
62 @SuppressWarnings("unchecked")
63 public ServletContextAdapter(ServletConfig config) {
64 this.rootContext = config.getServletContext();
65 initParameters = new Hashtable<String, String>();
66 Enumeration<String> enumeration = rootContext
67 .getInitParameterNames();
68 while (enumeration.hasMoreElements()) {
69 String paramName = enumeration.nextElement();
70 initParameters.put(paramName, rootContext
71 .getInitParameter(paramName));
72 }
73 enumeration = config.getInitParameterNames();
74 while (enumeration.hasMoreElements()) {
75 String paramName = enumeration.nextElement();
76 initParameters.put(paramName, config.getInitParameter(paramName));
77 }
78 }
79
80
81 public ServletContext getContext(String string) {
82 return rootContext.getContext(string);
83 }
84
85
86 public int getMajorVersion() {
87 return rootContext.getMajorVersion();
88 }
89
90
91 public int getMinorVersion() {
92 return rootContext.getMinorVersion();
93 }
94
95
96 public String getMimeType(String string) {
97 return rootContext.getMimeType(string);
98 }
99
100
101 @SuppressWarnings({ "rawtypes" })
102 public Set getResourcePaths(String string) {
103 return rootContext.getResourcePaths(string);
104 }
105
106
107 public URL getResource(String string) throws MalformedURLException {
108 return rootContext.getResource(string);
109 }
110
111
112 public InputStream getResourceAsStream(String string) {
113 return rootContext.getResourceAsStream(string);
114 }
115
116
117 public RequestDispatcher getRequestDispatcher(String string) {
118 return rootContext.getRequestDispatcher(string);
119 }
120
121
122 public RequestDispatcher getNamedDispatcher(String string) {
123 return rootContext.getNamedDispatcher(string);
124 }
125
126
127 public Servlet getServlet(String string) throws ServletException {
128 return rootContext.getServlet(string);
129 }
130
131
132 @SuppressWarnings("rawtypes")
133 public Enumeration getServlets() {
134 return rootContext.getServlets();
135 }
136
137
138 @SuppressWarnings("rawtypes")
139 public Enumeration getServletNames() {
140 return rootContext.getServletNames();
141 }
142
143
144 public void log(String string) {
145 rootContext.log(string);
146 }
147
148
149 public void log(Exception exception, String string) {
150 rootContext.log(exception, string);
151 }
152
153
154 public void log(String string, Throwable throwable) {
155 rootContext.log(string, throwable);
156 }
157
158
159 public String getRealPath(String string) {
160 return rootContext.getRealPath(string);
161 }
162
163
164 public String getServerInfo() {
165 return rootContext.getServerInfo();
166 }
167
168
169 public String getInitParameter(String string) {
170 return initParameters.get(string);
171 }
172
173
174 @SuppressWarnings("rawtypes")
175 public Enumeration getInitParameterNames() {
176 return initParameters.keys();
177 }
178
179
180 public Object getAttribute(String string) {
181 return rootContext.getAttribute(string);
182 }
183
184
185 @SuppressWarnings("rawtypes")
186 public Enumeration getAttributeNames() {
187 return rootContext.getAttributeNames();
188 }
189
190
191 public void setAttribute(String string, Object object) {
192 rootContext.setAttribute(string, object);
193 }
194
195
196 public void removeAttribute(String string) {
197 rootContext.removeAttribute(string);
198 }
199
200
201 public String getServletContextName() {
202 return rootContext.getServletContextName();
203 }
204
205
206 public String getContextPath() {
207 return rootContext.getContextPath();
208 }
209 }