org.eclipse.equinox.jsp.jasper_1.0.300.v20110502

16:43:58.679 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.jsp.jasper_1.0.300.v20110502.jar
package org.eclipse.equinox.internal.jsp.jasper;

import org.apache.jasper.servlet.JspServlet;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.packageadmin.ExportedPackage;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

public class Activator
  implements BundleActivator, ServiceTrackerCustomizer
{
  private ServiceTracker packageAdminTracker;
  private static PackageAdmin packageAdmin;
  private static volatile Bundle thisBundle;
  private BundleContext context;
  
  public void start(BundleContext context)
    throws Exception
  {
    this.context = context;
    thisBundle = context.getBundle();
    packageAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), this);
    packageAdminTracker.open();
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    packageAdminTracker.close();
    packageAdminTracker = null;
    thisBundle = null;
    this.context = null;
  }
  
  public Object addingService(ServiceReference reference)
  {
    synchronized (Activator.class)
    {
      packageAdmin = (PackageAdmin)context.getService(reference);
    }
    return packageAdmin;
  }
  
  public void modifiedService(ServiceReference reference, Object service) {}
  
  public void removedService(ServiceReference reference, Object service)
  {
    synchronized (Activator.class)
    {
      context.ungetService(reference);
      packageAdmin = null;
    }
  }
  
  public static synchronized Bundle getBundle(Class clazz)
  {
    if (packageAdmin == null) {
      throw new IllegalStateException("Not started");
    }
    return packageAdmin.getBundle(clazz);
  }
  
  public static Bundle[] getFragments(Bundle bundle)
  {
    if (packageAdmin == null) {
      throw new IllegalStateException("Not started");
    }
    return packageAdmin.getFragments(bundle);
  }
  
  public static Bundle getJasperBundle()
  {
    Bundle bundle = getBundle(JspServlet.class);
    if (bundle != null) {
      return bundle;
    }
    if (thisBundle == null) {
      throw new IllegalStateException("Not started");
    }
    ExportedPackage[] exportedPackages = packageAdmin.getExportedPackages("org.apache.jasper.servlet");
    for (int i = 0; i < exportedPackages.length; i++)
    {
      Bundle[] importingBundles = exportedPackages[i].getImportingBundles();
      for (int j = 0; j < importingBundles.length; j++) {
        if (thisBundle.equals(importingBundles[j])) {
          return exportedPackages[i].getExportingBundle();
        }
      }
    }
    return null;
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import org.osgi.framework.Bundle;

public class BundleProxyClassLoader
  extends ClassLoader
{
  private Bundle bundle;
  private ClassLoader parent;
  
  public BundleProxyClassLoader(Bundle bundle)
  {
    this.bundle = bundle;
  }
  
  public BundleProxyClassLoader(Bundle bundle, ClassLoader parent)
  {
    super(parent);
    this.parent = parent;
    this.bundle = bundle;
  }
  
  public Enumeration findResources(String name)
    throws IOException
  {
    return bundle.getResources(name);
  }
  
  public URL findResource(String name)
  {
    return bundle.getResource(name);
  }
  
  public Class findClass(String name)
    throws ClassNotFoundException
  {
    return bundle.loadClass(name);
  }
  
  public URL getResource(String name)
  {
    return parent == null ? findResource(name) : super.getResource(name);
  }
  
  protected Class loadClass(String name, boolean resolve)
    throws ClassNotFoundException
  {
    Class clazz = parent == null ? findClass(name) : super.loadClass(name, false);
    if (resolve) {
      super.resolveClass(clazz);
    }
    return clazz;
  }
}

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

import java.security.PrivilegedAction;

class JSPContextFinder$1
  implements PrivilegedAction
{
  public Object run()
  {
    JSPContextFinder.contextFinder = new JSPContextFinder.Finder();
    return null;
  }
}

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

final class JSPContextFinder$Finder
  extends SecurityManager
{
  public Class[] getClassContext()
  {
    return super.getClassContext();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.jsp.jasper.JSPContextFinder.Finder
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.jsp.jasper;

import java.io.IOException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class JSPContextFinder
  extends ClassLoader
  implements PrivilegedAction
{
  static final class Finder
    extends SecurityManager
  {
    public Class[] getClassContext()
    {
      return super.getClassContext();
    }
  }
  
  private static ThreadLocal cycleDetector = new ThreadLocal();
  static Finder contextFinder;
  
  static
  {
    AccessController.doPrivileged(new PrivilegedAction()
    {
      public Object run()
      {
        JSPContextFinder.contextFinder = new JSPContextFinder.Finder();
        return null;
      }
    });
  }
  
  public JSPContextFinder(ClassLoader contextClassLoader)
  {
    super(contextClassLoader);
  }
  
  ArrayList basicFindClassLoaders()
  {
    Class[] stack = contextFinder.getClassContext();
    ArrayList result = new ArrayList(1);
    ClassLoader previousLoader = null;
    for (int i = 1; i < stack.length; i++)
    {
      ClassLoader tmp = stack[i].getClassLoader();
      if ((checkClass(stack[i])) && (tmp != null) && (tmp != this))
      {
        if ((checkClassLoader(tmp)) && 
          (previousLoader != tmp))
        {
          result.add(tmp);
          previousLoader = tmp;
        }
        if (Activator.getBundle(stack[i]) != null) {
          break;
        }
      }
    }
    return result;
  }
  
  private boolean checkClass(Class clazz)
  {
    return (clazz != JSPContextFinder.class) && (clazz != BundleProxyClassLoader.class) && (clazz != JspClassLoader.class);
  }
  
  private boolean checkClassLoader(ClassLoader classloader)
  {
    if ((classloader == null) || (classloader == getParent())) {
      return false;
    }
    for (ClassLoader parent = classloader.getParent(); parent != null; parent = parent.getParent()) {
      if (parent == this) {
        return false;
      }
    }
    return true;
  }
  
  private ArrayList findClassLoaders()
  {
    if (System.getSecurityManager() == null) {
      return basicFindClassLoaders();
    }
    return (ArrayList)AccessController.doPrivileged(this);
  }
  
  public Object run()
  {
    return basicFindClassLoaders();
  }
  
  private boolean startLoading(String name)
  {
    Set classesAndResources = (Set)cycleDetector.get();
    if ((classesAndResources != null) && (classesAndResources.contains(name))) {
      return false;
    }
    if (classesAndResources == null)
    {
      classesAndResources = new HashSet(3);
      cycleDetector.set(classesAndResources);
    }
    classesAndResources.add(name);
    return true;
  }
  
  private void stopLoading(String name)
  {
    ((Set)cycleDetector.get()).remove(name);
  }
  
  protected Class loadClass(String arg0, boolean arg1)
    throws ClassNotFoundException
  {
    if (!startLoading(arg0)) {
      throw new ClassNotFoundException(arg0);
    }
    try
    {
      ArrayList toConsult = findClassLoaders();
      Class localClass;
      for (Iterator loaders = toConsult.iterator(); loaders.hasNext();) {
        try
        {
          return ((ClassLoader)loaders.next()).loadClass(arg0);
        }
        catch (ClassNotFoundException localClassNotFoundException) {}
      }
      return super.loadClass(arg0, arg1);
    }
    finally
    {
      stopLoading(arg0);
    }
  }
  
  public URL getResource(String arg0)
  {
    if (!startLoading(arg0)) {
      return null;
    }
    try
    {
      ArrayList toConsult = findClassLoaders();
      URL localURL1;
      for (Iterator loaders = toConsult.iterator(); loaders.hasNext();)
      {
        URL result = ((ClassLoader)loaders.next()).getResource(arg0);
        if (result != null) {
          return result;
        }
      }
      return super.getResource(arg0);
    }
    finally
    {
      stopLoading(arg0);
    }
  }
  
  protected Enumeration findResources(String arg0)
    throws IOException
  {
    if (!startLoading(arg0)) {
      return null;
    }
    try
    {
      ArrayList toConsult = findClassLoaders();
      Enumeration localEnumeration1;
      for (Iterator loaders = toConsult.iterator(); loaders.hasNext();)
      {
        Enumeration result = ((ClassLoader)loaders.next()).getResources(arg0);
        if ((result != null) && (result.hasMoreElements())) {
          return result;
        }
      }
      return super.findResources(arg0);
    }
    finally
    {
      stopLoading(arg0);
    }
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;

class JspClassLoader$1
  extends ClassLoader
{
  public URL getResource(String name)
  {
    return null;
  }
  
  public Enumeration findResources(String name)
    throws IOException
  {
    return new JspClassLoader.2(this);
  }
  
  public Class loadClass(String name)
    throws ClassNotFoundException
  {
    throw new ClassNotFoundException(name);
  }
}

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

import java.util.Enumeration;

class JspClassLoader$2
  implements Enumeration
{
  final JspClassLoader.1 this$1;
  
  JspClassLoader$2(JspClassLoader.1 param1)
  {
    this$1 = param1;
  }
  
  public boolean hasMoreElements()
  {
    return false;
  }
  
  public Object nextElement()
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.jsp.jasper.JspClassLoader.2
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.jsp.jasper;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.StringTokenizer;
import org.osgi.framework.Bundle;

public class JspClassLoader
  extends URLClassLoader
{
  private static final Bundle JASPERBUNDLE = ;
  private static final ClassLoader PARENT = JspClassLoader.class.getClassLoader().getParent();
  private static final String JAVA_PACKAGE = "java.";
  private static final ClassLoader EMPTY_CLASSLOADER = new ClassLoader()
  {
    public URL getResource(String name)
    {
      return null;
    }
    
    public Enumeration findResources(String name)
      throws IOException
    {
      return new JspClassLoader.2(this);
    }
    
    public Class loadClass(String name)
      throws ClassNotFoundException
    {
      throw new ClassNotFoundException(name);
    }
  };
  
  public JspClassLoader(Bundle bundle)
  {
    super(new URL[0], new BundleProxyClassLoader(bundle, new BundleProxyClassLoader(JASPERBUNDLE, new JSPContextFinder(EMPTY_CLASSLOADER))));
    addBundleClassPathJars(bundle);
    Bundle[] fragments = Activator.getFragments(bundle);
    if (fragments != null) {
      for (int i = 0; i < fragments.length; i++) {
        addBundleClassPathJars(fragments[i]);
      }
    }
  }
  
  private void addBundleClassPathJars(Bundle bundle)
  {
    Dictionary headers = bundle.getHeaders();
    String classPath = (String)headers.get("Bundle-ClassPath");
    if (classPath != null)
    {
      StringTokenizer tokenizer = new StringTokenizer(classPath, ",");
      while (tokenizer.hasMoreTokens())
      {
        String candidate = tokenizer.nextToken().trim();
        if (candidate.endsWith(".jar"))
        {
          URL entry = bundle.getEntry(candidate);
          if (entry != null) {
            try
            {
              URL jarEntryURL = new URL("jar:" + entry.toString() + "!/");
              super.addURL(jarEntryURL);
            }
            catch (MalformedURLException localMalformedURLException) {}
          }
        }
      }
    }
  }
  
  protected Class loadClass(String name, boolean resolve)
    throws ClassNotFoundException
  {
    if ((PARENT != null) && (name.startsWith("java."))) {
      return PARENT.loadClass(name);
    }
    return super.loadClass(name, resolve);
  }
  
  protected Class findClass(String name)
    throws ClassNotFoundException
  {
    throw new ClassNotFoundException(name);
  }
}

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

import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Collections;
import java.util.Enumeration;
import org.osgi.framework.Bundle;

class JspServlet$BundlePermissionCollection
  extends PermissionCollection
{
  private static final long serialVersionUID = -6365478608043900677L;
  private Bundle bundle;
  
  public JspServlet$BundlePermissionCollection(Bundle bundle)
  {
    this.bundle = bundle;
    super.setReadOnly();
  }
  
  public void add(Permission permission)
  {
    throw new SecurityException();
  }
  
  public boolean implies(Permission permission)
  {
    return bundle.hasPermission(permission);
  }
  
  public Enumeration elements()
  {
    return Collections.enumeration(Collections.EMPTY_LIST);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.jsp.jasper.JspServlet.BundlePermissionCollection
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.jsp.jasper;

import java.util.Enumeration;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;

class JspServlet$ServletConfigAdaptor
  implements ServletConfig
{
  private ServletConfig config;
  private ServletContext context;
  final JspServlet this$0;
  
  public JspServlet$ServletConfigAdaptor(JspServlet paramJspServlet, ServletConfig config)
  {
    this$0 = paramJspServlet;
    this.config = config;
    context = new JspServlet.ServletContextAdaptor(paramJspServlet, config.getServletContext());
  }
  
  public String getInitParameter(String arg0)
  {
    return config.getInitParameter(arg0);
  }
  
  public Enumeration getInitParameterNames()
  {
    return config.getInitParameterNames();
  }
  
  public ServletContext getServletContext()
  {
    return context;
  }
  
  public String getServletName()
  {
    return config.getServletName();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.jsp.jasper.JspServlet.ServletConfigAdaptor
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.jsp.jasper;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.osgi.framework.Bundle;

class JspServlet$ServletContextAdaptor
  implements ServletContext
{
  private ServletContext delegate;
  final JspServlet this$0;
  
  public JspServlet$ServletContextAdaptor(JspServlet paramJspServlet, ServletContext delegate)
  {
    this$0 = paramJspServlet;
    this.delegate = delegate;
  }
  
  public URL getResource(String name)
    throws MalformedURLException
  {
    if ((this$0.alias != null) && (name.startsWith(this$0.alias))) {
      name = name.substring(this$0.alias.length());
    }
    String resourceName = this$0.bundleResourcePath + name;
    int lastSlash = resourceName.lastIndexOf('/');
    if (lastSlash == -1) {
      return null;
    }
    String path = resourceName.substring(0, lastSlash);
    if (path.length() == 0) {
      path = "/";
    }
    String file = sanitizeEntryName(resourceName.substring(lastSlash + 1));
    Enumeration entryPaths = this$0.bundle.findEntries(path, file, false);
    if ((entryPaths != null) && (entryPaths.hasMoreElements())) {
      return (URL)entryPaths.nextElement();
    }
    return delegate.getResource(name);
  }
  
  private String sanitizeEntryName(String name)
  {
    StringBuffer buffer = null;
    for (int i = 0; i < name.length(); i++)
    {
      char c = name.charAt(i);
      switch (c)
      {
      case '*': 
      case '\\': 
        if (buffer == null)
        {
          buffer = new StringBuffer(name.length() + 16);
          buffer.append(name.substring(0, i));
        }
        buffer.append('\\').append(c);
        break;
      default: 
        if (buffer != null) {
          buffer.append(c);
        }
        break;
      }
    }
    return buffer == null ? name : buffer.toString();
  }
  
  public InputStream getResourceAsStream(String name)
  {
    try
    {
      URL resourceURL = getResource(name);
      if (resourceURL != null) {
        return resourceURL.openStream();
      }
    }
    catch (IOException e)
    {
      log("Error opening stream for resource '" + name + "'", e);
    }
    return null;
  }
  
  public Set getResourcePaths(String name)
  {
    Set result = delegate.getResourcePaths(name);
    Enumeration e = this$0.bundle.findEntries(this$0.bundleResourcePath + name, null, false);
    if (e != null)
    {
      if (result == null) {
        result = new HashSet();
      }
      while (e.hasMoreElements())
      {
        URL entryURL = (URL)e.nextElement();
        result.add(entryURL.getFile().substring(this$0.bundleResourcePath.length()));
      }
    }
    return result;
  }
  
  public RequestDispatcher getRequestDispatcher(String arg0)
  {
    return delegate.getRequestDispatcher(arg0);
  }
  
  public Object getAttribute(String arg0)
  {
    return delegate.getAttribute(arg0);
  }
  
  public Enumeration getAttributeNames()
  {
    return delegate.getAttributeNames();
  }
  
  public ServletContext getContext(String arg0)
  {
    return delegate.getContext(arg0);
  }
  
  public String getInitParameter(String arg0)
  {
    return delegate.getInitParameter(arg0);
  }
  
  public Enumeration getInitParameterNames()
  {
    return delegate.getInitParameterNames();
  }
  
  public int getMajorVersion()
  {
    return delegate.getMajorVersion();
  }
  
  public String getMimeType(String arg0)
  {
    return delegate.getMimeType(arg0);
  }
  
  public int getMinorVersion()
  {
    return delegate.getMinorVersion();
  }
  
  public RequestDispatcher getNamedDispatcher(String arg0)
  {
    return delegate.getNamedDispatcher(arg0);
  }
  
  public String getRealPath(String arg0)
  {
    return delegate.getRealPath(arg0);
  }
  
  public String getServerInfo()
  {
    return delegate.getServerInfo();
  }
  
  /**
   * @deprecated
   */
  public Servlet getServlet(String arg0)
    throws ServletException
  {
    return delegate.getServlet(arg0);
  }
  
  public String getServletContextName()
  {
    return delegate.getServletContextName();
  }
  
  /**
   * @deprecated
   */
  public Enumeration getServletNames()
  {
    return delegate.getServletNames();
  }
  
  /**
   * @deprecated
   */
  public Enumeration getServlets()
  {
    return delegate.getServlets();
  }
  
  /**
   * @deprecated
   */
  public void log(Exception arg0, String arg1)
  {
    delegate.log(arg0, arg1);
  }
  
  public void log(String arg0, Throwable arg1)
  {
    delegate.log(arg0, arg1);
  }
  
  public void log(String arg0)
  {
    delegate.log(arg0);
  }
  
  public void removeAttribute(String arg0)
  {
    delegate.removeAttribute(arg0);
  }
  
  public void setAttribute(String arg0, Object arg1)
  {
    delegate.setAttribute(arg0, arg1);
  }
  
  public String getContextPath()
  {
    try
    {
      Method getContextPathMethod = delegate.getClass().getMethod("getContextPath", null);
      return (String)getContextPathMethod.invoke(delegate, null);
    }
    catch (Exception localException) {}
    return null;
  }
}

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

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import org.eclipse.equinox.internal.jsp.jasper.JspClassLoader;
import org.osgi.framework.Bundle;

public class JspServlet
  extends HttpServlet
{
  private static final long serialVersionUID = -4110476909131707652L;
  
  private static class BundlePermissionCollection
    extends PermissionCollection
  {
    private static final long serialVersionUID = -6365478608043900677L;
    private Bundle bundle;
    
    public BundlePermissionCollection(Bundle bundle)
    {
      this.bundle = bundle;
      super.setReadOnly();
    }
    
    public void add(Permission permission)
    {
      throw new SecurityException();
    }
    
    public boolean implies(Permission permission)
    {
      return bundle.hasPermission(permission);
    }
    
    public Enumeration elements()
    {
      return Collections.enumeration(Collections.EMPTY_LIST);
    }
  }
  
  private Servlet jspServlet = new org.apache.jasper.servlet.JspServlet();
  Bundle bundle;
  private URLClassLoader jspLoader;
  String bundleResourcePath;
  String alias;
  
  public JspServlet(Bundle bundle, String bundleResourcePath, String alias)
  {
    this.bundle = bundle;
    this.bundleResourcePath = ((bundleResourcePath == null) || (bundleResourcePath.equals("/")) ? "" : bundleResourcePath);
    this.alias = ((alias == null) || (alias.equals("/")) ? null : alias);
    jspLoader = new JspClassLoader(bundle);
  }
  
  public JspServlet(Bundle bundle, String bundleResourcePath)
  {
    this(bundle, bundleResourcePath, null);
  }
  
  public void init(ServletConfig config)
    throws ServletException
  {
    ClassLoader original = Thread.currentThread().getContextClassLoader();
    try
    {
      Thread.currentThread().setContextClassLoader(jspLoader);
      jspServlet.init(new ServletConfigAdaptor(config));
      if (System.getSecurityManager() != null) {
        try
        {
          Field jspRuntimeContextField = jspServlet.getClass().getDeclaredField("rctxt");
          jspRuntimeContextField.setAccessible(true);
          Object jspRuntimeContext = jspRuntimeContextField.get(jspServlet);
          Field permissionCollectionField = jspRuntimeContext.getClass().getDeclaredField("permissionCollection");
          permissionCollectionField.setAccessible(true);
          permissionCollectionField.set(jspRuntimeContext, new BundlePermissionCollection(bundle));
        }
        catch (Exception localException)
        {
          throw new ServletException("Cannot initialize JSPServlet. Failed to set JSPRuntimeContext permission collection.");
        }
      }
    }
    finally
    {
      Thread.currentThread().setContextClassLoader(original);
    }
    Thread.currentThread().setContextClassLoader(original);
  }
  
  /* Error */
  public void destroy()
  {
    // Byte code:
    //   0: invokestatic 164	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   3: invokevirtual 162	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   6: astore_1
    //   7: invokestatic 164	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   10: aload_0
    //   11: getfield 154	org/eclipse/equinox/jsp/jasper/JspServlet:jspLoader	Ljava/net/URLClassLoader;
    //   14: invokevirtual 163	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   17: aload_0
    //   18: getfield 155	org/eclipse/equinox/jsp/jasper/JspServlet:jspServlet	Ljavax/servlet/Servlet;
    //   21: invokeinterface 175 1 0
    //   26: goto +13 -> 39
    //   29: astore_2
    //   30: invokestatic 164	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   33: aload_1
    //   34: invokevirtual 163	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   37: aload_2
    //   38: athrow
    //   39: invokestatic 164	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   42: aload_1
    //   43: invokevirtual 163	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   46: return
    // Line number table:
    //   Java source line #134	-> byte code offset #0
    //   Java source line #136	-> byte code offset #7
    //   Java source line #137	-> byte code offset #17
    //   Java source line #138	-> byte code offset #29
    //   Java source line #139	-> byte code offset #30
    //   Java source line #140	-> byte code offset #37
    //   Java source line #139	-> byte code offset #39
    //   Java source line #141	-> byte code offset #46
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	47	0	this	JspServlet
    //   6	37	1	original	ClassLoader
    //   29	9	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   7	29	29	finally
  }
  
  /* Error */
  public void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    throws ServletException, IOException
  {
    // Byte code:
    //   0: aload_1
    //   1: invokeinterface 180 1 0
    //   6: astore_3
    //   7: aload_3
    //   8: ifnull +22 -> 30
    //   11: aload_3
    //   12: ldc 3
    //   14: invokevirtual 160	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   17: ifeq +13 -> 30
    //   20: aload_2
    //   21: sipush 404
    //   24: invokeinterface 181 2 0
    //   29: return
    //   30: invokestatic 164	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   33: invokevirtual 162	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   36: astore 4
    //   38: invokestatic 164	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   41: aload_0
    //   42: getfield 154	org/eclipse/equinox/jsp/jasper/JspServlet:jspLoader	Ljava/net/URLClassLoader;
    //   45: invokevirtual 163	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   48: aload_0
    //   49: getfield 155	org/eclipse/equinox/jsp/jasper/JspServlet:jspServlet	Ljavax/servlet/Servlet;
    //   52: aload_1
    //   53: aload_2
    //   54: invokeinterface 179 3 0
    //   59: goto +16 -> 75
    //   62: astore 5
    //   64: invokestatic 164	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   67: aload 4
    //   69: invokevirtual 163	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   72: aload 5
    //   74: athrow
    //   75: invokestatic 164	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   78: aload 4
    //   80: invokevirtual 163	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   83: return
    // Line number table:
    //   Java source line #144	-> byte code offset #0
    //   Java source line #145	-> byte code offset #7
    //   Java source line #146	-> byte code offset #20
    //   Java source line #147	-> byte code offset #29
    //   Java source line #150	-> byte code offset #30
    //   Java source line #152	-> byte code offset #38
    //   Java source line #153	-> byte code offset #48
    //   Java source line #154	-> byte code offset #62
    //   Java source line #155	-> byte code offset #64
    //   Java source line #156	-> byte code offset #72
    //   Java source line #155	-> byte code offset #75
    //   Java source line #157	-> byte code offset #83
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	84	0	this	JspServlet
    //   0	84	1	request	javax.servlet.http.HttpServletRequest
    //   0	84	2	response	javax.servlet.http.HttpServletResponse
    //   6	6	3	pathInfo	String
    //   36	43	4	original	ClassLoader
    //   62	11	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   38	62	62	finally
  }
  
  public ServletConfig getServletConfig()
  {
    return jspServlet.getServletConfig();
  }
  
  public String getServletInfo()
  {
    return jspServlet.getServletInfo();
  }
  
  private class ServletConfigAdaptor
    implements ServletConfig
  {
    private ServletConfig config;
    private ServletContext context;
    
    public ServletConfigAdaptor(ServletConfig config)
    {
      this.config = config;
      context = new JspServlet.ServletContextAdaptor(JspServlet.this, config.getServletContext());
    }
    
    public String getInitParameter(String arg0)
    {
      return config.getInitParameter(arg0);
    }
    
    public Enumeration getInitParameterNames()
    {
      return config.getInitParameterNames();
    }
    
    public ServletContext getServletContext()
    {
      return context;
    }
    
    public String getServletName()
    {
      return config.getServletName();
    }
  }
  
  private class ServletContextAdaptor
    implements ServletContext
  {
    private ServletContext delegate;
    
    public ServletContextAdaptor(ServletContext delegate)
    {
      this.delegate = delegate;
    }
    
    public URL getResource(String name)
      throws MalformedURLException
    {
      if ((alias != null) && (name.startsWith(alias))) {
        name = name.substring(alias.length());
      }
      String resourceName = bundleResourcePath + name;
      int lastSlash = resourceName.lastIndexOf('/');
      if (lastSlash == -1) {
        return null;
      }
      String path = resourceName.substring(0, lastSlash);
      if (path.length() == 0) {
        path = "/";
      }
      String file = sanitizeEntryName(resourceName.substring(lastSlash + 1));
      Enumeration entryPaths = bundle.findEntries(path, file, false);
      if ((entryPaths != null) && (entryPaths.hasMoreElements())) {
        return (URL)entryPaths.nextElement();
      }
      return delegate.getResource(name);
    }
    
    private String sanitizeEntryName(String name)
    {
      StringBuffer buffer = null;
      for (int i = 0; i < name.length(); i++)
      {
        char c = name.charAt(i);
        switch (c)
        {
        case '*': 
        case '\\': 
          if (buffer == null)
          {
            buffer = new StringBuffer(name.length() + 16);
            buffer.append(name.substring(0, i));
          }
          buffer.append('\\').append(c);
          break;
        default: 
          if (buffer != null) {
            buffer.append(c);
          }
          break;
        }
      }
      return buffer == null ? name : buffer.toString();
    }
    
    public InputStream getResourceAsStream(String name)
    {
      try
      {
        URL resourceURL = getResource(name);
        if (resourceURL != null) {
          return resourceURL.openStream();
        }
      }
      catch (IOException e)
      {
        log("Error opening stream for resource '" + name + "'", e);
      }
      return null;
    }
    
    public Set getResourcePaths(String name)
    {
      Set result = delegate.getResourcePaths(name);
      Enumeration e = bundle.findEntries(bundleResourcePath + name, null, false);
      if (e != null)
      {
        if (result == null) {
          result = new HashSet();
        }
        while (e.hasMoreElements())
        {
          URL entryURL = (URL)e.nextElement();
          result.add(entryURL.getFile().substring(bundleResourcePath.length()));
        }
      }
      return result;
    }
    
    public RequestDispatcher getRequestDispatcher(String arg0)
    {
      return delegate.getRequestDispatcher(arg0);
    }
    
    public Object getAttribute(String arg0)
    {
      return delegate.getAttribute(arg0);
    }
    
    public Enumeration getAttributeNames()
    {
      return delegate.getAttributeNames();
    }
    
    public ServletContext getContext(String arg0)
    {
      return delegate.getContext(arg0);
    }
    
    public String getInitParameter(String arg0)
    {
      return delegate.getInitParameter(arg0);
    }
    
    public Enumeration getInitParameterNames()
    {
      return delegate.getInitParameterNames();
    }
    
    public int getMajorVersion()
    {
      return delegate.getMajorVersion();
    }
    
    public String getMimeType(String arg0)
    {
      return delegate.getMimeType(arg0);
    }
    
    public int getMinorVersion()
    {
      return delegate.getMinorVersion();
    }
    
    public RequestDispatcher getNamedDispatcher(String arg0)
    {
      return delegate.getNamedDispatcher(arg0);
    }
    
    public String getRealPath(String arg0)
    {
      return delegate.getRealPath(arg0);
    }
    
    public String getServerInfo()
    {
      return delegate.getServerInfo();
    }
    
    /**
     * @deprecated
     */
    public Servlet getServlet(String arg0)
      throws ServletException
    {
      return delegate.getServlet(arg0);
    }
    
    public String getServletContextName()
    {
      return delegate.getServletContextName();
    }
    
    /**
     * @deprecated
     */
    public Enumeration getServletNames()
    {
      return delegate.getServletNames();
    }
    
    /**
     * @deprecated
     */
    public Enumeration getServlets()
    {
      return delegate.getServlets();
    }
    
    /**
     * @deprecated
     */
    public void log(Exception arg0, String arg1)
    {
      delegate.log(arg0, arg1);
    }
    
    public void log(String arg0, Throwable arg1)
    {
      delegate.log(arg0, arg1);
    }
    
    public void log(String arg0)
    {
      delegate.log(arg0);
    }
    
    public void removeAttribute(String arg0)
    {
      delegate.removeAttribute(arg0);
    }
    
    public void setAttribute(String arg0, Object arg1)
    {
      delegate.setAttribute(arg0, arg1);
    }
    
    public String getContextPath()
    {
      try
      {
        Method getContextPathMethod = delegate.getClass().getMethod("getContextPath", null);
        return (String)getContextPathMethod.invoke(delegate, null);
      }
      catch (Exception localException) {}
      return null;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.jsp.jasper.JspServlet
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
1

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-2017. Infinite Loop Ltd