JAL-3548 start an http server for posting gene ids to retrieve from ensembl and displ... spike/JAL-3548_exampleRestServer
authorJim Procter <jprocter@issues.jalview.org>
Thu, 5 Mar 2020 12:14:11 +0000 (12:14 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 5 Mar 2020 12:14:11 +0000 (12:14 +0000)
examples/groovy/simpleHttpServlet.groovy [new file with mode: 0644]
j11lib/jetty-security-9.2.11.v20150529.jar [new file with mode: 0644]
j11lib/jetty-servlet-9.2.11.v20150529.jar [new file with mode: 0644]
j8lib/jetty-security-9.2.11.v20150529.jar [new file with mode: 0644]
j8lib/jetty-servlet-9.2.11.v20150529.jar [new file with mode: 0644]

diff --git a/examples/groovy/simpleHttpServlet.groovy b/examples/groovy/simpleHttpServlet.groovy
new file mode 100644 (file)
index 0000000..556f78b
--- /dev/null
@@ -0,0 +1,45 @@
+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
diff --git a/j11lib/jetty-security-9.2.11.v20150529.jar b/j11lib/jetty-security-9.2.11.v20150529.jar
new file mode 100644 (file)
index 0000000..0d2ac23
Binary files /dev/null and b/j11lib/jetty-security-9.2.11.v20150529.jar differ
diff --git a/j11lib/jetty-servlet-9.2.11.v20150529.jar b/j11lib/jetty-servlet-9.2.11.v20150529.jar
new file mode 100644 (file)
index 0000000..d9fe378
Binary files /dev/null and b/j11lib/jetty-servlet-9.2.11.v20150529.jar differ
diff --git a/j8lib/jetty-security-9.2.11.v20150529.jar b/j8lib/jetty-security-9.2.11.v20150529.jar
new file mode 100644 (file)
index 0000000..0d2ac23
Binary files /dev/null and b/j8lib/jetty-security-9.2.11.v20150529.jar differ
diff --git a/j8lib/jetty-servlet-9.2.11.v20150529.jar b/j8lib/jetty-servlet-9.2.11.v20150529.jar
new file mode 100644 (file)
index 0000000..d9fe378
Binary files /dev/null and b/j8lib/jetty-servlet-9.2.11.v20150529.jar differ