Package org.apache.catalina.loader
Class WebappLoader
- java.lang.Object
- 
- org.apache.catalina.util.LifecycleBase
- 
- org.apache.catalina.util.LifecycleMBeanBase
- 
- org.apache.catalina.loader.WebappLoader
 
 
 
- 
- All Implemented Interfaces:
- java.beans.PropertyChangeListener,- java.util.EventListener,- javax.management.MBeanRegistration,- JmxEnabled,- Lifecycle,- Loader
 
 public class WebappLoader extends LifecycleMBeanBase implements Loader, java.beans.PropertyChangeListener Classloader implementation which is specialized for handling web applications in the most efficient way, while being Catalina aware (all accesses to resources are made throughWebResourceRoot). This class loader supports detection of modified Java classes, which can be used to implement auto-reload support.This class loader is configured via the Resources children of its Context prior to calling start(). When a new class is required, these Resources will be consulted first to locate the class. If it is not present, the system class loader will be used instead.- Author:
- Craig R. McClanahan, Remy Maucherat
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.catalina.LifecycleLifecycle.SingleUse
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected static StringManagersmThe string manager for this package.protected java.beans.PropertyChangeSupportsupportThe property change support for this component.- 
Fields inherited from class org.apache.catalina.util.LifecycleMBeanBasemserver
 - 
Fields inherited from interface org.apache.catalina.LifecycleAFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
 
- 
 - 
Constructor SummaryConstructors Constructor Description WebappLoader()Construct a new WebappLoader.WebappLoader(java.lang.ClassLoader parent)Deprecated.UseContainer.setParentClassLoader(ClassLoader)to specify the required class loader.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)Add a property change listener to this component.voidbackgroundProcess()Execute a periodic task, such as reloading, etc.java.lang.ClassLoadergetClassLoader()Return the Java class loader to be used by this Container.java.lang.StringgetClasspath()Classpath, as set in org.apache.catalina.jsp_classpath context propertyContextgetContext()booleangetDelegate()Return the "follow standard delegation model" flag used to configure our ClassLoader.protected java.lang.StringgetDomainInternal()Method implemented by sub-classes to identify the domain in which MBeans should be registered.java.lang.StringgetLoaderClass()java.lang.String[]getLoaderRepositories()java.lang.StringgetLoaderRepositoriesString()protected java.lang.StringgetObjectNameKeyProperties()Allow sub-classes to specify the key properties component of theObjectNamethat will be used to register this component.booleangetReloadable()Return the reloadable flag for this Loader.booleanmodified()Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?voidpropertyChange(java.beans.PropertyChangeEvent event)Process property change events from our associated Context.voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)Remove a property change listener from this component.voidsetContext(Context context)Set the Context with which this Loader has been associated.voidsetDelegate(boolean delegate)Set the "follow standard delegation model" flag used to configure our ClassLoader.voidsetLoaderClass(java.lang.String loaderClass)Set the ClassLoader class name.voidsetLoaderInstance(WebappClassLoaderBase loaderInstance)Set the ClassLoader instance, without relying on reflection This method will also invokesetLoaderClass(String)withloaderInstance.getClass().getName()as an argumentvoidsetReloadable(boolean reloadable)Set the reloadable flag for this Loader.protected voidstartInternal()Start associatedClassLoaderand implement the requirements ofLifecycleBase.startInternal().protected voidstopInternal()Stop associatedClassLoaderand implement the requirements ofLifecycleBase.stopInternal().java.lang.StringtoString()Return a String representation of this component.- 
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBasedestroyInternal, getDomain, getObjectName, initInternal, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister
 - 
Methods inherited from class org.apache.catalina.util.LifecycleBaseaddLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
 
- 
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm The string manager for this package.
 - 
supportprotected final java.beans.PropertyChangeSupport support The property change support for this component.
 
- 
 - 
Constructor Detail- 
WebappLoaderpublic WebappLoader() Construct a new WebappLoader. The parent class loader will be defined byContainer.getParentClassLoader().
 - 
WebappLoader@Deprecated public WebappLoader(java.lang.ClassLoader parent) Deprecated.UseContainer.setParentClassLoader(ClassLoader)to specify the required class loader. This method will be removed in Tomcat 10 onwards.Construct a new WebappLoader with the specified class loader to be defined as the parent of the ClassLoader we ultimately create.- Parameters:
- parent- The parent class loader
 
 
- 
 - 
Method Detail- 
getClassLoaderpublic java.lang.ClassLoader getClassLoader() Return the Java class loader to be used by this Container.- Specified by:
- getClassLoaderin interface- Loader
- Returns:
- the Java class loader to be used by this Container.
 
 - 
