public class SingleAppWebServletListener
extends java.lang.Object
implements javax.servlet.ServletContextListener
We create 2 URLClassLoaders (1 for core and 1 for web), with predefined (during single WAR build) list of jars (/WEB-INF/lib-web/).
As a result, core classloader contains core classes, web classloader contains web classes and WebAppClassLoader contains "shared" classes.
To make sure the Spring context uses the specific classloader we load AppWebContextLoader
reflectively, create new instance
and call its initialization methods reflectively as well.
As each classloader has its own AppContext version, we can scan jars only from defined folders (/WEB-INF/lib-web/ for "web" jars).
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
appContextLoader |
Constructor and Description |
---|
SingleAppWebServletListener() |
Modifier and Type | Method and Description |
---|---|
void |
contextDestroyed(javax.servlet.ServletContextEvent sce) |
void |
contextInitialized(javax.servlet.ServletContextEvent sce) |
protected java.lang.String |
getAppContextLoaderClassName() |
public void contextInitialized(javax.servlet.ServletContextEvent sce)
contextInitialized
in interface javax.servlet.ServletContextListener
public void contextDestroyed(javax.servlet.ServletContextEvent sce)
contextDestroyed
in interface javax.servlet.ServletContextListener
protected java.lang.String getAppContextLoaderClassName()