-
-
Save paulosuzart/480886 to your computer and use it in GitHub Desktop.
; Starts an JTornado HTTP Server and a sample RequestHandler. | |
; Bit verbose due to compilation directives. Recommendation is to generate | |
; a set of macros to hide this. | |
(ns org.ctornadoweb | |
; Compiled and implements a static main method to start the server | |
(:import (org.jtornadoweb HttpServer) | |
(org.jtornadoweb.Web$Application) | |
(org.jtornadoweb.Web$RequestHandler)) | |
(:gen-class :prefix "server-")) | |
(gen-class | |
:name org.ctornadoweb.MyHandler | |
:extends org.jtornadoweb.Web$RequestHandler | |
:prefix "do-") | |
(defn do-get [this] | |
"Handles the HTTP GET method" | |
(.write "hello clojure")) | |
(defn do-post [this] | |
"Handles the HTTP POST method" | |
(.write (.getArgument "name" "default" false))) | |
(defn server-main [] | |
"main method" | |
(.listen | |
(org.jtornadoweb.HttpServer. | |
(.add (org.jtornadoweb.Web$Application.) "/" org.ctornadoweb.MyHandler) | |
false nil false) 8089)) | |
;use (compile 'org.ctornadoweb) |
I'm not a clojure fan.. but JTornado is nice!
Hi Felipe. We are working hard to release the first stable version of JTornado. The idea is to kill all bureaucracy for Java on the Web. We still have the plan to rearrange the webframework (primarily written for java) to better fit other VM Languages like Groovy, Scala and Clojure.
Thanks.
Sure.. i wrote about that last year.. http://www.loogica.net/blog/2009/11/04/java-para-web-sem-servlets/ but my framework works with Jetty.. but JTornado is even better because it's (even) small (than jetty) and lightweight.. and combined with something like freemarker and some lightweight persistence framework can provide a very performatic, small yet powerfull solution to put java websites with minimum effort!
oh god! worked. Thanks