JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / httpserver / HttpServer.java
index 8797f33..a18d38d 100644 (file)
@@ -20,7 +20,6 @@
  */
 package jalview.httpserver;
 
-import jalview.bin.Instance;
 import jalview.rest.RestHandler;
 
 import java.net.BindException;
@@ -52,6 +51,36 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
  */
 public class HttpServer
 {
+  /*
+   * 'context root' - actually just prefixed to the path for each handler for
+   * now - see registerHandler
+   */
+  private static final String JALVIEW_PATH = "jalview";
+
+  /*
+   * Singleton instance of this server
+   */
+  private static HttpServer instance;
+
+  /*
+   * The Http server
+   */
+  private Server server;
+
+  /*
+   * Registered handlers for context paths
+   */
+  private HandlerCollection contextHandlers;
+
+  /*
+   * Lookup of ContextHandler by its wrapped handler
+   */
+  Map<Handler, ContextHandler> myHandlers = new HashMap<Handler, ContextHandler>();
+
+  /*
+   * The context root for the server
+   */
+  private URI contextRoot;
 
   /**
    * Returns the singleton instance of this class.
@@ -63,22 +92,22 @@ public class HttpServer
   {
     synchronized (HttpServer.class)
     {
-      Instance j = Instance.getInstance();
-      return (j.httpServer == null ? j.httpServer = new HttpServer()
-              : j.httpServer);
+      if (instance == null)
+      {
+        instance = new HttpServer();
+      }
+      return instance;
     }
   }
 
   /**
-   * Private constructor to enforce use of singleton; use getInstance().
+   * Private constructor to enforce use of singleton
    * 
    * @throws BindException
    *           if no free port can be assigned
    */
   private HttpServer() throws BindException
   {
-    // use getInstance()
-
     startServer();
 
     /*
@@ -87,32 +116,6 @@ public class HttpServer
     registerHandler(RestHandler.getInstance());
   }
 
-  /*
-   * 'context root' - actually just prefixed to the path for each handler for
-   * now - see registerHandler
-   */
-  private static final String JALVIEW_PATH = "jalview";
-
-  /*
-   * The Http server
-   */
-  private Server server;
-
-  /*
-   * Registered handlers for context paths
-   */
-  private HandlerCollection contextHandlers;
-
-  /*
-   * Lookup of ContextHandler by its wrapped handler
-   */
-  Map<Handler, ContextHandler> myHandlers = new HashMap<>();
-
-  /*
-   * The context root for the server
-   */
-  private URI contextRoot;
-
   /**
    * Start the http server
    *