Created
July 16, 2012 13:20
-
-
Save gtrak/3122677 to your computer and use it in GitHub Desktop.
Swank in web app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns swanker.core | |
(:require [swank.swank :as swank])) | |
(gen-class | |
:name swanker.core.ServletFilter | |
:prefix servlet- | |
:implements [javax.servlet.ServletContextListener]) | |
(comment | |
"Do this in web.xml" | |
"<listener> | |
<listener-class>swanker.core.ServletFilter</listener-class> | |
</listener>") | |
;;public void contextInitialized ( ServletContextEvent sce ); | |
(defn servlet-contextInitialized | |
[_ sce] | |
(println "Starting Swank Server on port 4006") | |
(def *servlet-context* (.getServletContext sce)) | |
(swank/start-server :port 4006)) | |
;;public void contextDestroyed ( ServletContextEvent sce ); | |
(defn servlet-contextDestroyed | |
[_ servlet-context-event] | |
(println "Shutting down Swank Server") | |
(swank/stop-server)) | |
(defn spring-context [] | |
(org.springframework.web.context.support.WebApplicationContextUtils/getWebApplicationContext *servlet-context*)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment