001: /*
002: * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContextFacade.java,v 1.3 2001/07/22 20:25:08 pier Exp $
003: * $Revision: 1.3 $
004: * $Date: 2001/07/22 20:25:08 $
005: *
006: * ====================================================================
007: *
008: * The Apache Software License, Version 1.1
009: *
010: * Copyright (c) 1999 The Apache Software Foundation. All rights
011: * reserved.
012: *
013: * Redistribution and use in source and binary forms, with or without
014: * modification, are permitted provided that the following conditions
015: * are met:
016: *
017: * 1. Redistributions of source code must retain the above copyright
018: * notice, this list of conditions and the following disclaimer.
019: *
020: * 2. Redistributions in binary form must reproduce the above copyright
021: * notice, this list of conditions and the following disclaimer in
022: * the documentation and/or other materials provided with the
023: * distribution.
024: *
025: * 3. The end-user documentation included with the redistribution, if
026: * any, must include the following acknowlegement:
027: * "This product includes software developed by the
028: * Apache Software Foundation (http://www.apache.org/)."
029: * Alternately, this acknowlegement may appear in the software itself,
030: * if and wherever such third-party acknowlegements normally appear.
031: *
032: * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033: * Foundation" must not be used to endorse or promote products derived
034: * from this software without prior written permission. For written
035: * permission, please contact apache@apache.org.
036: *
037: * 5. Products derived from this software may not be called "Apache"
038: * nor may "Apache" appear in their names without prior written
039: * permission of the Apache Group.
040: *
041: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052: * SUCH DAMAGE.
053: * ====================================================================
054: *
055: * This software consists of voluntary contributions made by many
056: * individuals on behalf of the Apache Software Foundation. For more
057: * information on the Apache Software Foundation, please see
058: * <http://www.apache.org/>.
059: *
060: * [Additional notices, if required by prior licensing conditions]
061: *
062: */
063:
064: package org.apache.catalina.core;
065:
066: import java.io.InputStream;
067: import java.io.File;
068: import java.net.MalformedURLException;
069: import java.net.URL;
070: import java.security.AccessController;
071: import java.security.PrivilegedAction;
072: import java.security.PrivilegedExceptionAction;
073: import java.security.PrivilegedActionException;
074: import java.util.ArrayList;
075: import java.util.Arrays;
076: import java.util.Enumeration;
077: import java.util.HashMap;
078: import java.util.HashSet;
079: import java.util.Set;
080: import javax.naming.NamingException;
081: import javax.naming.Binding;
082: import javax.naming.directory.DirContext;
083: import javax.servlet.RequestDispatcher;
084: import javax.servlet.Servlet;
085: import javax.servlet.ServletContext;
086: import javax.servlet.ServletException;
087: import javax.servlet.ServletContextAttributeEvent;
088: import javax.servlet.ServletContextAttributeListener;
089: import javax.servlet.http.HttpServletRequest;
090:
091: /**
092: * Facade object which masks the internal <code>ApplicationContext</code>
093: * object from the web application.
094: *
095: * @author Remy Maucherat
096: * @version $Revision: 1.3 $ $Date: 2001/07/22 20:25:08 $
097: */
098:
099: public final class ApplicationContextFacade implements ServletContext {
100:
101: // ----------------------------------------------------------- Constructors
102:
103: /**
104: * Construct a new instance of this class, associated with the specified
105: * Context instance.
106: *
107: * @param context The associated Context instance
108: */
109: public ApplicationContextFacade(ApplicationContext context) {
110: super ();
111: this .context = context;
112: }
113:
114: // ----------------------------------------------------- Instance Variables
115:
116: /**
117: * Wrapped application context.
118: */
119: private ApplicationContext context = null;
120:
121: // ------------------------------------------------- ServletContext Methods
122:
123: public ServletContext getContext(String uripath) {
124: ServletContext theContext = context.getContext(uripath);
125: if ((theContext != null)
126: && (theContext instanceof ApplicationContext))
127: theContext = ((ApplicationContext) theContext).getFacade();
128: return (theContext);
129: }
130:
131: public int getMajorVersion() {
132: return context.getMajorVersion();
133: }
134:
135: public int getMinorVersion() {
136: return context.getMinorVersion();
137: }
138:
139: public String getMimeType(String file) {
140: return context.getMimeType(file);
141: }
142:
143: public Set getResourcePaths(String path) {
144: return context.getResourcePaths(path);
145: }
146:
147: public URL getResource(String path) throws MalformedURLException {
148: return context.getResource(path);
149: }
150:
151: public InputStream getResourceAsStream(String path) {
152: return context.getResourceAsStream(path);
153: }
154:
155: public RequestDispatcher getRequestDispatcher(String path) {
156: return context.getRequestDispatcher(path);
157: }
158:
159: public RequestDispatcher getNamedDispatcher(String name) {
160: return context.getNamedDispatcher(name);
161: }
162:
163: public Servlet getServlet(String name) throws ServletException {
164: return context.getServlet(name);
165: }
166:
167: public Enumeration getServlets() {
168: return context.getServlets();
169: }
170:
171: public Enumeration getServletNames() {
172: return context.getServletNames();
173: }
174:
175: public void log(String msg) {
176: context.log(msg);
177: }
178:
179: public void log(Exception exception, String msg) {
180: context.log(exception, msg);
181: }
182:
183: public void log(String message, Throwable throwable) {
184: context.log(message, throwable);
185: }
186:
187: public String getRealPath(String path) {
188: return context.getRealPath(path);
189: }
190:
191: public String getServerInfo() {
192: return context.getServerInfo();
193: }
194:
195: public String getInitParameter(String name) {
196: return context.getInitParameter(name);
197: }
198:
199: public Enumeration getInitParameterNames() {
200: return context.getInitParameterNames();
201: }
202:
203: public Object getAttribute(String name) {
204: return context.getAttribute(name);
205: }
206:
207: public Enumeration getAttributeNames() {
208: return context.getAttributeNames();
209: }
210:
211: public void setAttribute(String name, Object object) {
212: context.setAttribute(name, object);
213: }
214:
215: public void removeAttribute(String name) {
216: context.removeAttribute(name);
217: }
218:
219: public String getServletContextName() {
220: return context.getServletContextName();
221: }
222:
223: }
|