X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fhttpserver%2FHttpServer.java;h=8cb184625c37e95e71775812d56ac04c74360b79;hb=418006c3714eb8da78234660698231597eb90fb1;hp=58e792dee2e3ee5af05799d6d3517c8c1f021fb5;hpb=208f2c3de82e3327c4f930ab7d04f5b812ccd277;p=jalview.git diff --git a/src/jalview/httpserver/HttpServer.java b/src/jalview/httpserver/HttpServer.java index 58e792d..8cb1846 100644 --- a/src/jalview/httpserver/HttpServer.java +++ b/src/jalview/httpserver/HttpServer.java @@ -20,7 +20,8 @@ */ package jalview.httpserver; -import jalview.bin.Jalview; +import jalview.bin.ApplicationSingletonProvider; +import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI; import jalview.rest.RestHandler; import java.net.BindException; @@ -50,13 +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 { - /* - * 'context root' - actually just prefixed to the path for each handler for - * now - see registerHandler - */ - private static final String JALVIEW_PATH = "jalview"; /** * Returns the singleton instance of this class. @@ -68,12 +64,34 @@ public class HttpServer { synchronized (HttpServer.class) { - Jalview j = Jalview.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 + */ + private static final String JALVIEW_PATH = "jalview"; + /* * The Http server */ @@ -95,22 +113,6 @@ public class HttpServer private URI contextRoot; /** - * Private constructor to enforce use of singleton - * - * @throws BindException - * if no free port can be assigned - */ - private HttpServer() throws BindException - { - startServer(); - - /* - * Provides a REST server by default; add more programmatically as required - */ - registerHandler(RestHandler.getInstance()); - } - - /** * Start the http server * * @throws BindException