JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / httpserver / HttpServer.java
index f2daf2b..a18d38d 100644 (file)
@@ -20,8 +20,6 @@
  */
 package jalview.httpserver;
 
-import jalview.bin.ApplicationSingletonProvider;
-import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.rest.RestHandler;
 
 import java.net.BindException;
@@ -51,7 +49,7 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
  * @author gmcarstairs
  * @see http://eclipse.org/jetty/documentation/current/embedding-jetty.html
  */
-public class HttpServer implements ApplicationSingletonI
+public class HttpServer
 {
   /*
    * 'context root' - actually just prefixed to the path for each handler for
@@ -60,6 +58,11 @@ public class HttpServer implements ApplicationSingletonI
   private static final String JALVIEW_PATH = "jalview";
 
   /*
+   * Singleton instance of this server
+   */
+  private static HttpServer instance;
+
+  /*
    * The Http server
    */
   private Server server;
@@ -72,7 +75,7 @@ public class HttpServer implements ApplicationSingletonI
   /*
    * Lookup of ContextHandler by its wrapped handler
    */
-  Map<Handler, ContextHandler> myHandlers = new HashMap<>();
+  Map<Handler, ContextHandler> myHandlers = new HashMap<Handler, ContextHandler>();
 
   /*
    * The context root for the server
@@ -89,20 +92,22 @@ public class HttpServer implements ApplicationSingletonI
   {
     synchronized (HttpServer.class)
     {
-      return (HttpServer) ApplicationSingletonProvider.getInstance(HttpServer.class);
+      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();
 
     /*