Top Description Inners Fields Constructors Methods
org.apache.catalina.loader

public Class WebappLoader

extends LifecycleMBeanBase
implements Loader
Class Inheritance
All Implemented Interfaces
org.apache.catalina.Loader
Imports
java.beans.PropertyChangeListener, .PropertyChangeSupport, java.io.File, .FilePermission, .IOException, java.lang.reflect.Constructor, java.net.URL, .URLClassLoader, java.nio.charset.StandardCharsets, javax.management.ObjectName, jakarta.servlet.ServletContext, org.apache.catalina.Context, .Globals, .LifecycleException, .LifecycleState, .Loader, org.apache.catalina.util.LifecycleMBeanBase, .ToStringUtil, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.jakartaee.ClassConverter, .EESpecProfile, .EESpecProfiles, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.buf.UDecoder, org.apache.tomcat.util.compat.JreCompat, org.apache.tomcat.util.modeler.Registry, org.apache.tomcat.util.res.StringManager

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 org.apache.catalina.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.

Authors
Craig R. McClanahan, Remy Maucherat

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private WebappClassLoaderBase
classLoader

The class loader being managed by this Loader component.

private String
classpath

Classpath set in the loader.

private Context
context

The Context with which this Loader has been associated.

private boolean
delegate

The "follow standard delegation model" flag that will be used to configure our ClassLoader.

private String
jakartaConverter

The profile name which will be used by the converter, or null if not used.

private String
loaderClass

The Java class name of the ClassLoader implementation to be used.

private static final Log
protected static final StringManager
sm

Hides org.apache.catalina.util.LifecycleMBeanBase.sm.

The string manager for this package.
protected final PropertyChangeSupport
support

The property change support for this component.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addPropertyChangeListener(PropertyChangeListener
The listener to add
listener
)

Implements org.apache.catalina.Loader.addPropertyChangeListener.

Add a property change listener to this component.

public void
backgroundProcess()

Implements org.apache.catalina.Loader.backgroundProcess.

Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container.

private boolean
private WebappClassLoaderBase
createClassLoader()

Create associated classLoader.

public ClassLoader
getClassLoader()

Implements org.apache.catalina.Loader.getClassLoader.

Return the Java class loader to be used by this Container.

public String

Returns:

The classpath
getClasspath
()

Classpath, as set in org.apache.catalina.jsp_classpath context property

public Context
public boolean
getDelegate()

Implements org.apache.catalina.Loader.getDelegate.

Return the "follow standard delegation model" flag used to configure our ClassLoader.

protected String
getDomainInternal()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getDomainInternal.

Method implemented by sub-classes to identify the domain in which MBeans should be registered.

public String

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.
getJakartaConverter
()

public String

Returns:

the ClassLoader class name.
getLoaderClass
()

public String[]
public String
protected String
getObjectNameKeyProperties()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getObjectNameKeyProperties.

Allow sub-classes to specify the key properties component of the ObjectName that will be used to register this component.

public boolean
modified()

Implements org.apache.catalina.Loader.modified.

Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?

public void
removePropertyChangeListener(PropertyChangeListener
The listener to remove
listener
)

Implements org.apache.catalina.Loader.removePropertyChangeListener.

Remove a property change listener from this component.

private void
setClassPath()

Set the appropriate context attribute for our class path.

public void
setContext(Context
The associated Context
context
)

Implements org.apache.catalina.Loader.setContext.

Set the Context with which this Loader has been associated.

public void
setDelegate(boolean
The new flag
delegate
)

Implements org.apache.catalina.Loader.setDelegate.

Set the "follow standard delegation model" flag used to configure our ClassLoader.

public void
setJakartaConverter(String
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.
jakartaConverter
)

Set the Jakarta converter.

public void
setLoaderClass(String
The new ClassLoader class name
loaderClass
)

Set the ClassLoader class name.

public void
setLoaderInstance(WebappClassLoaderBase
The new ClassLoader instance to use
loaderInstance
)

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

private void
setPermissions()

Configure associated class loader permissions.

protected void
protected void
public String
toString()

Overrides java.lang.Object.toString.

Return a String representation of this component.

Inherited from org.apache.catalina.util.LifecycleMBeanBase:
destroyInternalgetDomaingetObjectNameinitInternalpostDeregisterpostRegisterpreDeregisterpreRegisterregistersetDomainunregisterunregister

Field Detail

classLoaderback to summary
private WebappClassLoaderBase classLoader

The class loader being managed by this Loader component.

classpathback to summary
private String classpath

Classpath set in the loader.

contextback to summary
private Context context

The Context with which this Loader has been associated.

delegateback to summary
private boolean delegate

The "follow standard delegation model" flag that will be used to configure our ClassLoader.

jakartaConverterback to summary
private String jakartaConverter

The profile name which will be used by the converter, or null if not used. Any invalid profile value will default to the TOMCAT profile, which converts all packages used by Tomcat.

loaderClassback to summary
private String loaderClass

The Java class name of the ClassLoader implementation to be used. This class should extend WebappClassLoaderBase, otherwise, a different loader implementation must be used.

logback to summary
private static final Log log

Hides org.apache.catalina.util.LifecycleMBeanBase.log.

smback to summary
protected static final StringManager sm

Hides org.apache.catalina.util.LifecycleMBeanBase.sm.

The string manager for this package.

supportback to summary
protected final PropertyChangeSupport support

The property change support for this component.

Constructor Detail

WebappLoaderback to summary
public WebappLoader()

Method Detail

addPropertyChangeListenerback to summary
public void addPropertyChangeListener(PropertyChangeListener listener)

