Package com.saperion.web
Class WebAppInitUtil
- java.lang.Object
-
- com.saperion.web.WebAppInitUtil
-
public class WebAppInitUtil extends java.lang.ObjectThis class is a web filter and can be used to initialize a web application. It is capable of handling multiple instances ofWebAppInitializerto dynamically initialize the web application.WebAppInitializercan 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 Summary
Constructors Constructor Description WebAppInitUtil()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcontextDestroyed(ServletContextEvent sce)Is called when is the server / the application is shut down.voidcontextInitialized(ServletContextEvent sce)Is called when the server / the application is started.WebAppInitializergetInitializer(java.lang.String name)Returns the WebAppInitializer by the given name if existing, null otherwise.static WebAppInitUtilgetInstance()Returns the instance of this WebAppInitUtil.protected voidloadInitilizers(ServletContext c)Loads the registered initializers as given as initialization parameters in web.xml.WebAppInitUtilremoveInitializer(java.lang.String name)Removes the WebAppInitializer by the given name if existing.WebAppInitUtilsetInitializer(java.lang.String name, WebAppInitializer webAppInitializer)Sets the given WebAppInitializer by the given name if not already existing.
-
-
-
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 callsonWepAppIniton all registered WebAppInitializers.- Parameters:
sce- The ServletContextEvent.
-
contextDestroyed
public void contextDestroyed(ServletContextEvent sce)
Is called when is the server / the application is shut down. CallsonWepAppDestroyon all registered WebAppInitializers.- Parameters:
sce- The ServletContextEvent.
-
-