Skip to content

Instantly share code, notes, and snippets.

@lispnik
Created Sep 16, 2011
Embed
What would you like to do?
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