Skip to content

Instantly share code, notes, and snippets.

@gtrak
Created July 16, 2012 13:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtrak/3122677 to your computer and use it in GitHub Desktop.
Save gtrak/3122677 to your computer and use it in GitHub Desktop.
Swank in web app
(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