org.eclipse.equinox.http.jetty_2.0.100.v20110502

16:43:55.119 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.http.jetty_2.0.100.v20110502.jar
package org.eclipse.equinox.http.jetty;

import java.security.Permission;
import java.util.Dictionary;
import org.eclipse.equinox.http.jetty.internal.Activator;
import org.osgi.service.cm.ConfigurationPermission;

public class JettyConfigurator
{
  private static final String PID_PREFIX = "org.eclipse.equinox.http.jetty.JettyConfigurator.";
  private static Permission configurationPermission = new ConfigurationPermission("*", "configure");
  
  public static void startServer(String id, Dictionary settings)
    throws Exception
  {
    checkConfigurationPermission();
    String pid = "org.eclipse.equinox.http.jetty.JettyConfigurator." + id;
    settings.put("service.pid", pid);
    Activator.startServer(pid, settings);
  }
  
  public static void stopServer(String id)
    throws Exception
  {
    checkConfigurationPermission();
    Activator.stopServer("org.eclipse.equinox.http.jetty.JettyConfigurator." + id);
  }
  
  private static void checkConfigurationPermission()
    throws SecurityException
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPermission(configurationPermission);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.jetty.JettyConfigurator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.http.jetty;

public abstract interface JettyConstants
{
  public static final String HTTP_ENABLED = "http.enabled";
  public static final String HTTP_PORT = "http.port";
  public static final String HTTP_HOST = "http.host";
  public static final String HTTP_NIO = "http.nio";
  public static final String HTTPS_ENABLED = "https.enabled";
  public static final String HTTPS_HOST = "https.host";
  public static final String HTTPS_PORT = "https.port";
  public static final String SSL_KEYSTORE = "ssl.keystore";
  public static final String SSL_PASSWORD = "ssl.password";
  public static final String SSL_KEYPASSWORD = "ssl.keypassword";
  public static final String SSL_NEEDCLIENTAUTH = "ssl.needclientauth";
  public static final String SSL_WANTCLIENTAUTH = "ssl.wantclientauth";
  public static final String SSL_PROTOCOL = "ssl.protocol";
  public static final String SSL_ALGORITHM = "ssl.algorithm";
  public static final String SSL_KEYSTORETYPE = "ssl.keystoretype";
  public static final String CONTEXT_PATH = "context.path";
  public static final String CONTEXT_SESSIONINACTIVEINTERVAL = "context.sessioninactiveinterval";
  public static final String CUSTOMIZER_CLASS = "customizer.class";
  public static final String OTHER_INFO = "other.info";
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.jetty.JettyConstants
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.http.jetty;

import java.util.Dictionary;

public abstract class JettyCustomizer
{
  public Object customizeContext(Object context, Dictionary settings)
  {
    return context;
  }
  
  public Object customizeHttpConnector(Object connector, Dictionary settings)
  {
    return connector;
  }
  
