Skip to content

Instantly share code, notes, and snippets.

@lispnik
Created September 16, 2011 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lispnik/1221146 to your computer and use it in GitHub Desktop.
Save lispnik/1221146 to your computer and use it in GitHub Desktop.
Spring/Spring Security bootstrapper for Jetty and Ring
(defn- boot-spring
"Initialize a Jetty server for Spring and also Spring Security"
([server handler context-config-location]
(let [filter (doto (org.mortbay.jetty.servlet.FilterHolder. org.springframework.web.filter.DelegatingFilterProxy)
(.setName "springSecurityFilterChain"))
servlet (doto (org.mortbay.jetty.servlet.ServletHolder. (ring.util.servlet/servlet handler))
(.setName "default"))
context (doto (org.mortbay.jetty.servlet.Context. server "/"
(bit-or org.mortbay.jetty.servlet.Context/SESSIONS
org.mortbay.jetty.servlet.Context/SECURITY))
(.addFilter filter "/*" 0)
(.addServlet servlet "/")
(.addEventListener (org.springframework.web.context.ContextLoaderListener.)))]
(when context-config-location
(.setInitParams context {"contextConfigLocation" context-config-location}))
(.addHandler server context)))
([server handler]
(boot-spring server handler nil)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment