Paste number 134966: abcl+jetty

Paste number 134966: abcl+jetty
Pasted by: milosn
When:1 year, 8 months ago
Share:Tweet this! | http://paste.lisp.org/+2W52
Channel:None
Paste contents:
Raw Source | XML | Display As
(in-package #:test-asdf)

(loop for x in (abcl-asdf:as-classpath(abcl-asdf:resolve-dependencies "org.eclipse.jetty" "jetty-server" "8.1.8.v20121106"))
      do (java:add-to-classpath x))

(defparameter *server* (jss:new 'org.eclipse.jetty.server.Server 8080))

(defun make-handler ()
  (java:jnew-runtime-class
    "MyHandler"
    :superclass "org.eclipse.jetty.server.handler.AbstractHandler"
    :interfaces ()
    :fields ()
    :methods (list
               (list "handle" :void '("java.lang.String"
                                      "org.eclipse.jetty.server.Request"
                                      "javax.servlet.http.HttpServletRequest"
                                      "javax.servlet.http.HttpServletResponse")
                     (lambda (this target base_request request response)
                       (#"setContentType" response "text/html;charset=utf-8")
                       (#"setStatus" response 200)
                       (#"setHandled" base_request java:+true+)
                       (let ((out (#"getWriter" response)))
                         (#"println" out "Hello from ABCL<br />")
                         (#"println" out "Request path: ")
                         (#"println" out target)
                         (#"close" out)))))))

(defun start ()
  (let ((handler-clazz (make-handler)))
    (#"setHandler" *server* (jss:new handler-clazz))
    (#"start" *server*)))

(defun stop ()
    (#"stop" *server*))

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.