  public Object customizeHttpsConnector(Object connector, Dictionary settings)
  {
    return connector;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.jetty.JettyCustomizer
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.http.jetty.internal;

import java.io.File;
import java.lang.reflect.Method;
import java.util.Dictionary;
import java.util.Hashtable;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.ManagedServiceFactory;
import org.osgi.service.startlevel.StartLevel;

public class Activator
  implements BundleActivator
{
  private static final String JETTY_WORK_DIR = "jettywork";
  private static final String DEFAULT_PID = "default";
  private static final String MANAGED_SERVICE_FACTORY_PID = "org.eclipse.equinox.http.jetty.config";
  private static final String ORG_OSGI_SERVICE_HTTP_PORT = "org.osgi.service.http.port";
  private static final String ORG_OSGI_SERVICE_HTTP_PORT_SECURE = "org.osgi.service.http.port.secure";
  private static final String AUTOSTART = "org.eclipse.equinox.http.jetty.autostart";
  private static final String LOG_STDERR_THRESHOLD = "org.eclipse.equinox.http.jetty.log.stderr.threshold";
  private static HttpServerManager staticServerManager;
  private HttpServerManager httpServerManager;
  private ServiceRegistration registration;
  
  public void start(BundleContext context)
    throws Exception
  {
    File jettyWorkDir = new File(context.getDataFile(""), "jettywork");
    jettyWorkDir.mkdir();
    setStdErrLogThreshold(context.getProperty("org.eclipse.equinox.http.jetty.log.stderr.threshold"));
    httpServerManager = new HttpServerManager(jettyWorkDir);
    
    String autostart = context.getProperty("org.eclipse.equinox.http.jetty.autostart");
    if (((autostart == null) || (Boolean.valueOf(autostart).booleanValue())) && (!isBundleActivationPolicyUsed(context)))
    {
      Dictionary defaultSettings = createDefaultSettings(context);
      httpServerManager.updated("default", defaultSettings);
    }
    Dictionary dictionary = new Hashtable();
    dictionary.put("service.pid", "org.eclipse.equinox.http.jetty.config");
    
    registration = context.registerService(ManagedServiceFactory.class.getName(), httpServerManager, dictionary);
    setStaticServerManager(httpServerManager);
  }
  
  private void setStdErrLogThreshold(String property)
  {
    try
    {
      Class clazz = Class.forName("org.slf4j.Logger");
      Method method = clazz.getMethod("setThresholdLogger", new Class[] { String.class });
      method.invoke(null, new Object[] { property });
    }
    catch (Throwable localThrowable) {}
  }
  
  private boolean isBundleActivationPolicyUsed(BundleContext context)
  {
    ServiceReference reference = context.getServiceReference(StartLevel.class.getName());
    StartLevel sl = reference != null ? (StartLevel)context.getService(reference) : null;
    if (sl != null) {
      try
      {
        Bundle bundle = context.getBundle();
        Method isBundleActivationPolicyUsed = tmp76_73.getMethod("isBundleActivationPolicyUsed", new Class[] { Bundle.class });
        Boolean result = (Boolean)isBundleActivationPolicyUsed.invoke(sl, new Object[] { bundle });
        return result.booleanValue();
      }
      catch (Exception localException) {}finally
      {
        context.ungetService(reference);
      }
    }
    return false;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    setStaticServerManager(null);
    registration.unregister();
    registration = null;
    
    httpServerManager.shutdown();
    httpServerManager = null;
  }
  
  private Dictionary createDefaultSettings(BundleContext context)
  {
    Dictionary defaultSettings = new Hashtable();
    
    defaultSettings.put("service.pid", "default");
    
    String httpEnabledProperty = context.getProperty("org.eclipse.equinox.http.jetty.http.enabled");
    Boolean httpEnabled = httpEnabledProperty == null ? Boolean.TRUE : new Boolean(httpEnabledProperty);
    defaultSettings.put("http.enabled", httpEnabled);
    
    String httpPortProperty = context.getProperty("org.eclipse.equinox.http.jetty.http.port");
    if (httpPortProperty == null) {
      httpPortProperty = context.getProperty("org.osgi.service.http.port");
    }
    int httpPort = 80;
    if (httpPortProperty != null) {
      try
      {
        httpPort = Integer.parseInt(httpPortProperty);
      }
      catch (NumberFormatException localNumberFormatException1) {}
    }
    defaultSettings.put("http.port", new Integer(httpPort));
    
    String httpHost = context.getProperty("org.eclipse.equinox.http.jetty.http.host");
    if (httpHost != null) {
      defaultSettings.put("http.host", httpHost);
    }
    Boolean httpsEnabled = new Boolean(context.getProperty("org.eclipse.equinox.http.jetty.https.enabled"));
    defaultSettings.put("https.enabled", httpsEnabled);
    if (httpsEnabled.booleanValue())
    {
      String httpsPortProperty = context.getProperty("org.eclipse.equinox.http.jetty.https.port");
      if (httpsPortProperty == null) {
        httpsPortProperty = context.getProperty("org.osgi.service.http.port.secure");
      }
      int httpsPort = 443;
      if (httpsPortProperty != null) {
        try
        {
          httpsPort = Integer.parseInt(httpsPortProperty);
        }
        catch (NumberFormatException localNumberFormatException2) {}
      }
      defaultSettings.put("https.port", new Integer(httpsPort));
      
      String httpsHost = context.getProperty("org.eclipse.equinox.http.jetty.https.host");
      if (httpsHost != null) {
        defaultSettings.put("https.host", httpsHost);
      }
      String keystore = context.getProperty("org.eclipse.equinox.http.jetty.ssl.keystore");
      if (keystore != null) {
        defaultSettings.put("ssl.keystore", keystore);
      }
      String password = context.getProperty("org.eclipse.equinox.http.jetty.ssl.password");
      if (password != null) {
        defaultSettings.put("ssl.password", password);
      }
      String keypassword = context.getProperty("org.eclipse.equinox.http.jetty.ssl.keypassword");
      if (keypassword != null) {
        defaultSettings.put("ssl.keypassword", keypassword);
      }
      String needclientauth = context.getProperty("org.eclipse.equinox.http.jetty.ssl.needclientauth");
      if (needclientauth != null) {
        defaultSettings.put("ssl.needclientauth", new Boolean(needclientauth));
      }
      String wantclientauth = context.getProperty("org.eclipse.equinox.http.jetty.ssl.wantclientauth");
      if (wantclientauth != null) {
        defaultSettings.put("ssl.wantclientauth", new Boolean(wantclientauth));
      }
      String protocol = context.getProperty("org.eclipse.equinox.http.jetty.ssl.protocol");
      if (protocol != null) {
        defaultSettings.put("ssl.protocol", protocol);
      }
      String algorithm = context.getProperty("org.eclipse.equinox.http.jetty.ssl.algorithm");
      if (algorithm != null) {
        defaultSettings.put("ssl.algorithm", algorithm);
      }
      String keystoretype = context.getProperty("org.eclipse.equinox.http.jetty.ssl.keystoretype");
      if (keystoretype != null) {
        defaultSettings.put("ssl.keystoretype", keystoretype);
      }
    }
    String contextpath = context.getProperty("org.eclipse.equinox.http.jetty.context.path");
    if (contextpath != null) {
      defaultSettings.put("context.path", contextpath);
    }
    String sessionInactiveInterval = context.getProperty("org.eclipse.equinox.http.jetty.context.sessioninactiveinterval");
    if (sessionInactiveInterval != null) {
      try
      {
        defaultSettings.put("context.sessioninactiveinterval", new Integer(sessionInactiveInterval));
      }
      catch (NumberFormatException localNumberFormatException3) {}
    }
    String otherInfo = context.getProperty("org.eclipse.equinox.http.jetty.other.info");
    if (otherInfo != null) {
      defaultSettings.put("other.info", otherInfo);
    }
    String customizerClass = context.getProperty("org.eclipse.equinox.http.jetty.customizer.class");
    if (customizerClass != null) {
      defaultSettings.put("customizer.class", customizerClass);
    }
    return defaultSettings;
  }
  
  public static synchronized void startServer(String pid, Dictionary settings)
    throws Exception
  {
    if (staticServerManager == null) {
      throw new IllegalStateException("Inactive");
    }
    staticServerManager.updated(pid, settings);
  }
  
  public static synchronized void stopServer(String pid)
    throws Exception
  {
    if (staticServerManager != null) {
      staticServerManager.deleted(pid);
    }
  }
  
  private static synchronized void setStaticServerManager(HttpServerManager httpServerManager)
  {
    staticServerManager = httpServerManager;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.jetty.internal.Activator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.http.jetty.internal;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import org.eclipse.equinox.http.servlet.HttpServiceServlet;

public class HttpServerManager$InternalHttpServiceServlet
  implements Servlet
{
  private Servlet httpServiceServlet = new HttpServiceServlet();
  private ClassLoader contextLoader;
  
  /* Error */
  public void init(ServletConfig config)
    throws javax.servlet.ServletException
  {
    // Byte code:
    //   0: aload_1
    //   1: invokeinterface 88 1 0
    //   6: astore_2
    //   7: aload_0
    //   8: aload_2
    //   9: ldc 1
    //   11: invokeinterface 89 2 0
    //   16: checkcast 36	java/lang/ClassLoader
    //   19: putfield 76	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:contextLoader	Ljava/lang/ClassLoader;
    //   22: invokestatic 81	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   25: astore_3
    //   26: aload_3
    //   27: invokevirtual 79	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   30: astore 4
    //   32: aload_3
    //   33: aload_0
    //   34: getfield 76	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:contextLoader	Ljava/lang/ClassLoader;
    //   37: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   40: aload_0
    //   41: getfield 77	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:httpServiceServlet	Ljavax/servlet/Servlet;
    //   44: aload_1
    //   45: invokeinterface 86 2 0
    //   50: goto +14 -> 64
    //   53: astore 5
    //   55: aload_3
    //   56: aload 4
    //   58: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   61: aload 5
    //   63: athrow
    //   64: aload_3
    //   65: aload 4
    //   67: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   70: return
    // Line number table:
    //   Java source line #287	-> byte code offset #0
    //   Java source line #288	-> byte code offset #7
    //   Java source line #290	-> byte code offset #22
    //   Java source line #291	-> byte code offset #26
    //   Java source line #292	-> byte code offset #32
    //   Java source line #294	-> byte code offset #40
    //   Java source line #295	-> byte code offset #53
    //   Java source line #296	-> byte code offset #55
    //   Java source line #297	-> byte code offset #61
    //   Java source line #296	-> byte code offset #64
    //   Java source line #298	-> byte code offset #70
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	71	0	this	InternalHttpServiceServlet
    //   0	71	1	config	ServletConfig
    //   6	3	2	context	javax.servlet.ServletContext
    //   25	40	3	thread	Thread
    //   30	36	4	current	ClassLoader
    //   53	9	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   40	53	53	finally
  }
  
  /* Error */
  public void destroy()
  {
    // Byte code:
    //   0: invokestatic 81	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   3: astore_1
    //   4: aload_1
    //   5: invokevirtual 79	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   8: astore_2
    //   9: aload_1
    //   10: aload_0
    //   11: getfield 76	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:contextLoader	Ljava/lang/ClassLoader;
    //   14: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   17: aload_0
    //   18: getfield 77	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:httpServiceServlet	Ljavax/servlet/Servlet;
    //   21: invokeinterface 83 1 0
    //   26: goto +11 -> 37
    //   29: astore_3
    //   30: aload_1
    //   31: aload_2
    //   32: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   35: aload_3
    //   36: athrow
    //   37: aload_1
    //   38: aload_2
    //   39: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   42: aload_0
    //   43: aconst_null
    //   44: putfield 76	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:contextLoader	Ljava/lang/ClassLoader;
    //   47: return
    // Line number table:
    //   Java source line #301	-> byte code offset #0
    //   Java source line #302	-> byte code offset #4
    //   Java source line #303	-> byte code offset #9
    //   Java source line #305	-> byte code offset #17
    //   Java source line #306	-> byte code offset #29
    //   Java source line #307	-> byte code offset #30
    //   Java source line #308	-> byte code offset #35
    //   Java source line #307	-> byte code offset #37
    //   Java source line #309	-> byte code offset #42
    //   Java source line #310	-> byte code offset #47
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	48	0	this	InternalHttpServiceServlet
    //   3	35	1	thread	Thread
    //   8	31	2	current	ClassLoader
    //   29	7	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   17	29	29	finally
  }
  
  /* Error */
  public void service(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res)
    throws javax.servlet.ServletException, java.io.IOException
  {
    // Byte code:
    //   0: invokestatic 81	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   3: astore_3
    //   4: aload_3
    //   5: invokevirtual 79	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   8: astore 4
    //   10: aload_3
    //   11: aload_0
    //   12: getfield 76	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:contextLoader	Ljava/lang/ClassLoader;
    //   15: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   18: aload_0
    //   19: getfield 77	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:httpServiceServlet	Ljavax/servlet/Servlet;
    //   22: aload_1
    //   23: aload_2
    //   24: invokeinterface 87 3 0
    //   29: goto +14 -> 43
    //   32: astore 5
    //   34: aload_3
    //   35: aload 4
    //   37: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   40: aload 5
    //   42: athrow
    //   43: aload_3
    //   44: aload 4
    //   46: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   49: return
    // Line number table:
    //   Java source line #313	-> byte code offset #0
    //   Java source line #314	-> byte code offset #4
    //   Java source line #315	-> byte code offset #10
    //   Java source line #317	-> byte code offset #18
    //   Java source line #318	-> byte code offset #32
    //   Java source line #319	-> byte code offset #34
    //   Java source line #320	-> byte code offset #40
    //   Java source line #319	-> byte code offset #43
    //   Java source line #321	-> byte code offset #49
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	50	0	this	InternalHttpServiceServlet
    //   0	50	1	req	javax.servlet.ServletRequest
    //   0	50	2	res	javax.servlet.ServletResponse
    //   3	41	3	thread	Thread
    //   8	37	4	current	ClassLoader
    //   32	9	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   18	32	32	finally
  }
  
  public ServletConfig getServletConfig()
  {
    return httpServiceServlet.getServletConfig();
  }
  
  public String getServletInfo()
  {
    return httpServiceServlet.getServletInfo();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.jetty.internal.HttpServerManager.InternalHttpServiceServlet
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.http.jetty.internal;

import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import org.eclipse.equinox.http.jetty.JettyCustomizer;
import org.eclipse.equinox.http.servlet.HttpServiceServlet;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.security.SslSocketConnector;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.HashSessionManager;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.jetty.servlet.SessionHandler;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedServiceFactory;

public class HttpServerManager
  implements ManagedServiceFactory
{
  private static final String CONTEXT_TEMPDIR = "javax.servlet.context.tempdir";
  private static final String DIR_PREFIX = "pid_";
  private static final String INTERNAL_CONTEXT_CLASSLOADER = "org.eclipse.equinox.http.jetty.internal.ContextClassLoader";
  private Map servers = new HashMap();
  private File workDir;
  
  public HttpServerManager(File workDir)
  {
    this.workDir = workDir;
  }
  
  public synchronized void deleted(String pid)
  {
    Server server = (Server)servers.remove(pid);
    if (server != null)
    {
      try
      {
        server.stop();
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
      File contextWorkDir = new File(workDir, "pid_" + pid.hashCode());
      deleteDirectory(contextWorkDir);
    }
  }
  
  public String getName()
  {
    return getClass().getName();
  }
  
  public synchronized void updated(String pid, Dictionary dictionary)
    throws ConfigurationException
  {
    deleted(pid);
    Server server = new Server();
    
    JettyCustomizer customizer = createJettyCustomizer(dictionary);
    
    Connector httpConnector = createHttpConnector(dictionary);
    if (customizer != null) {
      httpConnector = (Connector)customizer.customizeHttpConnector(httpConnector, dictionary);
    }
    if (httpConnector != null) {
      server.addConnector(httpConnector);
    }
    Connector httpsConnector = createHttpsConnector(dictionary);
    if (customizer != null) {
      httpsConnector = (Connector)customizer.customizeHttpsConnector(httpsConnector, dictionary);
    }
    if (httpsConnector != null) {
      server.addConnector(httpsConnector);
    }
    ServletHolder holder = new ServletHolder(new InternalHttpServiceServlet());
    holder.setInitOrder(0);
    holder.setInitParameter("service.vendor", "Eclipse.org");
    holder.setInitParameter("service.description", "Equinox Jetty-based Http Service");
    if (httpConnector != null)
    {
      int port = httpConnector.getLocalPort();
      if (port == -1) {
        port = httpConnector.getPort();
      }
      holder.setInitParameter("http.port", Integer.toString(port));
    }
    if (httpsConnector != null)
    {
      int port = httpsConnector.getLocalPort();
      if (port == -1) {
        port = httpsConnector.getPort();
      }
      holder.setInitParameter("https.port", Integer.toString(port));
    }
    String otherInfo = (String)dictionary.get("other.info");
    if (otherInfo != null) {
      holder.setInitParameter("other.info", otherInfo);
    }
    Context httpContext = createHttpContext(dictionary);
    if (customizer != null) {
      httpContext = (Context)customizer.customizeContext(httpContext, dictionary);
    }
    httpContext.addServlet(holder, "/*");
    server.addHandler(httpContext);
    try
    {
      server.start();
    }
    catch (Exception e)
    {
      throw new ConfigurationException(pid, e.getMessage(), e);
    }
    servers.put(pid, server);
  }
  
  public synchronized void shutdown()
    throws Exception
  {
    for (Iterator it = servers.values().iterator(); it.hasNext();)
    {
      Server server = (Server)it.next();
      server.stop();
    }
    servers.clear();
  }
  
  private Connector createHttpConnector(Dictionary dictionary)
  {
    Boolean httpEnabled = (Boolean)dictionary.get("http.enabled");
    if ((httpEnabled != null) && (!httpEnabled.booleanValue())) {
      return null;
    }
    Integer httpPort = (Integer)dictionary.get("http.port");
    if (httpPort == null) {
      return null;
    }
    Boolean nioEnabled = (Boolean)dictionary.get("http.nio");
    if (nioEnabled == null) {
      nioEnabled = getDefaultNIOEnablement();
    }
    Connector connector;
    Connector connector;
    if (nioEnabled.booleanValue()) {
      connector = new SelectChannelConnector();
    } else {
      connector = new SocketConnector();
    }
    connector.setPort(httpPort.intValue());
    
    String httpHost = (String)dictionary.get("http.host");
    if (httpHost != null) {
      connector.setHost(httpHost);
    }
    if (connector.getPort() == 0) {
      try
      {
        connector.open();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
    return connector;
  }
  
  private Boolean getDefaultNIOEnablement()
  {
    Properties systemProperties = System.getProperties();
    String javaVendor = systemProperties.getProperty("java.vendor", "");
    if (javaVendor.equals("IBM Corporation"))
    {
      String javaVersion = systemProperties.getProperty("java.version", "");
      if (javaVersion.startsWith("1.4")) {
        return Boolean.FALSE;
      }
      if (javaVersion.equals("1.6.0"))
      {
        String jclVersion = systemProperties.getProperty("java.jcl.version", "");
        if (jclVersion.startsWith("2007")) {
          return Boolean.FALSE;
        }
        if ((jclVersion.startsWith("2008")) && (!jclVersion.startsWith("200811")) && (!jclVersion.startsWith("200812"))) {
          return Boolean.FALSE;
        }
      }
    }
    return Boolean.TRUE;
  }
  
  private Connector createHttpsConnector(Dictionary dictionary)
  {
    Boolean httpsEnabled = (Boolean)dictionary.get("https.enabled");
    if ((httpsEnabled == null) || (!httpsEnabled.booleanValue())) {
      return null;
    }
    Integer httpsPort = (Integer)dictionary.get("https.port");
    if (httpsPort == null) {
      return null;
    }
    SslSocketConnector sslConnector = new SslSocketConnector();
    sslConnector.setPort(httpsPort.intValue());
    
    String httpsHost = (String)dictionary.get("https.host");
    if (httpsHost != null) {
      sslConnector.setHost(httpsHost);
    }
    String keyStore = (String)dictionary.get("ssl.keystore");
    if (keyStore != null) {
      sslConnector.setKeystore(keyStore);
    }
    String password = (String)dictionary.get("ssl.password");
    if (password != null) {
      sslConnector.setPassword(password);
    }
    String keyPassword = (String)dictionary.get("ssl.keypassword");
    if (keyPassword != null) {
      sslConnector.setKeyPassword(keyPassword);
    }
    Object needClientAuth = dictionary.get("ssl.needclientauth");
    if (needClientAuth != null)
    {
      if ((needClientAuth instanceof String)) {
        needClientAuth = Boolean.valueOf((String)needClientAuth);
      }
      sslConnector.setNeedClientAuth(((Boolean)needClientAuth).booleanValue());
    }
    Object wantClientAuth = dictionary.get("ssl.wantclientauth");
    if (wantClientAuth != null)
    {
      if ((wantClientAuth instanceof String)) {
        wantClientAuth = Boolean.valueOf((String)wantClientAuth);
      }
      sslConnector.setWantClientAuth(((Boolean)wantClientAuth).booleanValue());
    }
    String protocol = (String)dictionary.get("ssl.protocol");
    if (protocol != null) {
      sslConnector.setProtocol(protocol);
    }
    String keystoreType = (String)dictionary.get("ssl.keystoretype");
    if (keystoreType != null) {
      sslConnector.setKeystoreType(keystoreType);
    }
    if (sslConnector.getPort() == 0) {
      try
      {
        sslConnector.open();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
    return sslConnector;
  }
  
  private Context createHttpContext(Dictionary dictionary)
  {
    Context httpContext = new Context();
    httpContext.setAttribute("org.eclipse.equinox.http.jetty.internal.ContextClassLoader", Thread.currentThread().getContextClassLoader());
    httpContext.setClassLoader(getClass().getClassLoader());
    
    String contextPathProperty = (String)dictionary.get("context.path");
    if (contextPathProperty == null) {
      contextPathProperty = "/";
    }
    httpContext.setContextPath(contextPathProperty);
    
    File contextWorkDir = new File(workDir, "pid_" + dictionary.get("service.pid").hashCode());
    contextWorkDir.mkdir();
    httpContext.setAttribute("javax.servlet.context.tempdir", contextWorkDir);
    
    HashSessionManager sessionManager = new HashSessionManager();
    Integer sessionInactiveInterval = (Integer)dictionary.get("context.sessioninactiveinterval");
    if (sessionInactiveInterval != null) {
      sessionManager.setMaxInactiveInterval(sessionInactiveInterval.intValue());
    }
    httpContext.setSessionHandler(new SessionHandler(sessionManager));
    
    return httpContext;
  }
  
  private JettyCustomizer createJettyCustomizer(Dictionary dictionary)
  {
    String customizerClass = (String)dictionary.get("customizer.class");
    if (customizerClass == null) {
      return null;
    }
    try
    {
      return (JettyCustomizer)Class.forName(customizerClass).newInstance();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return null;
  }
  
  public static class InternalHttpServiceServlet
    implements Servlet
  {
    private Servlet httpServiceServlet = new HttpServiceServlet();
    private ClassLoader contextLoader;
    
    /* Error */
    public void init(ServletConfig config)
      throws javax.servlet.ServletException
    {
      // Byte code:
      //   0: aload_1
      //   1: invokeinterface 88 1 0
      //   6: astore_2
      //   7: aload_0
      //   8: aload_2
      //   9: ldc 1
      //   11: invokeinterface 89 2 0
      //   16: checkcast 36	java/lang/ClassLoader
      //   19: putfield 76	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:contextLoader	Ljava/lang/ClassLoader;
      //   22: invokestatic 81	java/lang/Thread:currentThread	()Ljava/lang/Thread;
      //   25: astore_3
      //   26: aload_3
      //   27: invokevirtual 79	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
      //   30: astore 4
      //   32: aload_3
      //   33: aload_0
      //   34: getfield 76	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:contextLoader	Ljava/lang/ClassLoader;
      //   37: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
      //   40: aload_0
      //   41: getfield 77	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:httpServiceServlet	Ljavax/servlet/Servlet;
      //   44: aload_1
      //   45: invokeinterface 86 2 0
      //   50: goto +14 -> 64
      //   53: astore 5
      //   55: aload_3
      //   56: aload 4
      //   58: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
      //   61: aload 5
      //   63: athrow
      //   64: aload_3
      //   65: aload 4
      //   67: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
      //   70: return
      // Line number table:
      //   Java source line #287	-> byte code offset #0
      //   Java source line #288	-> byte code offset #7
      //   Java source line #290	-> byte code offset #22
      //   Java source line #291	-> byte code offset #26
      //   Java source line #292	-> byte code offset #32
      //   Java source line #294	-> byte code offset #40
      //   Java source line #295	-> byte code offset #53
      //   Java source line #296	-> byte code offset #55
      //   Java source line #297	-> byte code offset #61
      //   Java source line #296	-> byte code offset #64
      //   Java source line #298	-> byte code offset #70
      // Local variable table:
      //   start	length	slot	name	signature
      //   0	71	0	this	InternalHttpServiceServlet
      //   0	71	1	config	ServletConfig
      //   6	3	2	context	javax.servlet.ServletContext
      //   25	40	3	thread	Thread
      //   30	36	4	current	ClassLoader
      //   53	9	5	localObject	Object
      // Exception table:
      //   from	to	target	type
      //   40	53	53	finally
    }
    
    /* Error */
    public void destroy()
    {
      // Byte code:
      //   0: invokestatic 81	java/lang/Thread:currentThread	()Ljava/lang/Thread;
      //   3: astore_1
      //   4: aload_1
      //   5: invokevirtual 79	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
      //   8: astore_2
      //   9: aload_1
      //   10: aload_0
      //   11: getfield 76	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:contextLoader	Ljava/lang/ClassLoader;
      //   14: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
      //   17: aload_0
      //   18: getfield 77	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:httpServiceServlet	Ljavax/servlet/Servlet;
      //   21: invokeinterface 83 1 0
      //   26: goto +11 -> 37
      //   29: astore_3
      //   30: aload_1
      //   31: aload_2
      //   32: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
      //   35: aload_3
      //   36: athrow
      //   37: aload_1
      //   38: aload_2
      //   39: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
      //   42: aload_0
      //   43: aconst_null
      //   44: putfield 76	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:contextLoader	Ljava/lang/ClassLoader;
      //   47: return
      // Line number table:
      //   Java source line #301	-> byte code offset #0
      //   Java source line #302	-> byte code offset #4
      //   Java source line #303	-> byte code offset #9
      //   Java source line #305	-> byte code offset #17
      //   Java source line #306	-> byte code offset #29
      //   Java source line #307	-> byte code offset #30
      //   Java source line #308	-> byte code offset #35
      //   Java source line #307	-> byte code offset #37
      //   Java source line #309	-> byte code offset #42
      //   Java source line #310	-> byte code offset #47
      // Local variable table:
      //   start	length	slot	name	signature
      //   0	48	0	this	InternalHttpServiceServlet
      //   3	35	1	thread	Thread
      //   8	31	2	current	ClassLoader
      //   29	7	3	localObject	Object
      // Exception table:
      //   from	to	target	type
      //   17	29	29	finally
    }
    
    /* Error */
    public void service(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res)
      throws javax.servlet.ServletException, IOException
    {
      // Byte code:
      //   0: invokestatic 81	java/lang/Thread:currentThread	()Ljava/lang/Thread;
      //   3: astore_3
      //   4: aload_3
      //   5: invokevirtual 79	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
      //   8: astore 4
      //   10: aload_3
      //   11: aload_0
      //   12: getfield 76	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:contextLoader	Ljava/lang/ClassLoader;
      //   15: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
      //   18: aload_0
      //   19: getfield 77	org/eclipse/equinox/http/jetty/internal/HttpServerManager$InternalHttpServiceServlet:httpServiceServlet	Ljavax/servlet/Servlet;
      //   22: aload_1
      //   23: aload_2
      //   24: invokeinterface 87 3 0
      //   29: goto +14 -> 43
      //   32: astore 5
      //   34: aload_3
      //   35: aload 4
      //   37: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
      //   40: aload 5
      //   42: athrow
      //   43: aload_3
      //   44: aload 4
      //   46: invokevirtual 80	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
      //   49: return
      // Line number table:
      //   Java source line #313	-> byte code offset #0
      //   Java source line #314	-> byte code offset #4
      //   Java source line #315	-> byte code offset #10
      //   Java source line #317	-> byte code offset #18
      //   Java source line #318	-> byte code offset #32
      //   Java source line #319	-> byte code offset #34
      //   Java source line #320	-> byte code offset #40
      //   Java source line #319	-> byte code offset #43
      //   Java source line #321	-> byte code offset #49
      // Local variable table:
      //   start	length	slot	name	signature
      //   0	50	0	this	InternalHttpServiceServlet
      //   0	50	1	req	javax.servlet.ServletRequest
      //   0	50	2	res	javax.servlet.ServletResponse
      //   3	41	3	thread	Thread
      //   8	37	4	current	ClassLoader
      //   32	9	5	localObject	Object
      // Exception table:
      //   from	to	target	type
      //   18	32	32	finally
    }
    
    public ServletConfig getServletConfig()
    {
      return httpServiceServlet.getServletConfig();
    }
    
    public String getServletInfo()
    {
      return httpServiceServlet.getServletInfo();
    }
  }
  
  private static boolean deleteDirectory(File directory)
  {
    if ((directory.exists()) && (directory.isDirectory()))
    {
      File[] files = directory.listFiles();
      for (int i = 0; i < files.length; i++) {
        if (files[i].isDirectory()) {
          deleteDirectory(files[i]);
        } else {
          files[i].delete();
        }
      }
    }
    return directory.delete();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.http.jetty.internal.HttpServerManager
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.slf4j;

import org.mortbay.log.StdErrLog;

public class Logger
  extends StdErrLog
{
  private static int DEBUG = 0;
  private static int INFO = 1;
  private static int WARN = 2;
  private static int ERROR = 3;
  private static int OFF = 4;
  private static volatile int threshold = WARN;
  private static Logger root;
  private String localName;
  static Class class$0;
  
  public static synchronized Logger getRootLogger()
  {
    if (root != null) {
      return root;
    }
    root = new Logger(null);
    return root;
  }
  
  /* Error */
  public static void setThresholdLogger(String property)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokestatic 156	org/slf4j/Logger:parseThresholdProperty	(Ljava/lang/String;)I
    //   4: putstatic 132	org/slf4j/Logger:threshold	I
    //   7: invokestatic 145	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   10: invokevirtual 143	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   13: astore_1
    //   14: invokestatic 145	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   17: getstatic 133	org/slf4j/Logger:class$0	Ljava/lang/Class;
    //   20: dup
    //   21: ifnonnull +28 -> 49
    //   24: pop
    //   25: ldc 6
    //   27: invokestatic 137	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   30: dup
    //   31: putstatic 133	org/slf4j/Logger:class$0	Ljava/lang/Class;
    //   34: goto +15 -> 49
    //   37: new 69	java/lang/NoClassDefFoundError
    //   
1 2

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