*/
package jalview.httpserver;
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
import jalview.rest.RestHandler;
import java.net.BindException;
* @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";
-
- /*
- * Singleton instance of this server
- */
- private static HttpServer instance;
-
- /*
- * The Http server
- */
- private Server server;
-
- /*
- * Registered handlers for context paths
- */
- private HandlerCollection contextHandlers;
-
- /*
- * Lookup of ContextHandler by its wrapped handler
- */
- Map<Handler, ContextHandler> myHandlers = new HashMap<Handler, ContextHandler>();
-
- /*
- * The context root for the server
- */
- private URI contextRoot;
-
/**
* Returns the singleton instance of this class.
*
{
synchronized (HttpServer.class)
{
- if (instance == null)
- {
- instance = new HttpServer();
- }
- return instance;
+ return ApplicationSingletonProvider.getInstance(HttpServer.class);
}
}
-
+
/**
* Private constructor to enforce use of singleton
*
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
+ */
+ private Server server;
+
+ /*
+ * Registered handlers for context paths
+ */
+ private HandlerCollection contextHandlers;
+
+ /*
+ * Lookup of ContextHandler by its wrapped handler
+ */
+ Map<Handler, ContextHandler> myHandlers = new HashMap<Handler, ContextHandler>();
+
+ /*
+ * The context root for the server
+ */
+ private URI contextRoot;
+
+
/**
* Start the http server
*