@ SuppressWarnings ( "rawtypes" ) public List < ServletDefinition > initJawrSpringServlets ( ServletContext servletContext ) throws ServletException { List < ServletDefinition > jawrServletDefinitions = new ArrayList < ServletDefinition > ( ) ; ContextLoader contextLoader = new ContextLoader ( ) ; WebApplicationContext applicationCtx = contextLoader . initWebApplicationContext ( servletContext ) ; Map < ? , ? > jawrControllersMap = applicationCtx . getBeansOfType ( JawrSpringController . class ) ; Iterator < ? > entrySetIterator = jawrControllersMap . entrySet ( ) . iterator ( ) ; while ( entrySetIterator . hasNext ( ) ) { JawrSpringController jawrController = ( JawrSpringController ) ( ( Map . Entry ) entrySetIterator . next ( ) ) . getValue ( ) ; Map < String , Object > initParams = new HashMap < String , Object > ( ) ; initParams . putAll ( jawrController . getInitParams ( ) ) ; ServletConfig servletConfig = new MockServletConfig ( SPRING_DISPATCHER_SERVLET , servletContext , initParams ) ; MockJawrSpringServlet servlet = new MockJawrSpringServlet ( jawrController , servletConfig ) ; ServletDefinition servletDefinition = new ServletDefinition ( servlet , servletConfig ) ; jawrServletDefinitions . add ( servletDefinition ) ; } contextLoader . closeWebApplicationContext ( servletContext ) ; return jawrServletDefinitions ; }
Initialize the servlets which will handle the request to the JawrSpringController