Implements org.apache.catalina.Loader.addPropertyChangeListener.

Add a property change listener to this component.

Parameters
listener:PropertyChangeListener

The listener to add

Annotations
@Override
backgroundProcessback to summary
public void backgroundProcess()

Implements org.apache.catalina.Loader.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.

Annotations
@Override
buildClassPathback to summary
private boolean buildClassPath(StringBuilder classpath, ClassLoader loader)
createClassLoaderback to summary
private WebappClassLoaderBase createClassLoader() throws Exception

Create associated classLoader.

getClassLoaderback to summary
public ClassLoader getClassLoader()

Implements org.apache.catalina.Loader.getClassLoader.

Return the Java class loader to be used by this Container.

Returns:ClassLoader

Doc from org.apache.catalina.Loader.getClassLoader.

the Java class loader to be used by this Container.

Annotations
@Override
getClasspathback to summary
public String getClasspath()

Classpath, as set in org.apache.catalina.jsp_classpath context property

Returns:String

The classpath

getContextback to summary
public Context getContext()

Implements org.apache.catalina.Loader.getContext.

Returns:Context

Doc from org.apache.catalina.Loader.getContext.

the Context with which this Loader has been associated.

Annotations
@Override
getDelegateback to summary
public boolean getDelegate()

Implements org.apache.catalina.Loader.getDelegate.

Return the "follow standard delegation model" flag used to configure our ClassLoader.

Returns:boolean

Doc from org.apache.catalina.Loader.getDelegate.

the "follow standard delegation model" flag used to configure our ClassLoader.

Annotations
@Override
getDomainInternalback to summary
protected String getDomainInternal()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getDomainInternal.

Doc from org.apache.catalina.util.LifecycleMBeanBase.getDomainInternal.

Method implemented by sub-classes to identify the domain in which MBeans should be registered.

Returns:String

The name of the domain to use to register MBeans.

Annotations
@Override
getJakartaConverterback to summary
public String getJakartaConverter()
Returns:String

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.

getLoaderClassback to summary
public String getLoaderClass()
Returns:String

the ClassLoader class name.

getLoaderRepositoriesback to summary
public String[] getLoaderRepositories()
getLoaderRepositoriesStringback to summary
public String getLoaderRepositoriesString()
getObjectNameKeyPropertiesback to summary
protected String getObjectNameKeyProperties()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getObjectNameKeyProperties.

Doc from org.apache.catalina.util.LifecycleMBeanBase.getObjectNameKeyProperties.

Allow sub-classes to specify the key properties component of the ObjectName that will be used to register this component.

Returns:String

The string representation of the key properties component of the desired ObjectName

Annotations
@Override
modifiedback to summary
public boolean modified()

Implements org.apache.catalina.Loader.modified.

Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?

Returns:boolean

Doc from org.apache.catalina.Loader.modified.

true when the repository has been modified, false otherwise

Annotations
@Override
removePropertyChangeListenerback to summary
public void removePropertyChangeListener(PropertyChangeListener listener)

Implements org.apache.catalina.Loader.removePropertyChangeListener.

Remove a property change listener from this component.

Parameters
listener:PropertyChangeListener

The listener to remove

Annotations
@Override
setClassPathback to summary
private void setClassPath()

Set the appropriate context attribute for our class path. This is required only because Jasper depends on it.

setContextback to summary
public void setContext(Context context)

Implements org.apache.catalina.Loader.setContext.

Doc from org.apache.catalina.Loader.setContext.

Set the Context with which this Loader has been associated.

Parameters
context:Context

The associated Context

Annotations
@Override
setDelegateback to summary
public void setDelegate(boolean delegate)

Implements org.apache.catalina.Loader.setDelegate.

Set the "follow standard delegation model" flag used to configure our ClassLoader.

Parameters
delegate:boolean

The new flag

Annotations
@Override
setJakartaConverterback to summary
public void setJakartaConverter(String jakartaConverter)

Set the Jakarta converter.

Parameters
jakartaConverter:String

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.

setLoaderClassback to summary
public void setLoaderClass(String loaderClass)

Set the ClassLoader class name.

Parameters
loaderClass:String

The new ClassLoader class name

setLoaderInstanceback to summary
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:WebappClassLoaderBase

The new ClassLoader instance to use

setPermissionsback to summary
private void setPermissions()

Configure associated class loader permissions.

startInternalback to summary
protected void startInternal() throws LifecycleException

Implements abstract org.apache.catalina.util.LifecycleBase.startInternal.

Start associated ClassLoader and implement the requirements of org.apache.catalina.util.LifecycleBase#startInternal().

Annotations
@Override
Exceptions
LifecycleException:
if this component detects a fatal error that prevents this component from being used
stopInternalback to summary
protected void stopInternal() throws LifecycleException

Implements abstract org.apache.catalina.util.LifecycleBase.stopInternal.

Stop associated ClassLoader and implement the requirements of org.apache.catalina.util.LifecycleBase#stopInternal().

Annotations
@Override
Exceptions
LifecycleException:
if this component detects a fatal error that prevents this component from being used
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return a String representation of this component.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override
org.apache.catalina.loader back to summary

private Class WebappLoader.MigrationUtil

extends Object
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
addJakartaEETransformer(WebappClassLoaderBase webappClassLoader, String profileName)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MigrationUtilback to summary
private MigrationUtil()

Method Detail

addJakartaEETransformerback to summary
public static void addJakartaEETransformer(WebappClassLoaderBase webappClassLoader, String profileName)