# Class WebappLoader

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.loader.WebappLoader

All Implemented Interfaces:
  `MBeanRegistration, JmxEnabled, Lifecycle, Loader`

public class WebappLoader extends LifecycleMBeanBase implements 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.

## Nested Class Summary

### Nested classes/interfaces inherited from interface Lifecycle

`Lifecycle.SingleUse`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static final StringManager`
`sm`
The string manager for this package.
`protected final PropertyChangeSupport`
`support`
The property change support for this component.

### Fields inherited from interface 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

Constructors
Constructor
Description
`WebappLoader()`
Constructs a new WebappLoader.

## Method Summary

Modifier and Type
Method
Description
`void`
`addPropertyChangeListener(PropertyChangeListener listener)`
Add a property change listener to this component.
`void`
`backgroundProcess()`
Execute a periodic task, such as reloading, etc.
`ClassLoader`
`getClassLoader()`
Return the Java class loader to be used by this Loader.
`String`
`getClasspath()`
Classpath, as set in org.apache.catalina.jsp_classpath context property
`Context`
`getContext()`
Return the Context with which this Loader has been associated.
`boolean`
`getDelegate()`
Return the "follow standard delegation model" flag used to configure our ClassLoader.
`protected String`
`getDomainInternal()`
Method implemented by subclasses to identify the domain in which MBeans should be registered.
`String`
`getJakartaConverter()`
Returns the Jakarta converter profile name.
`String`
`getLoaderClass()`
Returns the ClassLoader class name.
`String[]`
`getLoaderRepositories()`
Returns the loader repositories as an array of URLs.
`String`
`getLoaderRepositoriesString()`
Returns the loader repositories as a colon-separated string.
`protected String`
`getObjectNameKeyProperties()`
Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.
`boolean`
`modified()`
Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?
`void`
`removePropertyChangeListener(PropertyChangeListener listener)`
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`
`setJakartaConverter(String jakartaConverter)`
Set the Jakarta converter.
`void`
`setLoaderClass(String loaderClass)`
Set the ClassLoader class name.
`void`
`setLoaderInstance(WebappClassLoaderBase loaderInstance)`
Set the ClassLoader instance, without relying on reflection This method will also invoke `setLoaderClass(String)` with `loaderInstance.getClass().getName()` as an argument
`protected void`
`startInternal()`
Start associated `ClassLoader` and implement the requirements of `LifecycleBase.startInternal()`.
`protected void`
`stopInternal()`
Stop associated `ClassLoader` and implement the requirements of `LifecycleBase.stopInternal()`.
`String`
`toString()`

### Methods inherited from class LifecycleMBeanBase

`destroyInternal, getDomain, getObjectName, initInternal, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister`

### Methods inherited from class LifecycleBase

`addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### sm

protected static final StringManager sm
The string manager for this package.

### support

protected final PropertyChangeSupport support
The property change support for this component.

## Constructor Details

### WebappLoader

public WebappLoader()
Constructs a new WebappLoader.

## Method Details

### getClassLoader

public ClassLoader getClassLoader()
Description copied from interface: `Loader`
Return the Java class loader to be used by this Loader.

Specified by:
  `getClassLoader` in interface `Loader`
Returns:
  the Java class loader to be used by this Loader

### getContext

public Context getContext()
Description copied from interface: `Loader`
Return the Context with which this Loader has been associated.

Specified by:
  `getContext` in interface `Loader`
Returns:
  the Context with which this Loader has been associated

### setContext

public void setContext(Context context)
Description copied from interface: `Loader`
Set the Context with which this Loader has been associated.

Specified by:
  `setContext` in interface `Loader`
Parameters:
  `context` - The associated Context

### getDelegate

public boolean getDelegate()
Description copied from interface: `Loader`
Return the "follow standard delegation model" flag used to configure our ClassLoader.

Specified by:
  `getDelegate` in interface `Loader`
Returns:
  the "follow standard delegation model" flag used to configure our ClassLoader

### setDelegate

public void setDelegate(boolean delegate)
Description copied from interface: `Loader`
Set the "follow standard delegation model" flag used to configure our ClassLoader.

Specified by:
  `setDelegate` in interface `Loader`
Parameters:
  `delegate` - The new flag

### getJakartaConverter

public String getJakartaConverter()
Returns the Jakarta converter profile name.

Returns:
  a non-null String if the loader will attempt to use the Jakarta converter. The String is the name of the profile used for conversion.

### setJakartaConverter

public void setJakartaConverter(String jakartaConverter)
Set the Jakarta converter.

Parameters:
  `jakartaConverter` - The profile name which will be used by the converter Any invalid profile value will default to the TOMCAT profile, which converts all packages used by Tomcat.

### getLoaderClass

public String getLoaderClass()
Returns the ClassLoader class name.

Returns:
  the ClassLoader class name

### setLoaderClass

public void setLoaderClass(String loaderClass)
Set the ClassLoader class name.

Parameters:
  `loaderClass` - The new ClassLoader class name

### setLoaderInstance

public void setLoaderInstance(WebappClassLoaderBase loaderInstance)
Set the ClassLoader instance, without relying on reflection This method will also invoke `setLoaderClass(String)` with `loaderInstance.getClass().getName()` as an argument

Parameters:
  `loaderInstance` - The new ClassLoader instance to use

### addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: `Loader`
Add a property change listener to this component.

Specified by:
  `addPropertyChangeListener` in interface `Loader`
Parameters:
  `listener` - The listener to add

### backgroundProcess

public void backgroundProcess()
Description copied from interface: `Loader`
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 interface `Loader`

### getLoaderRepositories

public String[] getLoaderRepositories()
Returns the loader repositories as an array of URLs.

Returns:
  array of repository URLs

### getLoaderRepositoriesString

public String getLoaderRepositoriesString()
Returns the loader repositories as a colon-separated string.

Returns:
  colon-separated repository URLs

### getClasspath

public String getClasspath()
Classpath, as set in org.apache.catalina.jsp_classpath context property

Returns:
  The classpath

### modified

public boolean modified()
Description copied from interface: `Loader`
Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?

Specified by:
  `modified` in interface `Loader`
Returns:
  `true` when the repository has been modified, `false` otherwise

### removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: `Loader`
Remove a property change listener from this component.

Specified by:
  `removePropertyChangeListener` in interface `Loader`
Parameters:
  `listener` - The listener to remove

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### startInternal

protected void startInternal() throws LifecycleException
Start associated `ClassLoader` and implement the requirements of `LifecycleBase.startInternal()`.

Specified by:
  `startInternal` in class `LifecycleBase`
Throws:
  `LifecycleException` - if this component detects a fatal error that prevents this component from being used

### stopInternal

protected void stopInternal() throws LifecycleException
Stop associated `ClassLoader` and implement the requirements of `LifecycleBase.stopInternal()`.

Specified by:
  `stopInternal` in class `LifecycleBase`
Throws:
  `LifecycleException` - if this component detects a fatal error that prevents this component from being used

### getDomainInternal

protected String getDomainInternal()
Description copied from class: `LifecycleMBeanBase`
Method implemented by subclasses to identify the domain in which MBeans should be registered.

Specified by:
  `getDomainInternal` in class `LifecycleMBeanBase`
Returns:
  The name of the domain to use to register MBeans.

### getObjectNameKeyProperties

protected String getObjectNameKeyProperties()
Description copied from class: `LifecycleMBeanBase`
Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.

Specified by:
  `getObjectNameKeyProperties` in class `LifecycleMBeanBase`
Returns:
  The string representation of the key properties component of the desired `ObjectName`