org.springframework.web.context.ContextLoaderListener
grepcode 를 통해 단순히 소스분석만 해보자.
// Stack trace contextInitialized():108, ContextLoaderListener {org.springframework.web.context} listenerStart():4797, StandardContext {org.apache.catalina.core} startInternal():5221, StandardContext {org.apache.catalina.core} start():150, LifecycleBase {org.apache.catalina.util} addChildInternal():724, ContainerBase {org.apache.catalina.core} addChild():700, ContainerBase {org.apache.catalina.core} addChild():714, StandardHost {org.apache.catalina.core} manageApp():1587, HostConfig {org.apache.catalina.startup} invoke0():-1, NativeMethodAccessorImpl {sun.reflect} invoke():-1, NativeMethodAccessorImpl {sun.reflect} invoke():-1, DelegatingMethodAccessorImpl {sun.reflect} invoke():-1, Method {java.lang.reflect} invoke():300, BaseModelMBean {org.apache.tomcat.util.modeler} invoke():-1, DefaultMBeanServerInterceptor {com.sun.jmx.interceptor} invoke():-1, JmxMBeanServer {com.sun.jmx.mbeanserver} createStandardContext():463, MBeanFactory {org.apache.catalina.mbeans} createStandardContext():413, MBeanFactory {org.apache.catalina.mbeans} invoke0():-1, NativeMethodAccessorImpl {sun.reflect} invoke():-1, NativeMethodAccessorImpl {sun.reflect} invoke():-1, DelegatingMethodAccessorImpl {sun.reflect} invoke():-1, Method {java.lang.reflect} invoke():300, BaseModelMBean {org.apache.tomcat.util.modeler}
ContextLoaderListener
ContextLoaderListener 는 ServletContextListener 를 implement 한다.
class ContextLoaderListener extends ContextLoader implements ServletContextListener
ㄹㅇㄴㄹ
// org.apache.catalina.startup.HostConfig.java public void manageApp(Context context) { String contextName = context.getName(); if (deployed.containsKey(contextName)) return; ... // Add the associated docBase to the redeployed list if it's a WAR boolean isWar = false; if (context.getDocBase() != null) { ... } host.addChild(context); ... } // org.apache.catalina.core.StandardHost.java @Override public void addChild(Container child) { child.addLifecycleListener(new MemoryLeakTrackingListener()); if (!(child instanceof Context)) throw new IllegalArgumentException (sm.getString("standardHost.notContext")); super.addChild(child); } // ContainerBase.java @Override public void addChild(Container child) { if (Globals.IS_SECURITY_ENABLED) { ... } else { addChildInternal(child); } } // ContainerBase.java private void addChildInternal(Container child) { ... if ((getState().isAvailable() || LifecycleState.STARTING_PREP.equals(getState())) && startChildren) { try { child.start(); } catch (LifecycleException e) { log.error("ContainerBase.addChild: start: ", e); throw new IllegalStateException ("ContainerBase.addChild: start: " + e); } } } // LifecycleBase.java @Override public final synchronized void start() throws LifecycleException { ... try { startInternal(); } catch (Throwable t) { ... } } // StandardContext.java @Override protected synchronized void startInternal() throws LifecycleException { ... try { ... // Configure and call application event listeners if (ok) { if (!listenerStart()) { log.error( "Error listenerStart"); ok = false; } } } // StandardContext.java public boolean listenerStart() { ... for (int i = 0; i < instances.length; i++) { if (!(instances[i] instanceof ServletContextListener)) continue; ServletContextListener listener = (ServletContextListener) instances[i]; try { fireContainerEvent("beforeContextInitialized", listener); if (noPluggabilityListeners.contains(listener)) { listener.contextInitialized(tldEvent); } else { listener.contextInitialized(event); } ... }
댓글 없음:
댓글 쓰기