Class WebAppInitUtil

java.lang.Object
com.saperion.web.WebAppInitUtil
All Implemented Interfaces:
jakarta.servlet.ServletContextListener, EventListener

public class WebAppInitUtil extends Object implements jakarta.servlet.ServletContextListener
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 Details

    • WebAppInitUtil

      public WebAppInitUtil()
  • Method Details

    • 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(String name) throws 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:
      Exception - if this WebAppInitUtil was not initialized by the servlet container yet.
    • setInitializer

      public WebAppInitUtil setInitializer(String name, WebAppInitializer webAppInitializer) throws 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:
      Exception - if this WebAppInitUtil was not initialized by the servlet container yet.
    • removeInitializer

      public WebAppInitUtil removeInitializer(String name) throws 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:
      Exception - if this WebAppInitUtil was not initialized by the servlet container yet.
    • loadInitilizers

      protected void loadInitilizers(jakarta.servlet.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(jakarta.servlet.ServletContextEvent sce)
      Is called when the server / the application is started. Registers WebAppInitializer and calls onWepAppInit on all registered WebAppInitializers.
      Specified by:
      contextInitialized in interface jakarta.servlet.ServletContextListener
      Parameters:
      sce - The ServletContextEvent.
    • contextDestroyed

      public void contextDestroyed(jakarta.servlet.ServletContextEvent sce)
      Is called when is the server / the application is shut down. Calls onWepAppDestroy on all registered WebAppInitializers.
      Specified by:
      contextDestroyed in interface jakarta.servlet.ServletContextListener
      Parameters:
      sce - The ServletContextEvent.