org.eclipse.equinox.http.servlet_1.1.200.v20110502

D_SINCE = "If-Modified-Since";
  private static final String IF_NONE_MATCH = "If-None-Match";
  private static final String ETAG = "ETag";
  private String internalName;
  HttpContext httpContext;
  private AccessControlContext acc;
  
  public ResourceServlet(String internalName, HttpContext context, AccessControlContext acc)
  {
    this.internalName = internalName;
    if (internalName.equals("/")) {
      this.internalName = "";
    }
    httpContext = context;
    this.acc = acc;
  }
  
  public void service(HttpServletRequest req, HttpServletResponse resp)
    throws IOException
  {
    String method = req.getMethod();
    if ((method.equals("GET")) || (method.equals("POST")) || (method.equals("HEAD")))
    {
      String pathInfo = HttpServletRequestAdaptor.getDispatchPathInfo(req);
      if (pathInfo == null) {
        pathInfo = "";
      }
      String resourcePath = internalName + pathInfo;
      URL resourceURL = httpContext.getResource(resourcePath);
      if (resourceURL != null) {
        writeResource(req, resp, resourcePath, resourceURL);
      } else {
        resp.sendError(404, "ProxyServlet: " + req.getRequestURI());
      }
    }
    else
    {
      resp.setStatus(405);
    }
  }
  
  private void writeResource(HttpServletRequest req, HttpServletResponse resp, String resourcePath, URL resourceURL)
    throws IOException
  {
    try
    {
      AccessController.doPrivileged(new PrivilegedExceptionAction()
      {
        private final URL val$resourceURL;
        private final HttpServletRequest val$req;
        private final HttpServletResponse val$resp;
        private final String val$resourcePath;
        
        /* Error */
        public Object run()
          throws java.lang.Exception
        {
          // Byte code:
          //   0: aload_0
          //   1: getfield 184	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resourceURL	Ljava/net/URL;
          //   4: invokevirtual 196	java/net/URL:openConnection	()Ljava/net/URLConnection;
          //   7: astore_1
          //   8: aload_1
          //   9: invokevirtual 198	java/net/URLConnection:getLastModified	()J
          //   12: lstore_2
          //   13: aload_1
          //   14: invokevirtual 197	java/net/URLConnection:getContentLength	()I
          //   17: istore 4
          //   19: aconst_null
          //   20: astore 5
          //   22: lload_2
          //   23: ldc2_w 88
          //   26: lcmp
          //   27: ifeq +42 -> 69
          //   30: iload 4
          //   32: iconst_m1
          //   33: if_icmpeq +36 -> 69
          //   36: new 101	java/lang/StringBuffer
          //   39: dup
          //   40: ldc 7
          //   42: invokespecial 192	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
          //   45: iload 4
          //   47: invokevirtual 193	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
          //   50: ldc 2
          //   52: invokevirtual 195	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
          //   55: lload_2
          //   56: invokevirtual 194	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
          //   59: ldc 1
          //   61: invokevirtual 195	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
          //   64: invokevirtual 191	java/lang/StringBuffer:toString	()Ljava/lang/String;
          //   67: astore 5
          //   69: aload_0
          //   70: getfield 185	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$req	Ljavax/servlet/http/HttpServletRequest;
          //   73: ldc 5
          //   75: invokeinterface 211 2 0
          //   80: astore 6
          //   82: aload 6
          //   84: ifnull +35 -> 119
          //   87: aload 5
          //   89: ifnull +30 -> 119
          //   92: aload 6
          //   94: aload 5
          //   96: invokevirtual 190	java/lang/String:indexOf	(Ljava/lang/String;)I
          //   99: iconst_m1
          //   100: if_icmpeq +19 -> 119
          //   103: aload_0
          //   104: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   107: sipush 304
          //   110: invokeinterface 212 2 0
          //   115: getstatic 181	java/lang/Boolean:TRUE	Ljava/lang/Boolean;
          //   118: areturn
          //   119: aload_0
          //   120: getfield 185	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$req	Ljavax/servlet/http/HttpServletRequest;
          //   123: ldc 4
          //   125: invokeinterface 210 2 0
          //   130: lstore 7
          //   132: lload 7
          //   134: ldc2_w 88
          //   137: lcmp
          //   138: ifle +36 -> 174
          //   141: lload_2
          //   142: lconst_0
          //   143: lcmp
          //   144: ifle +30 -> 174
          //   147: lload_2
          //   148: lload 7
          //   150: ldc2_w 90
          //   153: ladd
          //   154: lcmp
          //   155: ifgt +19 -> 174
          //   158: aload_0
          //   159: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   162: sipush 304
          //   165: invokeinterface 212 2 0
          //   170: getstatic 181	java/lang/Boolean:TRUE	Ljava/lang/Boolean;
          //   173: areturn
          //   174: iload 4
          //   176: iconst_m1
          //   177: if_icmpeq +14 -> 191
          //   180: aload_0
          //   181: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   184: iload 4
          //   186: invokeinterface 206 2 0
          //   191: aload_0
          //   192: getfield 187	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:this$0	Lorg/eclipse/equinox/http/servlet/internal/ResourceServlet;
          //   195: getfield 182	org/eclipse/equinox/http/servlet/internal/ResourceServlet:httpContext	Lorg/osgi/service/http/HttpContext;
          //   198: aload_0
          //   199: getfield 183	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resourcePath	Ljava/lang/String;
          //   202: invokeinterface 215 2 0
          //   207: astore 9
          //   209: aload 9
          //   211: ifnonnull +26 -> 237
          //   214: aload_0
          //   215: getfield 187	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:this$0	Lorg/eclipse/equinox/http/servlet/internal/ResourceServlet;
          //   218: invokevirtual 200	javax/servlet/GenericServlet:getServletConfig	()Ljavax/servlet/ServletConfig;
          //   221: invokeinterface 204 1 0
          //   226: aload_0
          //   227: getfield 183	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resourcePath	Ljava/lang/String;
          //   230: invokeinterface 205 2 0
          //   235: astore 9
          //   237: aload 9
          //   239: ifnull +14 -> 253
          //   242: aload_0
          //   243: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   246: aload 9
          //   248: invokeinterface 208 2 0
          //   253: lload_2
          //   254: lconst_0
          //   255: lcmp
          //   256: ifle +15 -> 271
          //   259: aload_0
          //   260: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   263: ldc 6
          //   265: lload_2
          //   266: invokeinterface 213 4 0
          //   271: aload 5
          //   273: ifnull +16 -> 289
          //   276: aload_0
          //   277: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   280: ldc 3
          //   282: aload 5
          //   284: invokeinterface 214 3 0
          //   289: iload 4
          //   291: ifeq +186 -> 477
          //   294: aconst_null
          //   295: astore 10
          //   297: aload_1
          //   298: invokevirtual 199	java/net/URLConnection:getInputStream	()Ljava/io/InputStream;
          //   301: astore 10
          //   303: aload_0
          //   304: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   307: invokeinterface 209 1 0
          //   312: astore 11
          //   314: aload_0
          //   315: getfield 187	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:this$0	Lorg/eclipse/equinox/http/servlet/internal/ResourceServlet;
          //   318: aload 10
          //   320: aload 11
          //   322: invokevirtual 202	org/eclipse/equinox/http/servlet/internal/ResourceServlet:writeResourceToOutputStream	(Ljava/io/InputStream;Ljava/io/OutputStream;)I
          //   325: istore 12
          //   327: iload 4
          //   329: iconst_m1
          //   330: if_icmpeq +10 -> 340
          //   333: iload 4
          //   335: iload 12
          //   337: if_icmpeq +126 -> 463
          //   340: aload_0
          //   341: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   344: iload 12
          //   346: invokeinterface 206 2 0
          //   351: goto +112 -> 463
          //   354: pop
          //   355: aload_0
          //   356: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   359: invokeinterface 207 1 0
          //   364: astore 11
          //   366: aload_0
          //   367: getfield 187	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:this$0	Lorg/eclipse/equinox/http/servlet/internal/ResourceServlet;
          //   370: aload 10
          //   372: aload 11
          //   374: invokevirtual 203	org/eclipse/equinox/http/servlet/internal/ResourceServlet:writeResourceToWriter	(Ljava/io/InputStream;Ljava/io/Writer;)V
          //   377: goto +86 -> 463
          //   380: pop
          //   381: aload_0
          //   382: getfield 187	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:this$0	Lorg/eclipse/equinox/http/servlet/internal/ResourceServlet;
          //   385: aload_0
          //   386: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   389: sipush 403
          //   392: invokevirtual 201	org/eclipse/equinox/http/servlet/internal/ResourceServlet:sendError	(Ljavax/servlet/http/HttpServletResponse;I)V
          //   395: aload 10
          //   397: ifnull +80 -> 477
          //   400: aload 10
          //   402: invokevirtual 188	java/io/InputStream:close	()V
          //   405: goto +72 -> 477
          //   408: pop
          //   409: goto +68 -> 477
          //   412: pop
          //   413: aload_0
          //   414: getfield 187	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:this$0	Lorg/eclipse/equinox/http/servlet/internal/ResourceServlet;
          //   417: aload_0
          //   418: getfield 186	org/eclipse/equinox/http/servlet/internal/ResourceServlet$1:val$resp	Ljavax/servlet/http/HttpServletResponse;
          //   421: sipush 403
          //   424: invokevirtual 201	org/eclipse/equinox/http/servlet/internal/ResourceServlet:sendError	(Ljavax/servlet/http/HttpServletResponse;I)V
          //   427: aload 10
          //   429: ifnull +48 -> 477
          //   432: aload 10
          //   434: invokevirtual 188	java/io/InputStream:close	()V
          //   437: goto +40 -> 477
          //   440: pop
          //   441: goto +36 -> 477
          //   444: astore 13
          //   446: aload 10
          //   448: ifnull +12 -> 460
          //   451: aload 10
          //   453: invokevirtual 188	java/io/InputStream:close	()V
          //   456: goto +4 -> 460
          //   459: pop
          //   460: aload 13
          //   462: athrow
          //   463: aload 10
          //   465: ifnull +12 -> 477
          //   468: aload 10
          //   470: invokevirtual 188	java/io/InputStream:close	()V
          //   473: goto +4 -> 477
          //   476: pop
          //   477: getstatic 181	java/lang/Boolean:TRUE	Ljava/lang/Boolean;
          //   480: areturn
          // Line number table:
          //   Java source line #63	-> byte code offset #0
          //   Java source line #64	-> byte code offset #8
          //   Java source line #65	-> byte code offset #13
          //   Java source line #67	-> byte code offset #19
          //   Java source line #68	-> byte code offset #22
          //   Java source line #69	-> byte code offset #36
          //   Java source line #73	-> byte code offset #69
          //   Java source line #74	-> byte code offset #82
          //   Java source line #75	-> byte code offset #103
          //   Java source line #76	-> byte code offset #115
          //   Java source line #79	-> byte code offset #119
          //   Java source line #82	-> byte code offset #132
          //   Java source line #83	-> byte code offset #158
          //   Java source line #84	-> byte code offset #170
          //   Java source line #88	-> byte code offset #174
          //   Java source line #89	-> byte code offset #180
          //   Java source line #91	-> byte code offset #191
          //   Java source line #92	-> byte code offset #209
          //   Java source line #93	-> byte code offset #214
          //   Java source line #95	-> byte code offset #237
          //   Java source line #96	-> byte code offset #242
          //   Java source line #98	-> byte code offset #253
          //   Java source line #99	-> byte code offset #259
          //   Java source line #101	-> byte code offset #271
          //   Java source line #102	-> byte code offset #276
          //   Java source line #104	-> byte code offset #289
          //   Java source line #106	-> byte code offset #294
          //   Java source line #108	-> byte code offset #297
          //   Java source line #111	-> byte code offset #303
          //   Java source line #112	-> byte code offset #314
          //   Java source line #113	-> byte code offset #327
          //   Java source line #114	-> byte code offset #340
          //   Java source line #115	-> byte code offset #354
          //   Java source line #116	-> byte code offset #355
          //   Java source line #117	-> byte code offset #366
          //   Java source line #122	-> byte code offset #380
          //   Java source line #126	-> byte code offset #381
          //   Java source line #132	-> byte code offset #395
          //   Java source line #134	-> byte code offset #400
          //   Java source line #135	-> byte code offset #408
          //   Java source line #127	-> byte code offset #412
          //   Java source line #130	-> byte code offset #413
          //   Java source line #132	-> byte code offset #427
          //   Java source line #134	-> byte code offset #432
          //   Java source line #135	-> byte code offset #440
          //   Java source line #131	-> byte code offset #444
          //   Java source line #132	-> byte code offset #446
          //   Java source line #134	-> byte code offset #451
          //   Java source line #135	-> byte code offset #459
          //   Java source line #138	-> byte code offset #460
          //   Java source line #132	-> byte code offset #463
          //   Java source line #134	-> byte code offset #468
          //   Java source line #135	-> byte code offset #476
          //   Java source line #140	-> byte code offset #477
          // Local variable table:
          //   start	length	slot	name	signature
          //   0	481	0	this	1
          //   7	291	1	connection	java.net.URLConnection
          //   12	254	2	lastModified	long
          //   17	317	4	contentLength	int
          //   20	263	5	etag	String
          //   80	13	6	ifNoneMatch	String
          //   130	19	7	ifModifiedSince	long
          //   207	40	9	contentType	String
          //   295	174	10	is	InputStream
          //   312	9	11	os	OutputStream
          //   364	9	11	writer	java.io.Writer
          //   325	20	12	writtenContentLength	int
          //   354	1	13	localIllegalStateException	IllegalStateException
          //   444	17	13	localObject	Object
          //   380	1	14	localFileNotFoundException	java.io.FileNotFoundException
          //   408	1	15	localIOException1	IOException
          //   412	1	16	localSecurityException	SecurityException
          //   440	1	17	localIOException2	IOException
          //   459	1	18	localIOException3	IOException
          //   476	1	19	localIOException4	IOException
          // Exception table:
          //   from	to	target	type
          //   303	351	354	java/lang/IllegalStateException
          //   297	377	380	java/io/FileNotFoundException
          //   400	405	408	java/io/IOException
          //   297	377	412	java/lang/SecurityException
          //   432	437	440	java/io/IOException
          //   297	395	444	finally
          //   412	427	444	finally
          //   451	456	459	java/io/IOException
          //   468	473	476	java/io/IOException
        }
      }, acc);
    }
    catch (PrivilegedActionException e)
    {
      throw ((IOException)e.getException());
    }
  }
  
  void sendError(HttpServletResponse resp, int sc)
    throws IOException
  {
    try
    {
      resp.reset();
      resp.sendError(sc);
    }
    catch (IllegalStateException localIllegalStateException) {}
  }
  
  int writeResourceToOutputStream(InputStream is, OutputStream os)
    throws IOException
  {
    byte[] buffer = new byte['?'];
    int bytesRead = is.read(buffer);
    int writtenContentLength = 0;
    while (bytesRead != -1)
    {
      os.write(buffer, 0, bytesRead);
      writtenContentLength += bytesRead;
      bytesRead = is.read(buffer);
    }
    return writtenContentLength;
  }
  
  /* Error */
  void writeResourceToWriter(InputStream is, java.io.Writer writer)
    throws IOException
  {
    // Byte code:
    //   0: new 101	java/io/InputStreamReader
    //   3: dup
    //   4: aload_1
    //   5: invokespecial 179	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   8: astore_3
    //   9: sipush 8192
    //   12: newarray <illegal type>
    //   14: astore 4
    //   16: aload_3
    //   17: aload 4
    //   19: invokevirtual 182	java/io/Reader:read	([C)I
    //   22: istore 5
    //   24: goto +20 -> 44
    //   27: aload_2
    //   28: aload 4
    //   30: iconst_0
    //   31: iload 5
    //   33: invokevirtual 183	java/io/Writer:write	([CII)V
    //   36: aload_3
    //   37: aload 4
    //   39: invokevirtual 182	java/io/Reader:read	([C)I
    //   42: istore 5
    //   44: iload 5
    //   46: iconst_m1
    //   47: if_icmpne -20 -> 27
    //   50: goto +16 -> 66
    //   53: astore 6
    //   55: aload_3
    //   56: ifnull +7 -> 63
    //   59: aload_3
    //   60: invokevirtual 181	java/io/Reader:close	()V
    //   63: aload 6
    //   65: athrow
    //   66: aload_3
    //   67: ifnull +7 -> 74
    //   70: aload_3
    //   71: invokevirtual 181	java/io/Reader:close	()V
    //   74: return
    // Line number table:
    //   Java source line #172	-> byte code offset #0
    //   Java source line #174	-> byte code offset #9
    //   Java source line #175	-> byte code offset #16
    //   Java source line #176	-> byte code offset #24
    //   Java source line #177	-> byte code offset #27
    //   Java source line #178	-> byte code offset #36
    //   Java source line #176	-> byte code offset #44
    //   Java source line #180	-> byte code offset #53
    //   Java source line #181	-> byte code offset #55
    //   Java source line #182	-> byte code offset #59
    //   Java source line #184	-> byte code offset #63
    //   Java source line #181	-> byte code offset #66
    //   Java source line #182	-> byte code offset #70
    //   Java source line #185	-> byte code offset #74
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	75	0	this	ResourceServlet
    //   0	75	1	is	InputStream
    //   0	75	2	writer	java.io.Writer
    //   8	63	3	reader	java.io.Reader
    //   14	24	4	buffer	char[]
    //   22	23	5	charsRead	int
    //   53	11	6	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   9	53	53	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.servlet.internal.ResourceServlet
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.http.servlet.internal;

import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;

public class ServletConfigImpl
  implements ServletConfig
{
  private static final Dictionary EMPTY_PARAMS = new Hashtable(0);
  private static final String SERVLET_NAME = "servlet-name";
  private Servlet servlet;
  private Dictionary initparams;
  private ServletContext servletContext;
  
  public ServletConfigImpl(Servlet servlet, Dictionary initparams, ServletContext servletContext)
  {
    this.servlet = servlet;
    this.initparams = (initparams != null ? initparams : EMPTY_PARAMS);
    this.servletContext = servletContext;
  }
  
  public String getServletName()
  {
    String servletName = (String)initparams.get("servlet-name");
    return servletName != null ? servletName : servlet.getClass().getName();
  }
  
  public ServletContext getServletContext()
  {
    return servletContext;
  }
  
  public String getInitParameter(String name)
  {
    return (String)initparams.get(name);
  }
  
  public Enumeration getInitParameterNames()
  {
    return initparams.keys();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.servlet.internal.ServletConfigImpl
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.http.servlet.internal;

import java.security.PrivilegedExceptionAction;
import org.osgi.service.http.HttpContext;

class ServletContextAdaptor$1
  implements PrivilegedExceptionAction
{
  final ServletContextAdaptor this$0;
  private final String val$name;
  
  ServletContextAdaptor$1(ServletContextAdaptor paramServletContextAdaptor, String paramString)
  {
    this$0 = paramServletContextAdaptor;val$name = paramString;
  }
  
  public Object run()
    throws Exception
  {
    return this$0.httpContext.getResource(val$name);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.servlet.internal.ServletContextAdaptor.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.http.servlet.internal;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Set;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.osgi.service.http.HttpContext;

public class ServletContextAdaptor
  implements ServletContext
{
  private ServletContext servletContext;
  HttpContext httpContext;
  private AccessControlContext acc;
  private ProxyContext proxyContext;
  
  public ServletContextAdaptor(ProxyContext proxyContext, ServletContext servletContext, HttpContext httpContext, AccessControlContext acc)
  {
    this.servletContext = servletContext;
    this.httpContext = httpContext;
    this.acc = acc;
    this.proxyContext = proxyContext;
  }
  
  public Set getResourcePaths(String name)
  {
    if ((name == null) || (!name.startsWith("/"))) {
      return null;
    }
    try
    {
      Method getResourcePathsMethod = httpContext.getClass().getMethod("getResourcePaths", new Class[] { String.class });
      if (!getResourcePathsMethod.isAccessible()) {
        getResourcePathsMethod.setAccessible(true);
      }
      return (Set)getResourcePathsMethod.invoke(httpContext, new Object[] { name });
    }
    catch (Exception localException) {}
    return null;
  }
  
  public Object getAttribute(String attributeName)
  {
    Dictionary attributes = proxyContext.getContextAttributes(httpContext);
    return attributes.get(attributeName);
  }
  
  public Enumeration getAttributeNames()
  {
    Dictionary attributes = proxyContext.getContextAttributes(httpContext);
    return attributes.keys();
  }
  
  public void setAttribute(String attributeName, Object attributeValue)
  {
    Dictionary attributes = proxyContext.getContextAttributes(httpContext);
    attributes.put(attributeName, attributeValue);
  }
  
  public void removeAttribute(String attributeName)
  {
    Dictionary attributes = proxyContext.getContextAttributes(httpContext);
    attributes.remove(attributeName);
  }
  
  public String getMimeType(String name)
  {
    String mimeType = httpContext.getMimeType(name);
    return mimeType != null ? mimeType : servletContext.getMimeType(name);
  }
  
  public URL getResource(String name)
  {
    try
    {
      (URL)AccessController.doPrivileged(new PrivilegedExceptionAction()
      {
        private final String val$name;
        
        public Object run()
          throws Exception
        {
          return httpContext.getResource(val$name);
        }
      }, acc);
    }
    catch (PrivilegedActionException e)
    {
      log(e.getException().getMessage(), e.getException());
    }
    return null;
  }
  
  public InputStream getResourceAsStream(String name)
  {
    URL url = getResource(name);
    if (url != null) {
      try
      {
        return url.openStream();
      }
      catch (IOException e)
      {
        log("Error opening stream for resource '" + name + "'", e);
      }
    }
    return null;
  }
  
  public ServletContext getContext(String arg0)
  {
    return servletContext.getContext(arg0);
  }
  
  public String getInitParameter(String arg0)
  {
    return servletContext.getInitParameter(arg0);
  }
  
  public Enumeration getInitParameterNames()
  {
    return servletContext.getInitParameterNames();
  }
  
  public int getMajorVersion()
  {
    return servletContext.getMajorVersion();
  }
  
  public int getMinorVersion()
  {
    return servletContext.getMinorVersion();
  }
  
  public RequestDispatcher getNamedDispatcher(String arg0)
  {
    return new RequestDispatcherAdaptor(servletContext.getNamedDispatcher(arg0));
  }
  
  public String getRealPath(String arg0)
  {
    return servletContext.getRealPath(arg0);
  }
  
  public RequestDispatcher getRequestDispatcher(String arg0)
  {
    return new RequestDispatcherAdaptor(servletContext.getRequestDispatcher(proxyContext.getServletPath() + arg0));
  }
  
  public String getServerInfo()
  {
    return servletContext.getServerInfo();
  }
  
  /**
   * @deprecated
   */
  public Servlet getServlet(String arg0)
    throws ServletException
  {
    return servletContext.getServlet(arg0);
  }
  
  public String getServletContextName()
  {
    return servletContext.getServletContextName();
  }
  
  /**
   * @deprecated
   */
  public Enumeration getServletNames()
  {
    return servletContext.getServletNames();
  }
  
  /**
   * @deprecated
   */
  public Enumeration getServlets()
  {
    return servletContext.getServlets();
  }
  
  /**
   * @deprecated
   */
  public void log(Exception arg0, String arg1)
  {
    servletContext.log(arg0, arg1);
  }
  
  public void log(String arg0, Throwable arg1)
  {
    servletContext.log(arg0, arg1);
  }
  
  public void log(String arg0)
  {
    servletContext.log(arg0);
  }
  
  public String getContextPath()
  {
    try
    {
      Method getContextPathMethod = servletContext.getClass().getMethod("getContextPath", null);
      return (String)getContextPathMethod.invoke(servletContext, null) + proxyContext.getServletPath();
    }
    catch (Exception localException) {}
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.servlet.internal.ServletContextAdaptor
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.http.servlet.internal;

import javax.servlet.Servlet;
import org.osgi.service.http.HttpContext;

public class ServletRegistration
  extends Registration
{
  private Servlet servlet;
  private HttpContext httpContext;
  private ClassLoader registeredContextClassLoader;
  
  public ServletRegistration(Servlet servlet, HttpContext context)
  {
    this.servlet = servlet;
    httpContext = context;
    registeredContextClassLoader = Thread.currentThread().getContextClassLoader();
  }
  
  /* Error */
  public void destroy()
  {
    // Byte code:
    //   0: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   3: invokevirtual 66	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   6: astore_1
    //   7: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   10: aload_0
    //   11: getfield 63	org/eclipse/equinox/http/servlet/internal/ServletRegistration:registeredContextClassLoader	Ljava/lang/ClassLoader;
    //   14: invokevirtual 67	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   17: aload_0
    //   18: invokespecial 70	org/eclipse/equinox/http/servlet/internal/Registration:destroy	()V
    //   21: aload_0
    //   22: getfield 64	org/eclipse/equinox/http/servlet/internal/ServletRegistration:servlet	Ljavax/servlet/Servlet;
    //   25: invokeinterface 71 1 0
    //   30: goto +13 -> 43
    //   33: astore_2
    //   34: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   37: aload_1
    //   38: invokevirtual 67	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   41: aload_2
    //   42: athrow
    //   43: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   46: aload_1
    //   47: invokevirtual 67	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   50: return
    // Line number table:
    //   Java source line #34	-> byte code offset #0
    //   Java source line #36	-> byte code offset #7
    //   Java source line #37	-> byte code offset #17
    //   Java source line #38	-> byte code offset #21
    //   Java source line #39	-> byte code offset #33
    //   Java source line #40	-> byte code offset #34
    //   Java source line #41	-> byte code offset #41
    //   Java source line #40	-> byte code offset #43
    //   Java source line #42	-> byte code offset #50
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	51	0	this	ServletRegistration
    //   6	41	1	original	ClassLoader
    //   33	9	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   7	33	33	finally
  }
  
  /* Error */
  public void init(javax.servlet.ServletConfig servletConfig)
    throws javax.servlet.ServletException
  {
    // Byte code:
    //   0: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   3: invokevirtual 66	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   6: astore_2
    //   7: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   10: aload_0
    //   11: getfield 63	org/eclipse/equinox/http/servlet/internal/ServletRegistration:registeredContextClassLoader	Ljava/lang/ClassLoader;
    //   14: invokevirtual 67	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   17: aload_0
    //   18: getfield 64	org/eclipse/equinox/http/servlet/internal/ServletRegistration:servlet	Ljavax/servlet/Servlet;
    //   21: aload_1
    //   22: invokeinterface 72 2 0
    //   27: goto +13 -> 40
    //   30: astore_3
    //   31: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   34: aload_2
    //   35: invokevirtual 67	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   38: aload_3
    //   39: athrow
    //   40: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   43: aload_2
    //   44: invokevirtual 67	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   47: return
    // Line number table:
    //   Java source line #46	-> byte code offset #0
    //   Java source line #48	-> byte code offset #7
    //   Java source line #49	-> byte code offset #17
    //   Java source line #50	-> byte code offset #30
    //   Java source line #51	-> byte code offset #31
    //   Java source line #52	-> byte code offset #38
    //   Java source line #51	-> byte code offset #40
    //   Java source line #53	-> byte code offset #47
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	48	0	this	ServletRegistration
    //   0	48	1	servletConfig	javax.servlet.ServletConfig
    //   6	38	2	original	ClassLoader
    //   30	9	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   7	30	30	finally
  }
  
  /* Error */
  public void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
    throws java.io.IOException, javax.servlet.ServletException
  {
    // Byte code:
    //   0: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   3: invokevirtual 66	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   6: astore_3
    //   7: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   10: aload_0
    //   11: getfield 63	org/eclipse/equinox/http/servlet/internal/ServletRegistration:registeredContextClassLoader	Ljava/lang/ClassLoader;
    //   14: invokevirtual 67	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   17: aload_0
    //   18: getfield 65	org/eclipse/equinox/http/servlet/internal/ServletRegistration:httpContext	Lorg/osgi/service/http/HttpContext;
    //   21: aload_1
    //   22: aload_2
    //   23: invokeinterface 74 3 0
    //   28: ifeq +29 -> 57
    //   31: aload_0
    //   32: getfield 64	org/eclipse/equinox/http/servlet/internal/ServletRegistration:servlet	Ljavax/servlet/Servlet;
    //   35: aload_1
    //   36: aload_2
    //   37: invokeinterface 73 3 0
    //   42: goto +15 -> 57
    //   45: astore 4
    //   47: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   50: aload_3
    //   51: invokevirtual 67	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   54: aload 4
    //   56: athrow
    //   57: invokestatic 68	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   60: aload_3
    //   61: invokevirtual 67	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   64: return
    // Line number table:
    //   Java source line #57	-> byte code offset #0
    //   Java source line #59	-> byte code offset #7
    //   Java source line #60	-> byte code offset #17
    //   Java source line #61	-> byte code offset #31
    //   Java source line #62	-> byte code offset #45
    //   Java source line #63	-> byte code offset #47
    //   Java source line #64	-> byte code offset #54
    //   Java source line #63	-> byte code offset #57
    //   Java source line #65	-> byte code offset #64
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	65	0	this	ServletRegistration
    //   0	65	1	req	javax.servlet.http.HttpServletRequest
    //   0	65	2	resp	javax.servlet.http.HttpServletResponse
    //   6	55	3	original	ClassLoader
    //   45	10	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   7	45	45	finally
  }
  
  public Servlet getServlet()
  {
    return servlet;
  }
  
  public HttpContext getHttpContext()
  {
    return httpContext;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.servlet.internal.ServletRegistration
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd