001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.apache.bridges.struts;
022:
023: import java.io.InputStream;
024:
025: import java.net.MalformedURLException;
026: import java.net.URL;
027:
028: import java.util.ArrayList;
029: import java.util.Collections;
030: import java.util.Enumeration;
031: import java.util.Set;
032:
033: import javax.servlet.RequestDispatcher;
034: import javax.servlet.Servlet;
035: import javax.servlet.ServletContext;
036: import javax.servlet.ServletException;
037:
038: /**
039: * <a href="LiferayServletContext.java.html"><b><i>View Source</i></b></a>
040: *
041: * @author Michael Young
042: *
043: */
044: public class LiferayServletContext implements ServletContext {
045:
046: public LiferayServletContext(ServletContext ctx) {
047: _ctx = ctx;
048: }
049:
050: public Object getAttribute(String name) {
051: return _ctx.getAttribute(name);
052: }
053:
054: public Enumeration getAttributeNames() {
055: return _ctx.getAttributeNames();
056: }
057:
058: public ServletContext getContext(String uriPath) {
059: ServletContext refContext = _ctx.getContext(uriPath);
060:
061: if (refContext == _ctx) {
062: return this ;
063: } else {
064: return refContext;
065: }
066: }
067:
068: public String getInitParameter(String name) {
069: return _ctx.getInitParameter(name);
070: }
071:
072: public Enumeration getInitParameterNames() {
073: return _ctx.getInitParameterNames();
074: }
075:
076: public int getMajorVersion() {
077: return _ctx.getMajorVersion();
078: }
079:
080: public String getMimeType(String file) {
081: return _ctx.getMimeType(file);
082: }
083:
084: public int getMinorVersion() {
085: return _ctx.getMinorVersion();
086: }
087:
088: public RequestDispatcher getNamedDispatcher(String name) {
089: RequestDispatcher dispatcher = _ctx.getNamedDispatcher(name);
090:
091: if (dispatcher != null) {
092: dispatcher = new LiferayRequestDispatcher(dispatcher, name);
093: }
094:
095: return dispatcher;
096: }
097:
098: public String getRealPath(String arg0) {
099: return _ctx.getRealPath(arg0);
100: }
101:
102: public RequestDispatcher getRequestDispatcher(String path) {
103: RequestDispatcher dispatcher = _ctx.getRequestDispatcher(path);
104:
105: if (dispatcher != null) {
106: dispatcher = new LiferayRequestDispatcher(dispatcher, path);
107: }
108:
109: return dispatcher;
110: }
111:
112: public URL getResource(String path) throws MalformedURLException {
113: return _ctx.getResource(path);
114: }
115:
116: public InputStream getResourceAsStream(String path) {
117: return _ctx.getResourceAsStream(path);
118: }
119:
120: public Set getResourcePaths(String path) {
121: return _ctx.getResourcePaths(path);
122: }
123:
124: public String getServerInfo() {
125: return _ctx.getServerInfo();
126: }
127:
128: public Servlet getServlet(String name) throws ServletException {
129: return null;
130: }
131:
132: public String getServletContextName() {
133: return _ctx.getServletContextName();
134: }
135:
136: public Enumeration getServletNames() {
137: return Collections.enumeration(new ArrayList());
138: }
139:
140: public Enumeration getServlets() {
141: return Collections.enumeration(new ArrayList());
142: }
143:
144: public void log(Exception exception, String message) {
145: _ctx.log(message, exception);
146: }
147:
148: public void log(String message) {
149: _ctx.log(message);
150: }
151:
152: public void log(String message, Throwable t) {
153: _ctx.log(message, t);
154: }
155:
156: public void removeAttribute(String name) {
157: _ctx.removeAttribute(name);
158: }
159:
160: public void setAttribute(String name, Object value) {
161: _ctx.setAttribute(name, value);
162: }
163:
164: public String toString() {
165: return _ctx.toString();
166: }
167:
168: private ServletContext _ctx;
169:
170: }
|