public class SingleAppCoreServletListener
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 (core.dependencies). So the classloaders load classes from the jars and only if class is not found they delegate loading to base WebAppClassLoader (their parent).
As a result, core classloader contains core classes, web classloder contains web classes and WebAppClassLoader contains "shared" classes.
To make sure the Spring context use 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 put property with dependencies to AppContext (reflectively as well).
The property will be used on spring context creation, to detect which jars to scan.
Constructor and Description |
---|
SingleAppCoreServletListener() |
Modifier and Type | Method and Description |
---|---|
void |
contextDestroyed(javax.servlet.ServletContextEvent sce) |
void |
contextInitialized(javax.servlet.ServletContextEvent sce) |
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