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:
PropertyChangeListener
,EventListener
,MBeanRegistration
,JmxEnabled
,Lifecycle
,Loader
Classloader implementation which is specialized for handling web applications in the most efficient way, while being
Catalina aware (all accesses to resources are made through
WebResourceRoot
). 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.Lifecycle
Lifecycle.SingleUse
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final StringManager
The string manager for this package.protected final PropertyChangeSupport
The property change support for this component.Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase
mserver
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a property change listener to this component.void
Execute a periodic task, such as reloading, etc.Return the Java class loader to be used by this Container.Classpath, as set in org.apache.catalina.jsp_classpath context propertyboolean
Return the "follow standard delegation model" flag used to configure our ClassLoader.protected String
Method implemented by sub-classes to identify the domain in which MBeans should be registered.String[]
protected String
Allow sub-classes to specify the key properties component of theObjectName
that will be used to register this component.boolean
Return the reloadable flag for this Loader.boolean
modified()
Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?void
Process property change events from our associated Context.void
Remove a property change listener from this component.void
setContext
(Context context) Set the Context with which this Loader has been associated.void
setDelegate
(boolean delegate) Set the "follow standard delegation model" flag used to configure our ClassLoader.void
setLoaderClass
(String loaderClass) Set the ClassLoader class name.void
setReloadable
(boolean reloadable) Set the reloadable flag for this Loader.protected void
Start associatedClassLoader
and implement the requirements ofLifecycleBase.startInternal()
.protected void
Stop associatedClassLoader
and implement the requirements ofLifecycleBase.stopInternal()
.toString()
Return a String representation of this component.Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
destroyInternal, getDomain, getObjectName, initInternal, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister
Methods inherited from class org.apache.catalina.util.LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
-
Field Details
-
sm
The string manager for this package. -
support
The property change support for this component.
-
-
Constructor Details
-
WebappLoader
public WebappLoader()Construct a new WebappLoader. The parent class loader will be defined byContainer.getParentClassLoader()
. -
WebappLoader
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 Details
-
getClassLoader
Return the Java class loader to be used by this Container.- Specified by:
getClassLoader
in interfaceLoader
- Returns:
- the Java class loader to be used by this Container.
-
getContext
- Specified by:
getContext
in interfaceLoader
- Returns:
- the Context with which this Loader has been associated.
-
setContext
Description copied from interface:Loader
Set the Context with which this Loader has been associated.- Specified by:
setContext
in interfaceLoader
- Parameters:
context
- The associated Context
-
getDelegate
public boolean getDelegate()Return the "follow standard delegation model" flag used to configure our ClassLoader.- Specified by:
getDelegate
in interfaceLoader
- Returns:
- the "follow standard delegation model" flag used to configure our ClassLoader.
-
setDelegate
public void setDelegate(boolean delegate) Set the "follow standard delegation model" flag used to configure our ClassLoader.- Specified by:
setDelegate
in interfaceLoader
- Parameters:
delegate
- The new flag
-
getLoaderClass
- Returns:
- the ClassLoader class name.
-
setLoaderClass
Set the ClassLoader class name.- Parameters:
loaderClass
- The new ClassLoader class name
-
getReloadable
public boolean getReloadable()Return the reloadable flag for this Loader.- Specified by:
getReloadable
in interfaceLoader
- Returns:
- the reloadable flag for this Loader.
-
setReloadable
public void setReloadable(boolean reloadable) Set the reloadable flag for this Loader.- Specified by:
setReloadable
in interfaceLoader
- Parameters:
reloadable
- The new reloadable flag
-
addPropertyChangeListener
Add a property change listener to this component.- Specified by:
addPropertyChangeListener
in interfaceLoader
- Parameters:
listener
- The listener to add
-
backgroundProcess
public 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:
backgroundProcess
in interfaceLoader
-
getLoaderRepositories
-
getLoaderRepositoriesString
-
getClasspath
Classpath, as set in org.apache.catalina.jsp_classpath context property- Returns:
- The classpath
-
modified
public boolean modified()Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded? -
removePropertyChangeListener
Remove a property change listener from this component.- Specified by:
removePropertyChangeListener
in interfaceLoader
- Parameters:
listener
- The listener to remove
-
toString
Return a String representation of this component. -
startInternal
Start associatedClassLoader
and implement the requirements ofLifecycleBase.startInternal()
.- Specified by:
startInternal
in classLifecycleBase
- Throws:
LifecycleException
- if this component detects a fatal error that prevents this component from being used
-
stopInternal
Stop associatedClassLoader
and implement the requirements ofLifecycleBase.stopInternal()
.- Specified by:
stopInternal
in classLifecycleBase
- Throws:
LifecycleException
- if this component detects a fatal error that prevents this component from being used
-
propertyChange
Process property change events from our associated Context.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
event
- The property change event that has occurred
-
getDomainInternal
Description copied from class:LifecycleMBeanBase
Method implemented by sub-classes to identify the domain in which MBeans should be registered.- Specified by:
getDomainInternal
in classLifecycleMBeanBase
- Returns:
- The name of the domain to use to register MBeans.
-
getObjectNameKeyProperties
Description copied from class:LifecycleMBeanBase
Allow sub-classes to specify the key properties component of theObjectName
that will be used to register this component.- Specified by:
getObjectNameKeyProperties
in classLifecycleMBeanBase
- Returns:
- The string representation of the key properties component of the
desired
ObjectName
-
Container.setParentClassLoader(ClassLoader)
to specify the required class loader.