package no.dusken.momus.config;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.servlet.DispatcherServlet;

public class WebInit implements WebApplicationInitializer {

	@Override
	public void onStartup(ServletContext servletContext) throws ServletException {
        AnnotationConfigWebApplicationContext config = new AnnotationConfigWebApplicationContext();
        config.register(ApplicationConfig.class, SecurityConfig.class);
        
        servletContext.addListener(new ContextLoaderListener(config));
        ServletRegistration.Dynamic dispatcher = 
            servletContext.addServlet("momusapi", new DispatcherServlet());

        dispatcher.setAsyncSupported(true);
        
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/api/*");

        // Add security to the servlet
        servletContext.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class)
            .addMappingForUrlPatterns(null, false, "/*");
	}

} 
@@ -26,16 +26,57 @@
 onfig;%0A%0A
+import javax.servlet.FilterRegistration;%0A
 import j
@@ -1221,38 +1221,99 @@
 let%0A        
-servletContext
+FilterRegistration.Dynamic securityFilter = servletContext%0A                
 .addFilter(%22
@@ -1368,16 +1368,18 @@
 y.class)
+;%0A
 %0A       
@@ -1375,28 +1375,86 @@
 );%0A%0A        
-    
+securityFilter.setAsyncSupported(true);%0A        securityFilter
 .addMappingF

Enable async for security filter