Class WebAppClassLoader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ClassVisibilityChecker
    Direct Known Subclasses:
    CachingWebAppClassLoader

    @Deprecated(since="2021-05-27")
    public class WebAppClassLoader
    extends java.net.URLClassLoader
    implements ClassVisibilityChecker
    Deprecated.
    The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.
    ClassLoader for HttpContext.

    Specializes URLClassLoader with some utility and file mapping methods.

    This loader defaults to the 2.3 servlet spec behavior where non system classes are loaded from the classpath in preference to the parent loader. Java2 compliant loading, where the parent loader always has priority, can be selected with the WebAppContext.setParentLoaderPriority(boolean) method and influenced with WebAppContext.isServerClass(String) and WebAppContext.isSystemClass(String).

    If no parent class loader is provided, then the current thread context classloader will be used. If that is null then the classloader that loaded this class is used as the parent.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  WebAppClassLoader.Context
      Deprecated.
      The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addClassFileTransformer​(java.lang.instrument.ClassFileTransformer transformer)
      void addClassPath​(java.lang.String classPath)
      Deprecated.
       
      void addClassPath​(Resource resource)
      Deprecated.
       
      void addJars​(Resource lib)
      Deprecated.
      Add elements to the class path for the context from the jar and zip files found in the specified resource.
      void addTransformer​(java.lang.instrument.ClassFileTransformer transformer)
      Deprecated.
       
      void close()
      Deprecated.
       
      WebAppClassLoader.Context getContext()
      Deprecated.
       
      java.lang.String getName()
      Deprecated.
       
      java.security.PermissionCollection getPermissions​(java.security.CodeSource cs)
      Deprecated.
       
      java.net.URL getResource​(java.lang.String name)
      Deprecated.
      Get a resource from the classloader NOTE: this method provides a convenience of hacking off a leading / should one be present.
      java.util.Enumeration<java.net.URL> getResources​(java.lang.String name)
      Deprecated.
       
      boolean isServerClass​(java.lang.Class<?> clazz)
      Deprecated.
      Is the class a Server Class.
      boolean isSystemClass​(java.lang.Class<?> clazz)
      Deprecated.
      Is the class a System Class.
      boolean removeClassFileTransformer​(java.lang.instrument.ClassFileTransformer transformer)
      boolean removeTransformer​(java.lang.instrument.ClassFileTransformer transformer)
      Deprecated.
       
      static <T> T runWithServerClassAccess​(java.security.PrivilegedExceptionAction<T> action)
      Deprecated.
      Run an action with access to ServerClasses
      void setName​(java.lang.String name)
      Deprecated.
       
      java.lang.String toString()
      Deprecated.
       
      • Methods inherited from class java.net.URLClassLoader

        findResource, findResources, getResourceAsStream, getURLs, newInstance, newInstance
      • Methods inherited from class java.lang.ClassLoader

        clearAssertionStatus, getDefinedPackage, getDefinedPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • WebAppClassLoader

        public WebAppClassLoader​(WebAppClassLoader.Context context)
                          throws java.io.IOException
        Deprecated.
        Constructor.
        Parameters:
        context - the context for this classloader
        Throws:
        java.io.IOException - if unable to initialize from context
      • WebAppClassLoader

        public WebAppClassLoader​(java.lang.ClassLoader parent,
                                 WebAppClassLoader.Context context)
                          throws java.io.IOException
        Deprecated.
        Constructor.
        Parameters:
        parent - the parent classloader
        context - the context for this classloader
        Throws:
        java.io.IOException - if unable to initialize classloader
    • Method Detail

      • runWithServerClassAccess

        public static <T> T runWithServerClassAccess​(java.security.PrivilegedExceptionAction<T> action)
                                              throws java.lang.Exception
        Deprecated.
        Run an action with access to ServerClasses

        Run the passed PrivilegedExceptionAction with the classloader configured so as to allow server classes to be visible

        Type Parameters:
        T - The type returned by the action
        Parameters:
        action - The action to run
        Returns:
        The return from the action
        Throws:
        java.lang.Exception - if thrown by the action
      • getName

        public java.lang.String getName()
        Deprecated.
        Overrides:
        getName in class java.lang.ClassLoader
        Returns:
        the name of the classloader
      • setName

        public void setName​(java.lang.String name)
        Deprecated.
        Parameters:
        name - the name of the classloader
      • addClassPath

        public void addClassPath​(Resource resource)
                          throws java.io.IOException
        Deprecated.
        Parameters:
        resource - Comma or semicolon separated path of filenames or URLs pointing to directories or jar files. Directories should end with '/'.
        Throws:
        java.io.IOException - if unable to add classpath from resource
      • addClassPath

        public void addClassPath​(java.lang.String classPath)
                          throws java.io.IOException
        Deprecated.
        Parameters:
        classPath - Comma or semicolon separated path of filenames or URLs pointing to directories or jar files. Directories should end with '/'.
        Throws:
        java.io.IOException - if unable to add classpath
      • addJars

        public void addJars​(Resource lib)
        Deprecated.
        Add elements to the class path for the context from the jar and zip files found in the specified resource.
        Parameters:
        lib - the resource that contains the jar and/or zip files.
      • getPermissions

        public java.security.PermissionCollection getPermissions​(java.security.CodeSource cs)
        Deprecated.
      • getResources

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

        public java.net.URL getResource​(java.lang.String name)
        Deprecated.
        Get a resource from the classloader NOTE: this method provides a convenience of hacking off a leading / should one be present. This is non-standard and it is recommended to not rely on this behavior
        Overrides:
        getResource in class java.lang.ClassLoader
      • addClassFileTransformer

        @Deprecated
        public void addClassFileTransformer​(java.lang.instrument.ClassFileTransformer transformer)
        Parameters:
        transformer - the transformer to add
      • removeClassFileTransformer

        @Deprecated
        public boolean removeClassFileTransformer​(java.lang.instrument.ClassFileTransformer transformer)
        Parameters:
        transformer - the transformer to remove
        Returns:
        true if transformer was removed
      • addTransformer

        public void addTransformer​(java.lang.instrument.ClassFileTransformer transformer)
        Deprecated.
      • removeTransformer

        public boolean removeTransformer​(java.lang.instrument.ClassFileTransformer transformer)
        Deprecated.
      • close

        public void close()
                   throws java.io.IOException
        Deprecated.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.net.URLClassLoader
        Throws:
        java.io.IOException
      • toString

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

        public boolean isSystemClass​(java.lang.Class<?> clazz)
        Deprecated.
        Description copied from interface: ClassVisibilityChecker
        Is the class a System Class. A System class is a class that is visible to a webapplication, but that cannot be overridden by the contents of WEB-INF/lib or WEB-INF/classes
        Specified by:
        isSystemClass in interface ClassVisibilityChecker
        Parameters:
        clazz - The fully qualified name of the class.
        Returns:
        True if the class is a system class.
      • isServerClass

        public boolean isServerClass​(java.lang.Class<?> clazz)
        Deprecated.
        Description copied from interface: ClassVisibilityChecker
        Is the class a Server Class. A Server class is a class that is part of the implementation of the server and is NIT visible to a webapplication. The web application may provide it's own implementation of the class, to be loaded from WEB-INF/lib or WEB-INF/classes
        Specified by:
        isServerClass in interface ClassVisibilityChecker
        Parameters:
        clazz - The fully qualified name of the class.
        Returns:
        True if the class is a server class.