JAL-3210 Improvements to eclipse detection. New src tree and SwingJS updated from...
[jalview.git] / src / jalview / httpserver / HttpServer.java
index 02c8380..f2daf2b 100644 (file)
@@ -20,7 +20,8 @@
  */
 package jalview.httpserver;
 
-import jalview.bin.Instance;
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.rest.RestHandler;
 
 import java.net.BindException;
@@ -50,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,22 +59,6 @@ public class HttpServer
    */
   private static final String JALVIEW_PATH = "jalview";
 
-  /**
-   * Returns the singleton instance of this class.
-   * 
-   * @return
-   * @throws BindException
-   */
-  public static HttpServer getInstance() throws BindException
-  {
-    synchronized (HttpServer.class)
-    {
-      Instance j = Instance.getInstance();
-      return (j.httpServer == null ? j.httpServer = new HttpServer()
-              : j.httpServer);
-    }
-  }
-
   /*
    * The Http server
    */
@@ -95,13 +80,29 @@ public class HttpServer
   private URI contextRoot;
 
   /**
-   * Private constructor to enforce use of singleton
+   * Returns the singleton instance of this class.
+   * 
+   * @return
+   * @throws BindException
+   */
+  public static HttpServer getInstance() throws BindException
+  {
+    synchronized (HttpServer.class)
+    {
+      return (HttpServer) ApplicationSingletonProvider.getInstance(HttpServer.class);
+    }
+  }
+
+  /**
+   * 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();
 
     /*