from develep
[jalview.git] / src / jalview / httpserver / HttpServer.java
index 8797f33..b58b01f 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,9 +51,8 @@ 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
 {
-
   /**
    * Returns the singleton instance of this class.
    * 
@@ -63,30 +63,10 @@ public class HttpServer
   {
     synchronized (HttpServer.class)
     {
-      Instance j = Instance.getInstance();
-      return (j.httpServer == null ? j.httpServer = new HttpServer()
-              : j.httpServer);
+      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();
-
-    /*
-     * Provides a REST server by default; add more programmatically as required
-     */
-    registerHandler(RestHandler.getInstance());
-  }
-
   /*
    * 'context root' - actually just prefixed to the path for each handler for
    * now - see registerHandler
@@ -113,6 +93,25 @@ public class HttpServer
    */
   private URI contextRoot;
 
+
+  /**
+   * 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();
+
+    /*
+     * Provides a REST server by default; add more programmatically as required
+     */
+    registerHandler(RestHandler.getInstance());
+  }
+
   /**
    * Start the http server
    *