--- /dev/null
+import org.eclipse.jetty.server.Server
+import org.eclipse.jetty.servlet.*
+import groovy.servlet.*
+import javax.servlet.http.*
+import javax.servlet.api.*
+import javax.servlet.ServletConfig
+
+class SimpleGroovyServlet extends HttpServlet {
+ def requestHandler
+ def context
+ void init(ServletConfig config) {
+ super.init(config)
+ context = config.servletContext
+ }
+ void service(HttpServletRequest request, HttpServletResponse response) {
+ requestHandler.binding = new ServletBinding(request, response, context)
+ use (ServletCategory) {
+ requestHandler.call()
+ }
+ }
+ static void run(int port, Closure requestHandler) {
+ ours = requestHandler;
+ def servlet = new SimpleGroovyServlet(requestHandler: requestHandler)
+ def jetty = new Server(port)
+// def handler = new ServletHandler()
+// jetty.setHandler(handler)
+
+ def context = new ServletContextHandler(jetty, '/', ServletContextHandler.SESSIONS)
+ context.addServlet(new ServletHolder(servlet), '/*')
+ jetty.start()
+ }
+ static Closure ours;
+}
+
+if ( SimpleGroovyServlet.ours == null ) {
+SimpleGroovyServlet.run(8878, { ->
+ response.contentType = 'text/plain'
+ println "Retrieving ENSEMBL ${params.name}"
+// println "my path is ${request.pathInfo}"
+// println "my params are $params"
+ jalview.gui.SequenceFetcher.fetchAndShow("ENSEMBL",""+params.get("name"))
+})
+} else {
+ print "Already running."
+}
\ No newline at end of file