Created
September 16, 2011 03:42
-
-
Save lispnik/1221146 to your computer and use it in GitHub Desktop.
Spring/Spring Security bootstrapper for Jetty and Ring
This file contains hidden or 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
(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