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