+
+ /**
+ * Returns a display name for the handler
+ *
+ * @return
+ */
+ public abstract String getName();
+
+ /**
+ * Deregister this listener and close it down
+ *
+ * @throws Exception
+ */
+ public void shutdown()
+ {
+ try
+ {
+ HttpServer.getInstance().removeHandler(this);
+ stop();
+ } catch (Exception e)
+ {
+ jalview.bin.Console.errPrintln(
+ "Error stopping " + getName() + ": " + e.getMessage());
+ }
+ }
+
+ /**
+ * Returns the URI on which we are listening
+ *
+ * @return
+ */
+ public String getUri()
+ {
+ return this.uri;
+ }
+
+ /**
+ * Set the URI to this handler
+ *
+ * @param u
+ */
+ protected void setUri(String u)
+ {
+ this.uri = u;
+ }
+
+ /**
+ * Sets the relative path to this handler - do this before registering the
+ * handler.
+ *
+ * @param p
+ */
+ protected void setPath(String p)
+ {
+ this.path = p;
+ }
+
+ /**
+ * Returns the relative path to this handler below the context root (without /
+ * separators)
+ *
+ * @return
+ */
+ public String getPath()
+ {
+ return this.path;
+ }
+
+ /**
+ * Registers the handler with the HttpServer and reports its URI on stdout
+ *
+ * @throws BindException
+ * if no port could be allocated
+ * @throws IllegalStateException
+ * if this method is called before {@link #setPath}
+ */
+ protected void registerHandler() throws BindException
+ {
+ HttpServer.getInstance().registerHandler(this);
+ }