JAL-3210 Improvements to eclipse detection. New src tree and SwingJS updated from...
[jalview.git] / src / jalview / httpserver / HttpServer.java
index a18d38d..f2daf2b 100644 (file)
@@ -20,6 +20,8 @@
  */
 package jalview.httpserver;
 
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.rest.RestHandler;
 
 import java.net.BindException;
@@ -49,7 +51,7 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
  * @author gmcarstairs
  * @see http://eclipse.org/jetty/documentation/current/embedding-jetty.html
  */
-public class HttpServer
+public class HttpServer implements ApplicationSingletonI
 {
   /*
    * 'context root' - actually just prefixed to the path for each handler for
@@ -58,11 +60,6 @@ public class HttpServer
   private static final String JALVIEW_PATH = "jalview";
 
   /*
-   * Singleton instance of this server
-   */
-  private static HttpServer instance;
-
-  /*
    * The Http server
    */
   private Server server;
@@ -75,7 +72,7 @@ public class HttpServer
   /*
    * Lookup of ContextHandler by its wrapped handler
    */
-  Map<Handler, ContextHandler> myHandlers = new HashMap<Handler, ContextHandler>();
+  Map<Handler, ContextHandler> myHandlers = new HashMap<>();
 
   /*
    * The context root for the server
@@ -92,22 +89,20 @@ public class HttpServer
   {
     synchronized (HttpServer.class)
     {
-      if (instance == null)
-      {
-        instance = new HttpServer();
-      }
-      return instance;
+      return (HttpServer) ApplicationSingletonProvider.getInstance(HttpServer.class);
     }
   }
 
   /**
-   * Private constructor to enforce use of singleton
+   * Private constructor to enforce use of singleton; use getInstance().
    * 
    * @throws BindException
    *           if no free port can be assigned
    */
   private HttpServer() throws BindException
   {
+    // use getInstance()
+
     startServer();
 
     /*