001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2007 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.lib.web.micro.base;
028:
029: import java.io.InputStream;
030: import java.net.URL;
031: import java.util.Enumeration;
032: import java.util.Set;
033:
034: import javax.servlet.RequestDispatcher;
035: import javax.servlet.Servlet;
036: import javax.servlet.ServletContext;
037:
038: /**
039: * A minimal servlet context implementation.
040: * <p>
041: * In the currently version, nearly all of the methods are not supported.
042: */
043: public class ServletContextImpl implements ServletContext {
044:
045: private static final Enumeration EMPTY_ENUMERATION = new Enumeration() {
046: public boolean hasMoreElements() {
047: return false;
048: }
049:
050: public Object nextElement() {
051: return null;
052: }
053: };
054:
055: // engine id
056: public String getServerInfo() {
057: return "Cougaar Micro/1.0";
058: }
059:
060: // disable logging
061: public void log(String msg) {
062: }
063:
064: public void log(String message, Throwable throwable) {
065: }
066:
067: // the rest is disabled:
068: public ServletContext getContext(String uripath) {
069: return null;
070: }
071:
072: public int getMajorVersion() {
073: return 2;
074: }
075:
076: public int getMinorVersion() {
077: return 3;
078: }
079:
080: public String getMimeType(String file) {
081: return null;
082: }
083:
084: public Set getResourcePaths(String path) {
085: return null;
086: }
087:
088: public URL getResource(String path) {
089: return null;
090: }
091:
092: public InputStream getResourceAsStream(String path) {
093: return null;
094: }
095:
096: public RequestDispatcher getRequestDispatcher(String path) {
097: die();
098: return null;
099: }
100:
101: public RequestDispatcher getNamedDispatcher(String name) {
102: die();
103: return null;
104: }
105:
106: public Servlet getServlet(String name) {
107: die();
108: return null;
109: }
110:
111: public Enumeration getServlets() {
112: return EMPTY_ENUMERATION;
113: }
114:
115: public Enumeration getServletNames() {
116: return EMPTY_ENUMERATION;
117: }
118:
119: public void log(Exception exception, String msg) {
120: log(msg, exception);
121: }
122:
123: public String getRealPath(String path) {
124: die();
125: return null;
126: }
127:
128: public String getInitParameter(String name) {
129: return null;
130: }
131:
132: public Enumeration getInitParameterNames() {
133: return EMPTY_ENUMERATION;
134: }
135:
136: public Object getAttribute(String name) {
137: return null;
138: }
139:
140: public Enumeration getAttributeNames() {
141: return EMPTY_ENUMERATION;
142: }
143:
144: public void setAttribute(String name, Object object) {
145: if (object != null)
146: die();
147: }
148:
149: public void removeAttribute(String name) {
150: }
151:
152: public String getServletContextName() {
153: return null;
154: }
155:
156: private static final void die() {
157: throw new UnsupportedOperationException("die");
158: }
159: }
|