Interface ClassLoaderHierarchy

  • All Known Implementing Classes:
    ClassLoaderHierarchyImpl

    @Contract
    public interface ClassLoaderHierarchy
    This class is responsible foe creation of class loader hierarchy of an application.
    Author:
    [email protected]
    • Method Detail

      • getAPIClassLoader

        ClassLoader getAPIClassLoader()
        Returns a ClassLoader that can load classes exported by any OSGi bundle in the system for public use. Such classes include Java EE API, AMX API, appserv-ext API, etc. CommonClassLoader delegates to this class loader.
        Returns:
        a ClassLoader that can load classes exported by any bundles
      • getCommonClassLoader

        CurrentBeforeParentClassLoader getCommonClassLoader()
        Returns a class loader that is common to all deployed applications. Common Class Loader is responsible for loading classes from following URLs (the order is strictly maintained): lib/*.jar:domain_dir/lib/classes:domain_dir/lib/*.jar. Please note that domain_dir/lib/classes comes before domain_dir/lib/*.jar, just like WEB-INF/classes is searched first before WEB-INF/lib/*.jar. It delegates to APIClassLoader.
        Returns:
        ClassLoader common to all deployed applications.
        See Also:
        getAPIClassLoader()
      • getCommonClassPath

        String getCommonClassPath()
        Returns the classpath equiavalent to what is used by classloader returned by getCommonClassLoader(). Classpath entries are separated by File.separatorChar, but don't assume there will be any leading or trailing separator char. It returns an empty string if there are no libraries installed.
        Returns:
        ClassPath separated by File.pathSeparatorChar
      • getConnectorClassLoader

        DelegatingClassLoader getConnectorClassLoader​(String application)
        Returns the class loader which has visibility to appropriate list of standalone RARs deployed in the server. Depending on a policy, this can either return a singleton classloader for all applications or a class loader specific to an application. When a singleton class loader is returned, such a class loader will have visibility to all the standalone RARs deployed in the system. When a class loader specific to an application is returned, such a class loader will have visibility to only standalone RARs that the application depends on.
        Parameters:
        application - Application whose class loader hierarchy is being set
        Returns:
        class loader which has visibility to appropriate list of standalone RARs.
      • getAppLibClassLoader

        ClassLoader getAppLibClassLoader​(String application,
                                         List<URI> libURIs)
                                  throws MalformedURLException
        Returns AppLibClassLoader. As the name suggests, this class loader has visibility to deploy time libraries (--libraries and EXTENSION_LIST of MANIFEST.MF, provided the library is available in 'applibs' directory) for an application. It is different from CommonClassLoader in a sense that the libraries that are part of common class loader are shared by all applications, where as this class loader adds a scope to a library.
        Parameters:
        application - Application for which this class loader is created
        libURIs - list of URIs, where each URI represent a library
        Returns:
        class loader that has visibility to appropriate application specific libraries.
        Throws:
        MalformedURLException
        See Also:
        #getAppLibClassFinder(List)
      • getAppLibClassFinder

        DelegatingClassLoader.ClassFinder getAppLibClassFinder​(List<URI> libURIs)
                                                        throws MalformedURLException
        Returns ApplibClassFinder. As the name suggests, this class finder has visibility to deploy time libraries (--libraries and EXTENSION_LIST of MANIFEST.MF, provided the library is available in 'applibs' directory) for an application. It is different from CommonClassLoader in a sense that the libraries that are part of common class loader are shared by all applications, where as this class loader adds a scope to a library.
        NOTE : Difference between this API and getAppLibClassLoader(String, List<URI>) is the latter will be used by all applications (for its parent classloader) whereas this API will be used only by connector classloader. All other application classloaders will have AppLibClassLoader as parent where as connector classloader will be above AppLibClassLoader and hence simple delegation is not feasible.
        Parameters:
        libURIs - list of URIs, where each URI represent a library
        Returns:
        class loader that has visibility to appropriate application specific libraries.
        Throws:
        MalformedURLException
        See Also:
        #getAppLibClassLoader(String, List)
      • createApplicationParentCL

        ClassLoader createApplicationParentCL​(ClassLoader parent,
                                              DeploymentContext context)
                                       throws com.sun.enterprise.module.ResolveError
        Sets up the parent class loader for the application class loader. Application class loader are under the control of the ArchiveHandler since a special archive file format will require a specific class loader. However GlassFish needs to be able to add capabilities to the application like adding APIs accessibility, this is done through its parent class loader which we create and maintain.
        Parameters:
        parent - the parent class loader
        context - deployment context
        Returns:
        class loader capable of loading public APIs identified by the deployers
        Throws:
        com.sun.enterprise.module.ResolveError - if one of the deployer's public API module is not found.