public static ServletContextCache getCache ( ServletContext servletContext ) { ServletContextCache cache = ( ServletContextCache ) servletContext . getAttribute ( ATTRIBUTE_KEY ) ; if ( cache == null ) { // It is possible this is called during context initialization before the listener cache = new ServletContextCache ( servletContext ) ; servletContext . setAttribute ( ATTRIBUTE_KEY , cache ) ; //throw new IllegalStateException("ServletContextCache not active in the provided ServletContext. Add context listener to web.xml?"); } else { assert cache . servletContext == servletContext ; } return cache ; }
Gets or creates the cache for the provided servlet context .