@WebListener public class ServletContextLoader extends Object implements javax.servlet.ServletContextListener
It is configured to auto-load into the servlet context by way of the
@WebListener
annotation. Overriding of this class is allowed, and overridden
classes that are annotated with @WebListener
will take precedence over this one.
By default, this class looks for the FactoryProducer class in a servletContext init
parameter called GSF_FACTORY_PRODUCER
. The class should have a public zero-arg
constructor.
If no servlet context init parameter is found, this loader will search the classPath for
a resource called CONFIG_FILE
. This file can contain blank lines and comments
(denoted by #) but must contain only one active line - a class name of a class implementing
the FactoryProducer interface. If more than one class name is found, an exception
will be thrown.
If neither of the above are found, DefaultFactoryProducer
will be instantiated
as the factory producer.
When the servlet context is initialized, the factory producer that is created is registered
the servlet context using the parameter GSF_FACTORY_PRODUCER
, and removed when the
servlet context is destroyed.
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_FILE
Name of config file where the factory producer class is configured.
|
static String |
GSF_FACTORY_PRODUCER
Name of the servlet context init parameter containing the factory producer to be booted
|
Constructor and Description |
---|
ServletContextLoader() |
Modifier and Type | Method and Description |
---|---|
void |
contextDestroyed(javax.servlet.ServletContextEvent servletContextEvent) |
void |
contextInitialized(javax.servlet.ServletContextEvent servletContextEvent) |
public static final String GSF_FACTORY_PRODUCER
public static final String CONFIG_FILE
public void contextInitialized(javax.servlet.ServletContextEvent servletContextEvent)
contextInitialized
in interface javax.servlet.ServletContextListener
public void contextDestroyed(javax.servlet.ServletContextEvent servletContextEvent)
contextDestroyed
in interface javax.servlet.ServletContextListener
Copyright © 2010–2017. All rights reserved.