Skip to content

Commit

Permalink
added the startup of swank
Browse files Browse the repository at this point in the history
  • Loading branch information
denlab committed Apr 15, 2012
1 parent bd66bac commit 362440a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main/java/cljinject/SwankServletContextListener.java
Expand Up @@ -3,9 +3,14 @@
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import clojure.lang.Compiler;
import java.io.StringReader;

public class SwankServletContextListener implements ServletContextListener{
ServletContext context;

// keep a hand on the context so we can get it from within clojure
public static ServletContext context;

public void contextInitialized(ServletContextEvent contextEvent) {
System.out.println(">>>>>>>>>>>>>>> Context Created");
context = contextEvent.getServletContext();
Expand All @@ -17,10 +22,11 @@ public void contextInitialized(ServletContextEvent contextEvent) {
new Thread() {
public void run() {
try {
while (true) {
System.out.print(".");
Thread.sleep(100);
}
final String startSwankScript =
"(ns my-app\n" +
" (:use [swank.swank :as swank]))\n" +
"(swank/start-repl) ";
Compiler.load(new StringReader(startSwankScript));
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 362440a

Please sign in to comment.