Class WebappLoader

  • All Implemented Interfaces:
    PropertyChangeListener, EventListener, MBeanRegistration, JmxEnabled, Lifecycle, Loader

    public class WebappLoader
    extends LifecycleMBeanBase
    implements Loader, 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 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
    • Field Detail

      • sm

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

      • WebappLoader

        @Deprecated
        public WebappLoader​(ClassLoader parent)
        Deprecated.
        Use Container.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

      • getClassLoader

        public ClassLoader getClassLoader()
        Return the Java class loader to be used by this Container.
        Specified by:
        getClassLoader in interface Loader
        Returns:
        the Java class loader to be used by this Container.
      • getContext

        public Context getContext()
        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()
        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)
        Set the "follow standard delegation model" flag used to configure our ClassLoader.
        Specified by:
        setDelegate in interface Loader
        Parameters:
        delegate - The new flag
      • getLoaderClass

        public String getLoaderClass()
        Returns:
        the ClassLoader class name.
      • setLoaderClass

        public void setLoaderClass​(String loaderClass)
        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 interface Loader
        Returns:
        the reloadable flag for this Loader.
      • setReloadable

        public void setReloadable​(boolean reloadable)
        Set the reloadable flag for this Loader.
        Specified by:
        setReloadable in interface Loader
        Parameters:
        reloadable - The new reloadable flag
      • 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 interface Loader
      • getLoaderRepositories

        public String[] getLoaderRepositories()
      • getLoaderRepositoriesString

        public String getLoaderRepositoriesString()
      • getClasspath

        public String 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?
        Specified by:
        modified in interface Loader
        Returns:
        true when the repository has been modified, false otherwise
      • toString

        public String toString()
        Return a String representation of this component.
        Overrides:
        toString in class Object
      • getDomainInternal

        protected String 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 class LifecycleMBeanBase
        Returns:
        The name of the domain to use to register MBeans.