*/
package jalview.httpserver;
-import jalview.bin.Jalview;
+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
*/
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)
- {
- Jalview j = Jalview.getInstance();
- return (j.httpServer == null ? j.httpServer = new HttpServer()
- : j.httpServer);
- }
- }
-
/*
* The Http server
*/
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();
/*