Class WebappClassLoaderBase

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Lifecycle, WebappProperties, InstrumentableClassLoader, PermissionCheck
    Direct Known Subclasses:
    ParallelWebappClassLoader, WebappClassLoader

    public abstract class WebappClassLoaderBase
    extends java.net.URLClassLoader
    implements Lifecycle, InstrumentableClassLoader, WebappProperties, PermissionCheck
    Specialized web application class loader.

    This class loader is a full reimplementation of the URLClassLoader from the JDK. It is designed to be fully compatible with a normal URLClassLoader, although its internal behavior may be completely different.

    IMPLEMENTATION NOTE - By default, this class loader follows the delegation model required by the specification. The bootstrap class loader will be queried first, then the local repositories, and only then delegation to the parent class loader will occur. This allows the web application to override any shared class except the classes from J2SE. Special handling is provided from the JAXP XML parser interfaces, the JNDI interfaces, and the classes from the servlet API, which are never loaded from the webapp repositories. The delegate property allows an application to modify this behavior to move the parent class loader ahead of the local repositories.

    IMPLEMENTATION NOTE - Due to limitations in Jasper compilation technology, any repository which contains classes from the servlet API will be ignored by the class loader.

    IMPLEMENTATION NOTE - The class loader generates source URLs which include the full JAR URL when a class is loaded from a JAR file, which allows setting security permission at the class level, even when a class is contained inside a JAR.

    IMPLEMENTATION NOTE - Local repositories are searched in the order they are added via the initial constructor.

    IMPLEMENTATION NOTE - No check for sealing violations or security is made unless a security manager is present.

    IMPLEMENTATION NOTE - As of 8.0, this class loader implements InstrumentableClassLoader, permitting web application classes to instrument other classes in the same web application. It does not permit instrumentation of system or container classes or classes in other web apps.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected WebappClassLoaderBase()
      Construct a new ClassLoader with no defined repositories and no parent ClassLoader.
      protected WebappClassLoaderBase​(java.lang.ClassLoader parent)
      Construct a new ClassLoader with no defined repositories and the given parent ClassLoader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLifecycleListener​(LifecycleListener listener)
      Add a LifecycleEvent listener to this component.
      void addTransformer​(java.lang.instrument.ClassFileTransformer transformer)
      Adds the specified class file transformer to this class loader.
      protected void addURL​(java.net.URL url)  
      boolean check​(java.security.Permission permission)
      Does this component have the given permission?
      protected void checkStateForClassLoading​(java.lang.String className)
      Checks that the class loader is in a valid state for class loading.
      protected void checkStateForResourceLoading​(java.lang.String resource)
      Checks that the class loader is in a valid state for resource loading.
      protected void clearReferences()
      Clear references.
      protected void copyStateWithoutTransformers​(WebappClassLoaderBase base)
      Copies the state of this class loader to another, excluding transformers.
      void destroy()
      Prepare to discard the object.
      protected java.lang.Class<?> doDefineClass​(java.lang.String name, byte[] b, int off, int len, java.security.ProtectionDomain protectionDomain)
      Defines a class from byte array.
      protected boolean filter​(java.lang.String name, boolean isClassName)
      Filter classes.
      java.lang.Class<?> findClass​(java.lang.String name)
      Find the specified class in our local repositories, if possible.
      protected java.lang.Class<?> findClassInternal​(java.lang.String name)
      Find specified class in local repositories.
      LifecycleListener[] findLifecycleListeners()
      Get the life cycle listeners associated with this life cycle.
      protected java.lang.Class<?> findLoadedClass0​(java.lang.String name)
      Finds the class with the given name if it has previously been loaded and cached by this class loader, and return the Class object.
      java.net.URL findResource​(java.lang.String name)
      Find the specified resource in our local repository, and return a URL referring to it, or null if this resource cannot be found.
      java.util.Enumeration<java.net.URL> findResources​(java.lang.String name)  
      boolean getClearReferencesHttpClientKeepAliveThread()
      Get the clearReferencesHttpClientKeepAliveThread flag for this Context.
      boolean getClearReferencesLogFactoryRelease()
      Get the clearReferencesLogFactoryRelease flag for this Context.
      boolean getClearReferencesObjectStreamClassCaches()  
      boolean getClearReferencesRmiTargets()
      Returns whether RMI target references should be cleared on reload.
      boolean getClearReferencesStopThreads()
      Get the clearReferencesStopThreads flag for this Context.
      boolean getClearReferencesStopTimerThreads()
      Get the clearReferencesStopTimerThreads flag for this Context.
      boolean getClearReferencesThreadLocals()
      Returns whether ThreadLocal references should be cleared on reload.
      java.lang.String getContextName()
      Get the context name for this class loader.
      boolean getDelegate()
      Return the "delegate first" flag for this class loader.
      java.lang.String getHostName()
      Returns a name for the logging system to use for the Host where the web application, if any, associated with the class loader is deployed.
      protected java.lang.ClassLoader getJavaseClassLoader()
      Returns the Java SE class loader.
      int getNotFoundClassResourceCacheSize()
      Returns the size of the cache for class resources that were not found.
      protected java.security.PermissionCollection getPermissions​(java.security.CodeSource codeSource)
      Get the Permissions for a CodeSource.
      java.net.URL getResource​(java.lang.String name)
      Find the resource with the given name.
      java.io.InputStream getResourceAsStream​(java.lang.String name)
      Find the resource with the given name, and return an input stream that can be used for reading it.
      java.util.Enumeration<java.net.URL> getResources​(java.lang.String name)  
      java.lang.String getServiceName()
      Returns a name for the logging system to use for the Service where the Host, if any, associated with the class loader is deployed.
      boolean getSkipMemoryLeakChecksOnJvmShutdown()
      Returns whether memory leak checks should be skipped on JVM shutdown.
      LifecycleState getState()
      Obtain the current state of the source component.
      java.lang.String getStateName()
      Obtain a textual representation of the current component state.
      java.net.URL[] getURLs()
      java.lang.String getWebappName()
      Returns a name for the logging system to use for the web application, if any, associated with the class loader.
      boolean hasLoggingConfig()
      Enables JULI to determine if the web application includes a local configuration without JULI having to look for the file which it may not have permission to do when running under a SecurityManager.
      void init()
      Prepare the component for starting.
      protected boolean isPackageSealed​(java.lang.String name, java.util.jar.Manifest man)
      Returns true if the specified package name is sealed according to the given manifest.
      java.lang.Class<?> loadClass​(java.lang.String name)
      Load the class with the specified name.
      java.lang.Class<?> loadClass​(java.lang.String name, boolean resolve)
      Load the class with the specified name, searching using the following algorithm until it finds and returns the class.
      boolean modified()
      Have one or more classes or resources been modified so that a reload is appropriate?
      protected void refreshPolicy()
      Refresh the system policy file, to pick up eventual changes.
      void removeLifecycleListener​(LifecycleListener listener)
      Remove a LifecycleEvent listener from this component.
      void removeTransformer​(java.lang.instrument.ClassFileTransformer transformer)
      Removes the specified class file transformer from this class loader.
      void setClearReferencesHttpClientKeepAliveThread​(boolean clearReferencesHttpClientKeepAliveThread)
      Set the clearReferencesHttpClientKeepAliveThread feature for this Context.
      void setClearReferencesLogFactoryRelease​(boolean clearReferencesLogFactoryRelease)
      Set the clearReferencesLogFactoryRelease feature for this Context.
      void setClearReferencesObjectStreamClassCaches​(boolean clearReferencesObjectStreamClassCaches)  
      void setClearReferencesRmiTargets​(boolean clearReferencesRmiTargets)
      Sets whether RMI target references should be cleared on reload.
      void setClearReferencesStopThreads​(boolean clearReferencesStopThreads)
      Set the clearReferencesStopThreads feature for this Context.
      void setClearReferencesStopTimerThreads​(boolean clearReferencesStopTimerThreads)
      Set the clearReferencesStopTimerThreads feature for this Context.
      void setClearReferencesThreadLocals​(boolean clearReferencesThreadLocals)
      Sets whether ThreadLocal references should be cleared on reload.
      void setDelegate​(boolean delegate)
      Set the "delegate first" flag for this class loader.
      protected void setJavaseClassLoader​(java.lang.ClassLoader classLoader)
      Sets the Java SE class loader.
      void setNotFoundClassResourceCacheSize​(int notFoundClassResourceCacheSize)
      Sets the size of the cache for class resources that were not found.
      void setResources​(WebResourceRoot resources)
      Set associated resources.
      void setSkipMemoryLeakChecksOnJvmShutdown​(boolean skipMemoryLeakChecksOnJvmShutdown)
      Sets whether memory leak checks should be skipped on JVM shutdown.
      void start()
      Prepare for the beginning of active use of the public methods other than property getters/setters and life cycle methods of this component.
      void stop()
      Gracefully terminate the active use of the public methods other than property getters/setters and life cycle methods of this component.
      java.lang.String toString()  
      • Methods inherited from class java.net.URLClassLoader

        close, definePackage, newInstance, newInstance
      • Methods inherited from class java.security.SecureClassLoader

        defineClass, defineClass
      • Methods inherited from class java.lang.ClassLoader

        clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • sm

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

        protected WebResourceRoot resources
        Associated web resources for this webapp.
      • resourceEntries

        protected final java.util.Map<java.lang.String,​ResourceEntry> resourceEntries
        The cache of ResourceEntry for classes and resources we have loaded, keyed by resource path, not binary name. Path is used as the key since resources may be requested by binary name (classes) or path (other resources such as property files) and the mapping from binary name to path is unambiguous but the reverse mapping is ambiguous.
      • delegate

        protected boolean delegate
        Should this class loader delegate to the parent class loader before searching its own repositories (i.e. the usual Java2 delegation model)? If set to false, this class loader will search its own repositories first, and delegate to the parent only if the class or resource is not found locally. Note that the default, false, is the behavior called for by the servlet specification.
      • permissionList

        protected final java.util.ArrayList<java.security.Permission> permissionList
        A list of read File Permission's required if this loader is for a web application context.
      • loaderPC

        protected final java.util.HashMap<java.lang.String,​java.security.PermissionCollection> loaderPC
        The PermissionCollection for each CodeSource for a web application context.
      • securityManager

        protected final java.lang.SecurityManager securityManager
        Instance of the SecurityManager installed.
      • parent

        protected final java.lang.ClassLoader parent
        The parent class loader.
    • Constructor Detail

      • WebappClassLoaderBase

        protected WebappClassLoaderBase()
        Construct a new ClassLoader with no defined repositories and no parent ClassLoader.
      • WebappClassLoaderBase

        protected WebappClassLoaderBase​(java.lang.ClassLoader parent)
        Construct a new ClassLoader with no defined repositories and the given parent ClassLoader.

        Method is used via reflection - see WebappLoader.createClassLoader()

        Parameters:
        parent - Our parent class loader
    • Method Detail

      • setNotFoundClassResourceCacheSize

        public void setNotFoundClassResourceCacheSize​(int notFoundClassResourceCacheSize)
        Sets the size of the cache for class resources that were not found.
        Parameters:
        notFoundClassResourceCacheSize - The cache size
      • getNotFoundClassResourceCacheSize

        public int getNotFoundClassResourceCacheSize()
        Returns the size of the cache for class resources that were not found.
        Returns:
        the cache size
      • setResources

        public void setResources​(WebResourceRoot resources)
        Set associated resources.
        Parameters:
        resources - the resources from which the classloader will load the classes
      • getContextName

        public java.lang.String getContextName()
        Get the context name for this class loader.
        Returns:
        the context name
      • getDelegate

        public boolean getDelegate()
        Return the "delegate first" flag for this class loader.
        Returns:
        true if the class lookup will delegate to the parent first. The default in Tomcat is false.
      • setDelegate

        public void setDelegate​(boolean delegate)
        Set the "delegate first" flag for this class loader. If this flag is true, this class loader delegates to the parent class loader before searching its own repositories, as in an ordinary (non-servlet) chain of Java class loaders. If set to false (the default), this class loader will search its own repositories first, and delegate to the parent only if the class or resource is not found locally, as per the servlet specification.
        Parameters:
        delegate - The new "delegate first" flag
      • getClearReferencesRmiTargets

        public boolean getClearReferencesRmiTargets()
        Returns whether RMI target references should be cleared on reload.
        Returns:
        the clearReferencesRmiTargets flag
      • setClearReferencesRmiTargets

        public void setClearReferencesRmiTargets​(boolean clearReferencesRmiTargets)
        Sets whether RMI target references should be cleared on reload.
        Parameters:
        clearReferencesRmiTargets - The new value
      • getClearReferencesStopThreads

        public boolean getClearReferencesStopThreads()
        Get the clearReferencesStopThreads flag for this Context.
        Returns:
        the clearReferencesStopThreads flag
      • setClearReferencesStopThreads

        public void setClearReferencesStopThreads​(boolean clearReferencesStopThreads)
        Set the clearReferencesStopThreads feature for this Context.
        Parameters:
        clearReferencesStopThreads - The new flag value
      • getClearReferencesStopTimerThreads

        public boolean getClearReferencesStopTimerThreads()
        Get the clearReferencesStopTimerThreads flag for this Context.
        Returns:
        the clearReferencesStopTimerThreads flag
      • setClearReferencesStopTimerThreads

        public void setClearReferencesStopTimerThreads​(boolean clearReferencesStopTimerThreads)
        Set the clearReferencesStopTimerThreads feature for this Context.
        Parameters:
        clearReferencesStopTimerThreads - The new flag value
      • getClearReferencesLogFactoryRelease

        public boolean getClearReferencesLogFactoryRelease()
        Get the clearReferencesLogFactoryRelease flag for this Context.
        Returns:
        the clearReferencesLogFactoryRelease flag
      • setClearReferencesLogFactoryRelease

        public void setClearReferencesLogFactoryRelease​(boolean clearReferencesLogFactoryRelease)
        Set the clearReferencesLogFactoryRelease feature for this Context.
        Parameters:
        clearReferencesLogFactoryRelease - The new flag value
      • getClearReferencesHttpClientKeepAliveThread

        public boolean getClearReferencesHttpClientKeepAliveThread()
        Get the clearReferencesHttpClientKeepAliveThread flag for this Context.
        Returns:
        the clearReferencesHttpClientKeepAliveThread flag
      • setClearReferencesHttpClientKeepAliveThread

        public void setClearReferencesHttpClientKeepAliveThread​(boolean clearReferencesHttpClientKeepAliveThread)
        Set the clearReferencesHttpClientKeepAliveThread feature for this Context.
        Parameters:
        clearReferencesHttpClientKeepAliveThread - The new flag value
      • getClearReferencesObjectStreamClassCaches

        public boolean getClearReferencesObjectStreamClassCaches()
      • setClearReferencesObjectStreamClassCaches

        public void setClearReferencesObjectStreamClassCaches​(boolean clearReferencesObjectStreamClassCaches)
      • getClearReferencesThreadLocals

        public boolean getClearReferencesThreadLocals()
        Returns whether ThreadLocal references should be cleared on reload.
        Returns:
        the clearReferencesThreadLocals flag
      • setClearReferencesThreadLocals

        public void setClearReferencesThreadLocals​(boolean clearReferencesThreadLocals)
        Sets whether ThreadLocal references should be cleared on reload.
        Parameters:
        clearReferencesThreadLocals - The new value
      • getSkipMemoryLeakChecksOnJvmShutdown

        public boolean getSkipMemoryLeakChecksOnJvmShutdown()
        Returns whether memory leak checks should be skipped on JVM shutdown.
        Returns:
        the skipMemoryLeakChecksOnJvmShutdown flag
      • setSkipMemoryLeakChecksOnJvmShutdown

        public void setSkipMemoryLeakChecksOnJvmShutdown​(boolean skipMemoryLeakChecksOnJvmShutdown)
        Sets whether memory leak checks should be skipped on JVM shutdown.
        Parameters:
        skipMemoryLeakChecksOnJvmShutdown - The new value
      • addTransformer

        public void addTransformer​(java.lang.instrument.ClassFileTransformer transformer)
        Description copied from interface: InstrumentableClassLoader
        Adds the specified class file transformer to this class loader. The transformer will then be able to instrument the bytecode of any classes loaded by this class loader after the invocation of this method.
        Specified by:
        addTransformer in interface InstrumentableClassLoader
        Parameters:
        transformer - The transformer to add to the class loader
      • removeTransformer

        public void removeTransformer​(java.lang.instrument.ClassFileTransformer transformer)
        Description copied from interface: InstrumentableClassLoader
        Removes the specified class file transformer from this class loader. It will no longer be able to instrument the byte code of any classes loaded by the class loader after the invocation of this method. However, any classes already instrumented by this transformer before this method call will remain in their instrumented state.
        Specified by:
        removeTransformer in interface InstrumentableClassLoader
        Parameters:
        transformer - The transformer to remove
      • copyStateWithoutTransformers

        protected void copyStateWithoutTransformers​(WebappClassLoaderBase base)
        Copies the state of this class loader to another, excluding transformers.
        Parameters:
        base - The target class loader
      • modified

        public boolean modified()
        Have one or more classes or resources been modified so that a reload is appropriate?
        Returns:
        true if there's been a modification
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • doDefineClass

        protected final java.lang.Class<?> doDefineClass​(java.lang.String name,
                                                         byte[] b,
                                                         int off,
                                                         int len,
                                                         java.security.ProtectionDomain protectionDomain)
        Defines a class from byte array. Exposed for use by tests.
        Parameters:
        name - The class name
        b - The byte array
        off - The offset
        len - The length
        protectionDomain - The protection domain
        Returns:
        the defined class
      • findClass

        public java.lang.Class<?> findClass​(java.lang.String name)
                                     throws java.lang.ClassNotFoundException
        Find the specified class in our local repositories, if possible. If not found, throw ClassNotFoundException.
        Overrides:
        findClass in class java.net.URLClassLoader
        Parameters:
        name - The binary name of the class to be loaded
        Throws:
        java.lang.ClassNotFoundException - if the class was not found
      • findResource

        public java.net.URL findResource​(java.lang.String name)
        Find the specified resource in our local repository, and return a URL referring to it, or null if this resource cannot be found.
        Overrides:
        findResource in class java.net.URLClassLoader
        Parameters:
        name - Name of the resource to be found
      • findResources

        public java.util.Enumeration<java.net.URL> findResources​(java.lang.String name)
                                                          throws java.io.IOException
        Overrides:
        findResources in class java.net.URLClassLoader
        Throws:
        java.io.IOException
      • getResource

        public java.net.URL getResource​(java.lang.String name)
        Find the resource with the given name. A resource is some data (images, audio, text, etc.) that can be accessed by class code in a way that is independent of the location of the code. The name of a resource is a "/"-separated path name that identifies the resource. If the resource cannot be found, return null.

        This method searches according to the following algorithm, returning as soon as it finds the appropriate URL. If the resource cannot be found, returns null.

        • If the delegate property is set to true, call the getResource() method of the parent class loader, if any.
        • Call findResource() to find this resource in our locally defined repositories.
        • Call the getResource() method of the parent class loader, if any.
        Overrides:
        getResource in class java.lang.ClassLoader
        Parameters:
        name - Name of the resource to return a URL for
      • getResources

        public java.util.Enumeration<java.net.URL> getResources​(java.lang.String name)
                                                         throws java.io.IOException
        Overrides:
        getResources in class java.lang.ClassLoader
        Throws:
        java.io.IOException
      • getResourceAsStream

        public java.io.InputStream getResourceAsStream​(java.lang.String name)
        Find the resource with the given name, and return an input stream that can be used for reading it. The search order is as described for getResource(), after checking to see if the resource data has been previously cached. If the resource cannot be found, return null.
        Overrides:
        getResourceAsStream in class java.net.URLClassLoader
        Parameters:
        name - Name of the resource to return an input stream for
      • loadClass

        public java.lang.Class<?> loadClass​(java.lang.String name)
                                     throws java.lang.ClassNotFoundException
        Load the class with the specified name. This method searches for classes in the same manner as loadClass(String, boolean) with false as the second argument.
        Overrides:
        loadClass in class java.lang.ClassLoader
        Parameters:
        name - The binary name of the class to be loaded
        Throws:
        java.lang.ClassNotFoundException - if the class was not found
      • loadClass

        public java.lang.Class<?> loadClass​(java.lang.String name,
                                            boolean resolve)
                                     throws java.lang.ClassNotFoundException
        Load the class with the specified name, searching using the following algorithm until it finds and returns the class. If the class cannot be found, returns ClassNotFoundException.
        • Call findLoadedClass(String) to check if the class has already been loaded. If it has, the same Class object is returned.
        • If the delegate property is set to true, call the loadClass() method of the parent class loader, if any.
        • Call findClass() to find this class in our locally defined repositories.
        • Call the loadClass() method of our parent class loader, if any.
        If the class was found using the above steps, and the resolve flag is true, this method will then call resolveClass(Class) on the resulting Class object.
        Overrides:
        loadClass in class java.lang.ClassLoader
        Parameters:
        name - The binary name of the class to be loaded
        resolve - If true then resolve the class
        Throws:
        java.lang.ClassNotFoundException - if the class was not found
      • checkStateForClassLoading

        protected void checkStateForClassLoading​(java.lang.String className)
                                          throws java.lang.ClassNotFoundException
        Checks that the class loader is in a valid state for class loading.
        Parameters:
        className - The class being loaded
        Throws:
        java.lang.ClassNotFoundException - If the class loader is not in a valid state
      • checkStateForResourceLoading

        protected void checkStateForResourceLoading​(java.lang.String resource)
                                             throws java.lang.IllegalStateException
        Checks that the class loader is in a valid state for resource loading.
        Parameters:
        resource - The resource being loaded
        Throws:
        java.lang.IllegalStateException - If the class loader is not in a valid state
      • getPermissions

        protected java.security.PermissionCollection getPermissions​(java.security.CodeSource codeSource)
        Get the Permissions for a CodeSource. If this instance of WebappClassLoaderBase is for a web application context, add read FilePermission for the appropriate resources.
        Overrides:
        getPermissions in class java.net.URLClassLoader
        Parameters:
        codeSource - where the code was loaded from
        Returns:
        PermissionCollection for CodeSource
      • check

        public boolean check​(java.security.Permission permission)
        Description copied from interface: PermissionCheck
        Does this component have the given permission?
        Specified by:
        check in interface PermissionCheck
        Parameters:
        permission - The permission to test
        Returns:
        false if a SecurityManager is enabled and the component does not have the given permission, otherwise true
      • getURLs

        public java.net.URL[] getURLs()

        Note that list of URLs returned by this method may not be complete. The web application class loader accesses class loader resources via the WebResourceRoot which supports the arbitrary mapping of additional files, directories and contents of JAR files under WEB-INF/classes. Any such resources will not be included in the URLs returned here.

        Overrides:
        getURLs in class java.net.URLClassLoader
      • addLifecycleListener

        public void addLifecycleListener​(LifecycleListener listener)
        Description copied from interface: Lifecycle
        Add a LifecycleEvent listener to this component.
        Specified by:
        addLifecycleListener in interface Lifecycle
        Parameters:
        listener - The listener to add
      • findLifecycleListeners

        public LifecycleListener[] findLifecycleListeners()
        Description copied from interface: Lifecycle
        Get the life cycle listeners associated with this life cycle.
        Specified by:
        findLifecycleListeners in interface Lifecycle
        Returns:
        An array containing the life cycle listeners associated with this life cycle. If this component has no listeners registered, a zero-length array is returned.
      • removeLifecycleListener

        public void removeLifecycleListener​(LifecycleListener listener)
        Description copied from interface: Lifecycle
        Remove a LifecycleEvent listener from this component.
        Specified by:
        removeLifecycleListener in interface Lifecycle
        Parameters:
        listener - The listener to remove
      • getState

        public LifecycleState getState()
        Description copied from interface: Lifecycle
        Obtain the current state of the source component.
        Specified by:
        getState in interface Lifecycle
        Returns:
        The current state of the source component.
      • getStateName

        public java.lang.String getStateName()
        Description copied from interface: Lifecycle
        Obtain a textual representation of the current component state. Useful for JMX. The format of this string may vary between point releases and should not be relied upon to determine component state. To determine component state, use Lifecycle.getState().
        Specified by:
        getStateName in interface Lifecycle
        Returns:
        The name of the current component state.
      • init

        public void init()
        Description copied from interface: Lifecycle
        Prepare the component for starting. This method should perform any initialization required post object creation. The following LifecycleEvents will be fired in the following order:
        1. INIT_EVENT: On the successful completion of component initialization.
        Specified by:
        init in interface Lifecycle
      • start

        public void start()
                   throws LifecycleException
        Description copied from interface: Lifecycle
        Prepare for the beginning of active use of the public methods other than property getters/setters and life cycle methods of this component. This method should be called before any of the public methods other than property getters/setters and life cycle methods of this component are utilized. The following LifecycleEvents will be fired in the following order:
        1. BEFORE_START_EVENT: At the beginning of the method. It is as this point the state transitions to LifecycleState.STARTING_PREP.
        2. START_EVENT: During the method once it is safe to call start() for any child components. It is at this point that the state transitions to LifecycleState.STARTING and that the public methods other than property getters/setters and life cycle methods may be used.
        3. AFTER_START_EVENT: At the end of the method, immediately before it returns. It is at this point that the state transitions to LifecycleState.STARTED.
        Specified by:
        start in interface Lifecycle
        Throws:
        LifecycleException - if this component detects a fatal error that prevents this component from being used
      • stop

        public void stop()
                  throws LifecycleException
        Description copied from interface: Lifecycle
        Gracefully terminate the active use of the public methods other than property getters/setters and life cycle methods of this component. Once the STOP_EVENT is fired, the public methods other than property getters/setters and life cycle methods should not be used. The following LifecycleEvents will be fired in the following order:
        1. BEFORE_STOP_EVENT: At the beginning of the method. It is at this point that the state transitions to LifecycleState.STOPPING_PREP.
        2. STOP_EVENT: During the method once it is safe to call stop() for any child components. It is at this point that the state transitions to LifecycleState.STOPPING and that the public methods other than property getters/setters and life cycle methods may no longer be used.
        3. AFTER_STOP_EVENT: At the end of the method, immediately before it returns. It is at this point that the state transitions to LifecycleState.STOPPED.
        Note that if transitioning from LifecycleState.FAILED then the three events above will be fired but the component will transition directly from LifecycleState.FAILED to LifecycleState.STOPPING, bypassing LifecycleState.STOPPING_PREP
        Specified by:
        stop in interface Lifecycle
        Throws:
        LifecycleException - if this component detects a fatal error that needs to be reported
      • destroy

        public void destroy()
        Description copied from interface: Lifecycle
        Prepare to discard the object. The following LifecycleEvents will be fired in the following order:
        1. DESTROY_EVENT: On the successful completion of component destruction.
        Specified by:
        destroy in interface Lifecycle
      • getJavaseClassLoader

        protected java.lang.ClassLoader getJavaseClassLoader()
        Returns the Java SE class loader.
        Returns:
        the Java SE class loader
      • setJavaseClassLoader

        protected void setJavaseClassLoader​(java.lang.ClassLoader classLoader)
        Sets the Java SE class loader.
        Parameters:
        classLoader - The Java SE class loader
        Throws:
        java.lang.IllegalArgumentException - If the class loader is null
      • clearReferences

        protected void clearReferences()
        Clear references.
      • findClassInternal

        protected java.lang.Class<?> findClassInternal​(java.lang.String name)
        Find specified class in local repositories.
        Parameters:
        name - The binary name of the class to be loaded
        Returns:
        the loaded class, or null if the class isn't found
      • isPackageSealed

        protected boolean isPackageSealed​(java.lang.String name,
                                          java.util.jar.Manifest man)
        Returns true if the specified package name is sealed according to the given manifest.
        Parameters:
        name - Path name to check
        man - Associated manifest
        Returns:
        true if the manifest associated says it is sealed
      • findLoadedClass0

        protected java.lang.Class<?> findLoadedClass0​(java.lang.String name)
        Finds the class with the given name if it has previously been loaded and cached by this class loader, and return the Class object. If this class has not been cached, return null.
        Parameters:
        name - The binary name of the resource to return
        Returns:
        a loaded class
      • refreshPolicy

        protected void refreshPolicy()
        Refresh the system policy file, to pick up eventual changes.
      • filter

        protected boolean filter​(java.lang.String name,
                                 boolean isClassName)
        Filter classes.
        Parameters:
        name - class name
        isClassName - true if name is a class name, false if name is a resource name
        Returns:
        true if the class should be filtered
      • addURL

        protected void addURL​(java.net.URL url)
        Overrides:
        addURL in class java.net.URLClassLoader
      • getWebappName

        public java.lang.String getWebappName()
        Description copied from interface: WebappProperties
        Returns a name for the logging system to use for the web application, if any, associated with the class loader.
        Specified by:
        getWebappName in interface WebappProperties
        Returns:
        The name to use for the web application or null if none is available.
      • getHostName

        public java.lang.String getHostName()
        Description copied from interface: WebappProperties
        Returns a name for the logging system to use for the Host where the web application, if any, associated with the class loader is deployed.
        Specified by:
        getHostName in interface WebappProperties
        Returns:
        The name to use for the Host where the web application is deployed or null if none is available.
      • getServiceName

        public java.lang.String getServiceName()
        Description copied from interface: WebappProperties
        Returns a name for the logging system to use for the Service where the Host, if any, associated with the class loader is deployed.
        Specified by:
        getServiceName in interface WebappProperties
        Returns:
        The name to use for the Service where the Host is deployed or null if none is available.
      • hasLoggingConfig

        public boolean hasLoggingConfig()
        Description copied from interface: WebappProperties
        Enables JULI to determine if the web application includes a local configuration without JULI having to look for the file which it may not have permission to do when running under a SecurityManager.
        Specified by:
        hasLoggingConfig in interface WebappProperties
        Returns:
        true if the web application includes a logging configuration at the standard location of /WEB-INF/classes/logging.properties.