Skip to content

Instantly share code, notes, and snippets.

Created Sep 16, 2011
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
(.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