Class WebAppInitUtil


  • public class WebAppInitUtil
    extends java.lang.Object
    This class is a web filter and can be used to initialize a web application. It is capable of handling multiple instances of WebAppInitializer to dynamically initialize the web application. WebAppInitializer can be registered as initialization-parameters in the web.xml. The order of the WebAppInitializer classes can be specified by the initialization parameter 'INIT_ORDER'.
    Author:
    sts
    • Constructor Detail

      • WebAppInitUtil

        public WebAppInitUtil()
    • Method Detail

      • getInstance

        public static WebAppInitUtil getInstance()
        Returns the instance of this WebAppInitUtil. If no instance was created by the servlet container
        Returns:
        the instance of this WebAppInitUtil.
      • getInitializer

        public WebAppInitializer getInitializer​(java.lang.String name)
                                         throws java.lang.Exception
        Returns the WebAppInitializer by the given name if existing, null otherwise.
        Parameters:
        name - The name of the WebAppInitializer to get.
        Returns:
        the WebAppInitializer by the given name if existing, null otherwise.
        Throws:
        java.lang.Exception - if this WebAppInitUtil was not initialized by the servlet container yet.
      • setInitializer

        public WebAppInitUtil setInitializer​(java.lang.String name,
                                             WebAppInitializer webAppInitializer)
                                      throws java.lang.Exception
        Sets the given WebAppInitializer by the given name if not already existing.
        Parameters:
        name - The name of the WebAppInitializer to set.
        webAppInitializer - The WebAppInitializer to set.
        Returns:
        instance of this WebAppInitUtil.
        Throws:
        java.lang.Exception - if this WebAppInitUtil was not initialized by the servlet container yet.
      • removeInitializer

        public WebAppInitUtil removeInitializer​(java.lang.String name)
                                         throws java.lang.Exception
        Removes the WebAppInitializer by the given name if existing.
        Parameters:
        name - The name of the WebAppInitializer to remove.
        Returns:
        instance of this WebAppInitUtil.
        Throws:
        java.lang.Exception - if this WebAppInitUtil was not initialized by the servlet container yet.
      • loadInitilizers

        protected void loadInitilizers​(ServletContext c)
        Loads the registered initializers as given as initialization parameters in web.xml. Overwrite this method to load initializers more elegant.
        Parameters:
        c - The ServletContext
      • contextInitialized

        public void contextInitialized​(ServletContextEvent sce)
        Is called when the server / the application is started. Registers WebAppInitializer and calls onWepAppInit on all registered WebAppInitializers.
        Parameters:
        sce - The ServletContextEvent.
      • contextDestroyed

        public void contextDestroyed​(ServletContextEvent sce)
        Is called when is the server / the application is shut down. Calls onWepAppDestroy on all registered WebAppInitializers.
        Parameters:
        sce - The ServletContextEvent.