import javax.servlet.http.HttpServletResponse;
import jalview.httpserver.AbstractRequestHandler;
-import jalview.httpserver.HttpServer;
import jalview.structure.SelectionSource;
/**
public class ChimeraListener extends AbstractRequestHandler implements
SelectionSource
{
+ /*
+ * Chimera notification parameter name
+ */
private static final String CHIMERA_NOTIFICATION = "chimeraNotification";
+ /*
+ * Chimera model changed notifications start with this
+ */
private static final String MODEL_CHANGED = "ModelChanged: ";
+ /*
+ * Chimera selection changed notification message
+ */
private static final String SELECTION_CHANGED = "SelectionChanged: selection changed\n";
/*
private static int chimeraId = 0;
/*
- * Path below context root that identifies this handler
+ * Prefix for path below context root (myChimeraId is appended)
*/
- private static final String LISTENER_PATH = "chimera";
+ private static final String PATH_PREFIX = "chimera";
/*
* Value of chimeraId (0, 1, 2...) for this instance
*/
private JalviewChimeraBinding chimeraBinding;
- /*
- * The URI of this listener
- */
- private String uri;
-
/**
- * Constructor that also registers this as an Http request handler on path
+ * Constructor that registers this as an Http request handler on path
* /chimeraN, where N is incremented for each instance. Call getUri to get the
* resulting URI for this handler.
*
{
myChimeraId = chimeraId++;
this.chimeraBinding = binding;
- final String path = LISTENER_PATH + myChimeraId;
- this.uri = HttpServer.getInstance().registerHandler(path, this);
- }
-
- /**
- * Returns the URI on which we are listening
- *
- * @return
- */
- public String getUri()
- {
- return this.uri;
+ setPath(PATH_PREFIX + myChimeraId);
+ registerHandler();
}
/**
}
/**
- * Deregister this listener and close it down
- *
- * @throws Exception
+ * Returns a display name for this service
*/
- public void shutdown()
+ @Override
+ public String getName()
{
- try
- {
- HttpServer.getInstance().removeHandler(this);
- stop();
- } catch (Exception e)
- {
- System.err.println("Error stopping chimera listener: "
- + e.getMessage());
- }
+ return "ChimeraListener";
}
}