Permalink
Browse files

renamed master package to http

  • Loading branch information...
1 parent 4c80fb9 commit 05b3315350f00fe0d1d2015b0942f17ac7f1ffa5 @amitrathore committed Mar 28, 2009
View
47 scripts/swarmiji
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# Please make sure to configure ~/.clojure.conf or /etc/clojure.conf
+# sample configuration can be found at clojure.conf.sample
+#
+# Note, running this script will:
+# - Run ~/.clojurerc on boot up (if exists)
+# - Add all .jar files within clj_ext (~/.clojure on default)
+# to the classpath
+#
+#
+
+if [ ! -f /etc/clojure.conf -a ! -f /mnt/furtive/clojure.conf -a ! -f ~/.clojure.conf ]; then
+ echo "Error: No config not found at /etc/clojure.conf or ~/.clojure.conf."
+ echo " Please provide one before starting this script."
+ echo " A sample can be found in the emacs-clojure repository named "
+ echo " clojure.conf.sample"
+ exit
+fi
+
+
+# Whether to load the repl or script
+if [ -z "$1" ]; then
+ clj_class=clojure.lang.Repl
+else
+ clj_class=clojure.lang.Script
+fi
+
+echo "SWARMIJI_HOME is ${SWARMIJI_HOME}"
+swarmiji_src="${SWARMIJI_HOME}/src/"
+swarmiji_jars="${SWARMIJI_HOME}/lib/java"
+swarmiji_clj="${SWARMIJI_HOME}/lib/clojure/capjure/src/:${SWARMIJI_HOME}/lib/clojure/conjure/src/:${SWARMIJI_HOME}/lib/clojure/clj-record/"
+
+clj_cp="."
+[ -f /etc/clojure.conf ] && . /etc/clojure.conf
+[ -f /mnt/swarmiji/clojure.conf ] && . /mnt/swarmiji/clojure.conf
+[ -f ~/.clojure.conf ] && . ~/.clojure.conf
+[ -f ~/.clojurerc ] && clj_rc=~/.clojurerc
+clj_cp="${clj_cp}:${swarmiji_jars}/*:${swarmiji_src}:${swarmiji_clj}:${clj_ext}/*"
+
+if [ -n "${clj_lib}" ]; then
+ export LD_LIBRARY_PATH=${clj_lib}:$LD_LIBRARY_PATH
+fi
+
+# exec java -Dpid=$$ ${clj_opts} -cp ${clj_cp}:${clj} ${clj_wrapper} ${clj_class} ${clj_rc} $*
+#echo exec java -server -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888 -Dpid=$$ ${clj_opts} -cp ${clj_cp}:${clj} ${clj_wrapper} ${clj_class} ${clj_rc} $*
+exec java -Xms256m -Xmx512m -server -Dpid=$$ ${clj_opts} -cp ${clj_cp}:${clj} ${clj_wrapper} ${clj_class} ${clj_rc} $*
View
6 src/org/runa/swarmiji/http/boot.clj
@@ -0,0 +1,6 @@
+(require '(org.runa.swarmiji.http [web-server :as web-server]))
+(require '(org.runa.swarmiji.http [grizzly-utils :as grizzly-utils]))
+
+(let [handler (web-server/http-request-handler)]
+ (grizzly-utils/start-web-server handler 8020))
+
View
2 ...rg/runa/swarmiji/master/grizzly_utils.clj → src/org/runa/swarmiji/http/grizzly_utils.clj
@@ -1,4 +1,4 @@
-(ns org.runa.swarmiji.master.grizzly-utils)
+(ns org.runa.swarmiji.http.grizzly-utils)
(import '(com.sun.grizzly.http SelectorThread))
View
15 src/org/runa/swarmiji/master/web_server.clj → src/org/runa/swarmiji/http/web_server.clj
@@ -1,12 +1,12 @@
-(ns org.runa.swarmiji.master.web-server)
+(ns org.runa.swarmiji.http.web-server)
(import '(com.sun.grizzly.http SelectorThread))
(import '(com.sun.grizzly.tcp Adapter OutputBuffer Request Response))
(import '(com.sun.grizzly.util.buf ByteChunk))
(import '(java.net HttpURLConnection))
(defn is-get? [request]
- (= (.toUpperCase (.method request)) "GET"))
+ (= (.toUpperCase (str (.method request))) "GET"))
(defn response-as-chunk [grizzly-response response-text]
(let [response-bytes (.getBytes response-text)
@@ -18,12 +18,13 @@
(.append out-chunk response-bytes 0 response-length)
out-chunk))
-(defn service-http-request [request response]
+(defn service-http-request [custom-request-handler request response]
(do
- (println "Recieved request from" (.requestURI request))
+ (println "Recieved request from" (str (.requestURI request)))
(if (is-get? request)
(let [out-buffer (.getOutputBuffer response)
- response-chunk (response-as-chunk response "Hello World!")]
+ response-text (custom-request-handler request)
+ response-chunk (response-as-chunk response response-text)]
(.doWrite out-buffer response-chunk response)
(.finish response)))))
@@ -32,10 +33,10 @@
(.recycle request)
(.recycle response)))
-(defn http-request-handler []
+(defn http-request-handler [custom-request-handler]
(proxy [Adapter] []
(service [req res]
- (service-http-request req res))
+ (service-http-request custom-request-handler req res))
(afterService [req res]
(after-service req res))))
View
6 src/org/runa/swarmiji/master/boot.clj
@@ -1,6 +0,0 @@
-(require '(org.runa.swarmiji.master [web-server :as web-server]))
-(require '(org.runa.swarmiji.master [grizzly-utils :as grizzly-utils]))
-
-(let [handler (web-server/http-request-handler)]
- (grizzly-utils/start-web-server handler 8020))
-

0 comments on commit 05b3315

Please sign in to comment.