Package hudson

Class PluginFirstClassLoader2

  • All Implemented Interfaces:
    Closeable, AutoCloseable, JenkinsClassLoader

    @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
    public class PluginFirstClassLoader2
    extends URLClassLoader2
    Class loader that consults the plugin's WEB-INF/lib/*.jar and WEB-INF/classes directories and the Jenkins core class loader (in that order).

    To use this class loader, set pluginFirstClassLoader to true in the maven-hpi-plugin configuration.

    Author:
    Basil Crow
    • Constructor Detail

      • PluginFirstClassLoader2

        public PluginFirstClassLoader2​(@NonNull
                                       URL[] urls,
                                       @NonNull
                                       ClassLoader parent)
    • Method Detail

      • getResource

        public URL getResource​(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. This method searches for resources in the following order:

        1. Invoke URLClassLoader.findResource(String) to find the resource.

        2. Invoke getResource(String) on the parent class loader.

        Overrides:
        getResource in class ClassLoader
        Parameters:
        name - The resource name
        Returns:
        URL object for reading the resource; null if the resource could not be found, a URL could not be constructed to locate the resource, the resource is in a package that is not opened unconditionally, or access to the resource is denied by the security manager.
        Throws:
        NullPointerException - If name is null
      • getResources

        public Enumeration<URL> getResources​(String name)
                                      throws IOException
        Find all the resources 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. This method first invokes URLClassLoader.findResources(String) to find the resources with the name in this class loader. Finally, it invokes getResources(String) on the parent class loader. It returns an enumeration whose elements are the URLs found by searching the URLs found with URLClassLoader.findResources(String), followed by the URLs found by searching the parent class loader.

        Overrides:
        getResources in class ClassLoader
        Parameters:
        name - The resource name
        Returns:
        An enumeration of URL objects for the resource. If no resources could be found, the enumeration will be empty. Resources for which a URL cannot be constructed, which are in a package that is not opened unconditionally, or for which access to the resource is denied by the security manager, are not returned in the enumeration.
        Throws:
        IOException - If I/O errors occur
        NullPointerException - If name is null