1
22
23 package com.liferay.portal.apache.bridges.struts;
24
25 import java.io.InputStream;
26
27 import java.net.MalformedURLException;
28 import java.net.URL;
29
30 import java.util.ArrayList;
31 import java.util.Collections;
32 import java.util.Enumeration;
33 import java.util.Set;
34
35 import javax.servlet.RequestDispatcher;
36 import javax.servlet.Servlet;
37 import javax.servlet.ServletContext;
38 import javax.servlet.ServletException;
39
40
46 public class LiferayServletContext implements ServletContext {
47
48 public LiferayServletContext(ServletContext ctx) {
49 _ctx = ctx;
50 }
51
52 public Object getAttribute(String name) {
53 return _ctx.getAttribute(name);
54 }
55
56 public Enumeration getAttributeNames() {
57 return _ctx.getAttributeNames();
58 }
59
60 public ServletContext getContext(String uriPath) {
61 ServletContext refContext = _ctx.getContext(uriPath);
62
63 if (refContext == _ctx) {
64 return this;
65 }
66 else {
67 return refContext;
68 }
69 }
70
71 public String getInitParameter(String name) {
72 return _ctx.getInitParameter(name);
73 }
74
75 public Enumeration getInitParameterNames() {
76 return _ctx.getInitParameterNames();
77 }
78
79 public int getMajorVersion() {
80 return _ctx.getMajorVersion();
81 }
82
83 public String getMimeType(String file) {
84 return _ctx.getMimeType(file);
85 }
86
87 public int getMinorVersion() {
88 return _ctx.getMinorVersion();
89 }
90
91 public RequestDispatcher getNamedDispatcher(String name) {
92 RequestDispatcher dispatcher = _ctx.getNamedDispatcher(name);
93
94 if (dispatcher != null) {
95 dispatcher = new LiferayRequestDispatcher(dispatcher, name);
96 }
97
98 return dispatcher;
99 }
100
101 public String getRealPath(String arg0) {
102 return _ctx.getRealPath(arg0);
103 }
104
105 public RequestDispatcher getRequestDispatcher(String path) {
106 RequestDispatcher dispatcher = _ctx.getRequestDispatcher(path);
107
108 if (dispatcher != null) {
109 dispatcher = new LiferayRequestDispatcher(dispatcher, path);
110 }
111
112 return dispatcher;
113 }
114
115 public URL getResource(String path) throws MalformedURLException {
116 return _ctx.getResource(path);
117 }
118
119 public InputStream getResourceAsStream(String path) {
120 return _ctx.getResourceAsStream(path);
121 }
122
123 public Set getResourcePaths(String path) {
124 return _ctx.getResourcePaths(path);
125 }
126
127 public String getServerInfo() {
128 return _ctx.getServerInfo();
129 }
130
131 public Servlet getServlet(String name) throws ServletException {
132 return null;
133 }
134
135 public String getServletContextName() {
136 return _ctx.getServletContextName();
137 }
138
139 public Enumeration getServletNames() {
140 return Collections.enumeration(new ArrayList());
141 }
142
143 public Enumeration getServlets() {
144 return Collections.enumeration(new ArrayList());
145 }
146
147 public void log(Exception exception, String message) {
148 _ctx.log(message, exception);
149 }
150
151 public void log(String message) {
152 _ctx.log(message);
153 }
154
155 public void log(String message, Throwable t) {
156 _ctx.log(message, t);
157 }
158
159 public void removeAttribute(String name) {
160 _ctx.removeAttribute(name);
161 }
162
163 public void setAttribute(String name, Object value) {
164 _ctx.setAttribute(name, value);
165 }
166
167 public String toString() {
168 return _ctx.toString();
169 }
170
171 private ServletContext _ctx;
172
173 }