getContextpublic Context getContext() - Specified by:
- getContextin interface- Loader
- Returns:
- the Context with which this Loader has been associated.
 
 - 
setContextpublic void setContext(Context context) Description copied from interface:LoaderSet the Context with which this Loader has been associated.- Specified by:
- setContextin interface- Loader
- Parameters:
- context- The associated Context
 
 - 
getDelegatepublic boolean getDelegate() Return the "follow standard delegation model" flag used to configure our ClassLoader.- Specified by:
- getDelegatein interface- Loader
- Returns:
- the "follow standard delegation model" flag used to configure our ClassLoader.
 
 - 
setDelegatepublic void setDelegate(boolean delegate) Set the "follow standard delegation model" flag used to configure our ClassLoader.- Specified by:
- setDelegatein interface- Loader
- Parameters:
- delegate- The new flag
 
 - 
getLoaderClasspublic java.lang.String getLoaderClass() - Returns:
- the ClassLoader class name.
 
 - 
setLoaderClasspublic void setLoaderClass(java.lang.String loaderClass) Set the ClassLoader class name.- Parameters:
- loaderClass- The new ClassLoader class name
 
 - 
setLoaderInstancepublic void setLoaderInstance(WebappClassLoaderBase loaderInstance) Set the ClassLoader instance, without relying on reflection This method will also invokesetLoaderClass(String)withloaderInstance.getClass().getName()as an argument- Parameters:
- loaderInstance- The new ClassLoader instance to use
 
 - 
getReloadablepublic boolean getReloadable() Return the reloadable flag for this Loader.- Specified by:
- getReloadablein interface- Loader
- Returns:
- the reloadable flag for this Loader.
 
 - 
setReloadablepublic void setReloadable(boolean reloadable) Set the reloadable flag for this Loader.- Specified by:
- setReloadablein interface- Loader
- Parameters:
- reloadable- The new reloadable flag
 
 - 
addPropertyChangeListenerpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener) Add a property change listener to this component.- Specified by:
- addPropertyChangeListenerin interface- Loader
- Parameters:
- listener- The listener to add
 
 - 
backgroundProcesspublic void backgroundProcess() Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.- Specified by:
- backgroundProcessin interface- Loader
 
 - 
getLoaderRepositoriespublic java.lang.String[] getLoaderRepositories() 
 - 
getLoaderRepositoriesStringpublic java.lang.String getLoaderRepositoriesString() 
 - 
getClasspathpublic java.lang.String getClasspath() Classpath, as set in org.apache.catalina.jsp_classpath context property- Returns:
- The classpath
 
 - 
modifiedpublic boolean modified() Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?
 - 
removePropertyChangeListenerpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener) Remove a property change listener from this component.- Specified by:
- removePropertyChangeListenerin interface- Loader
- Parameters:
- listener- The listener to remove
 
 - 
toStringpublic java.lang.String toString() Return a String representation of this component.- Overrides:
- toStringin class- java.lang.Object
 
 - 
startInternalprotected void startInternal() throws LifecycleExceptionStart associatedClassLoaderand implement the requirements ofLifecycleBase.startInternal().- Specified by:
- startInternalin class- LifecycleBase
- Throws:
- LifecycleException- if this component detects a fatal error that prevents this component from being used
 
 - 
stopInternalprotected void stopInternal() throws LifecycleExceptionStop associatedClassLoaderand implement the requirements ofLifecycleBase.stopInternal().- Specified by:
- stopInternalin class- LifecycleBase
- Throws:
- LifecycleException- if this component detects a fatal error that prevents this component from being used
 
 - 
propertyChangepublic void propertyChange(java.beans.PropertyChangeEvent event) Process property change events from our associated Context.- Specified by:
- propertyChangein interface- java.beans.PropertyChangeListener
- Parameters:
- event- The property change event that has occurred
 
 - 
getDomainInternalprotected java.lang.String getDomainInternal() Description copied from class:LifecycleMBeanBaseMethod implemented by sub-classes to identify the domain in which MBeans should be registered.- Specified by:
- getDomainInternalin class- LifecycleMBeanBase
- Returns:
- The name of the domain to use to register MBeans.
 
 - 
getObjectNameKeyPropertiesprotected java.lang.String getObjectNameKeyProperties() Description copied from class:LifecycleMBeanBaseAllow sub-classes to specify the key properties component of theObjectNamethat will be used to register this component.- Specified by:
- getObjectNameKeyPropertiesin class- LifecycleMBeanBase
- Returns:
- The string representation of the key properties component of the
          desired ObjectName
 
 
- 
 
-