public static void addFileOpener ( ServletContext servletContext , FileOpener fileOpener , String ... extensions ) { synchronized ( fileOpenersLock ) { @ SuppressWarnings ( "unchecked" ) Map < String , FileOpener > fileOpeners = ( Map < String , FileOpener > ) servletContext . getAttribute ( FILE_OPENERS_REQUEST_ATTRIBUTE_NAME ) ; if ( fileOpeners == null ) { fileOpeners = new HashMap <> ( ) ; servletContext . setAttribute ( FILE_OPENERS_REQUEST_ATTRIBUTE_NAME , fileOpeners ) ; } for ( String extension : extensions ) { if ( fileOpeners . containsKey ( extension ) ) throw new IllegalStateException ( "File opener already registered: " + extension ) ; fileOpeners . put ( extension , fileOpener ) ; } } }
Registers a file opener .