Package com.sun.enterprise.v3.server
Class ClassLoaderHierarchyImpl
- java.lang.Object
-
- com.sun.enterprise.v3.server.ClassLoaderHierarchyImpl
-
- All Implemented Interfaces:
ClassLoaderHierarchy
@Service public class ClassLoaderHierarchyImpl extends Object implements ClassLoaderHierarchy
- Author:
- [email protected]
-
-
Constructor Summary
Constructors Constructor Description ClassLoaderHierarchyImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassLoader
createApplicationParentCL(ClassLoader parent, DeploymentContext context)
Sets up the parent class loader for the application class loader.ClassLoader
getAPIClassLoader()
Returns a ClassLoader that can load classes exported by any OSGi bundle in the system for public use.DelegatingClassLoader.ClassFinder
getAppLibClassFinder(List<URI> libURIs)
Returns ApplibClassFinder.ClassLoader
getAppLibClassLoader(String application, List<URI> libURIs)
Returns AppLibClassLoader.CurrentBeforeParentClassLoader
getCommonClassLoader()
Returns a class loader that is common to all deployed applications.String
getCommonClassPath()
Returns the classpath equiavalent to what is used by classloader returned byClassLoaderHierarchy.getCommonClassLoader()
.DelegatingClassLoader
getConnectorClassLoader(String application)
Returns the class loader which has visibility to appropriate list of standalone RARs deployed in the server.
-
-
-
Method Detail
-
getAPIClassLoader
public ClassLoader getAPIClassLoader()
Description copied from interface:ClassLoaderHierarchy
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.- Specified by:
getAPIClassLoader
in interfaceClassLoaderHierarchy
- Returns:
- a ClassLoader that can load classes exported by any bundles
-
getCommonClassLoader
public CurrentBeforeParentClassLoader getCommonClassLoader()
Description copied from interface:ClassLoaderHierarchy
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.- Specified by:
getCommonClassLoader
in interfaceClassLoaderHierarchy
- Returns:
- ClassLoader common to all deployed applications.
- See Also:
ClassLoaderHierarchy.getAPIClassLoader()
-
getCommonClassPath
public String getCommonClassPath()
Description copied from interface:ClassLoaderHierarchy
Returns the classpath equiavalent to what is used by classloader returned byClassLoaderHierarchy.getCommonClassLoader()
. Classpath entries are separated byFile.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.- Specified by:
getCommonClassPath
in interfaceClassLoaderHierarchy
- Returns:
- ClassPath separated by
File.pathSeparatorChar
-
getConnectorClassLoader
public DelegatingClassLoader getConnectorClassLoader(String application)
Description copied from interface:ClassLoaderHierarchy
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.- Specified by:
getConnectorClassLoader
in interfaceClassLoaderHierarchy
- Parameters:
application
- Application whose class loader hierarchy is being set- Returns:
- class loader which has visibility to appropriate list of standalone RARs.
-
getAppLibClassLoader
public ClassLoader getAppLibClassLoader(String application, List<URI> libURIs) throws MalformedURLException
Description copied from interface:ClassLoaderHierarchy
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.- Specified by:
getAppLibClassLoader
in interfaceClassLoaderHierarchy
- Parameters:
application
- Application for which this class loader is createdlibURIs
- 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
public DelegatingClassLoader.ClassFinder getAppLibClassFinder(List<URI> libURIs) throws MalformedURLException
Description copied from interface:ClassLoaderHierarchy
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.- Specified by:
getAppLibClassFinder
in interfaceClassLoaderHierarchy
- 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
public 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.- Specified by:
createApplicationParentCL
in interfaceClassLoaderHierarchy
- Parameters:
parent
- the parent class loadercontext
- 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.
-
-