Top Description Fields Constructors Methods
com.sun.enterprise.module.impl

pack-priv final Class ModuleClassLoader

extends ClassLoaderProxy
Class Inheritance
Imports
com.sun.enterprise.module.ModuleState, .ModulesRegistry, .HK2Module, com.sun.enterprise.module.common_impl.LogHelper, java.io.IOException, .PrintStream, java.net.URL, java.util.Enumeration, .List, .Vector, java.util.concurrent.locks.ReentrantLock

ClassLoader that loads classes for a module.
Author
dochez

Field Summary

Modifier and TypeField and Description
private volatile boolean
initialized

HK2Module will be initialized when this classloader is consulted for the first time.

private String
private StackTraceElement[]
private final ReentrantLock
private static final String
private final ModuleImpl

Constructor Summary

AccessConstructor and Description
public
ModuleClassLoader(ModuleImpl owner, URL[] shared, ClassLoader parent)

Creates a new instance of ClassLoader

Method Summary

Modifier and TypeMethod and Description
pack-priv void
protected Class<?>
findClass(String name)

Overrides com.sun.enterprise.module.impl.ClassLoaderProxy.findClass.

Finds and loads the class with the specified name from the URL search path.

public ModuleImpl
public URL
getResource(String name)

Overrides java.lang.ClassLoader.getResource.

Finds the resource with the given name.

public Enumeration<URL>
getResources(String name)

Overrides java.lang.ClassLoader.getResources.

Finds all the resources with the given name.

private void
initialize(String name)

Lazily initialize this module if not done so yet.

protected Class<?>
loadClass(String name, boolean resolve)

Overrides java.lang.ClassLoader.loadClass.

Loads the class with the specified binary name.

public void
stop()

Overrides com.sun.enterprise.module.impl.ClassLoaderProxy.stop.

called by the facade class loader when it is garbage collected.

public String
toString()

Overrides com.sun.enterprise.module.impl.ClassLoaderProxy.toString.

Returns a string representation of the object.

Inherited from com.sun.enterprise.module.impl.ClassLoaderProxy:
addDelegateaddURLfindClassfindClassDirectfindResourcefindResourceDirectfindResourcesgetDelegatesloadClassregisterStopEventremoveDelegate

Field Detail

initializedback to summary
private volatile boolean initialized

HK2Module will be initialized when this classloader is consulted for the first time.

initializerClassNameback to summary
private String initializerClassName
initializerThreadback to summary
private StackTraceElement[] initializerThread
lockback to summary
private final ReentrantLock lock

Hides com.sun.enterprise.module.impl.ClassLoaderProxy.lock.

META_INF_SERVICESback to summary
private static final String META_INF_SERVICES
moduleback to summary
private final ModuleImpl module

Constructor Detail

ModuleClassLoaderback to summary
public ModuleClassLoader(ModuleImpl owner, URL[] shared, ClassLoader parent)

Creates a new instance of ClassLoader

Method Detail

dumpStateback to summary
pack-priv void dumpState(PrintStream writer)
findClassback to summary
protected Class<?> findClass(String name) throws ClassNotFoundException

Overrides com.sun.enterprise.module.impl.ClassLoaderProxy.findClass.

Doc from java.net.URLClassLoader.findClass.

Finds and loads the class with the specified name from the URL search path. Any URLs referring to JAR files are loaded and opened as needed until the class is found.

Exceptions
ClassNotFoundException:
if the class could not be found, or if the loader is closed.
getOwnerback to summary
public ModuleImpl getOwner()
getResourceback to summary
public URL getResource(String name)

Overrides java.lang.ClassLoader.getResource.

Doc from java.lang.ClassLoader.getResource.

Finds 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.

Resources in named modules are subject to the encapsulation rules specified by Module.getResourceAsStream. Additionally, and except for the special case where the resource has a name ending with ".class", this method will only find resources in packages of named modules when the package is opened unconditionally (even if the caller of this method is in the same module as the resource).

getResourcesback to summary
public Enumeration<URL> getResources(String name) throws IOException

Overrides java.lang.ClassLoader.getResources.

Doc from java.lang.ClassLoader.getResources.

Finds 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.

Resources in named modules are subject to the encapsulation rules specified by Module.getResourceAsStream. Additionally, and except for the special case where the resource has a name ending with ".class", this method will only find resources in packages of named modules when the package is opened unconditionally (even if the caller of this method is in the same module as the resource).

Exceptions
IOException:
If I/O errors occur
initializeback to summary
private void initialize(String name)

Lazily initialize this module if not done so yet.

loadClassback to summary
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException

Overrides java.lang.ClassLoader.loadClass.

Doc from java.lang.ClassLoader.loadClass.

Loads the class with the specified binary name. The default implementation of this method searches for classes in the following order:

  1. Invoke findLoadedClass(String) to check if the class has already been loaded.

  2. Invoke the loadClass method on the parent class loader. If the parent is null the class loader built into the virtual machine is used, instead.

  3. Invoke the findClass(String) method to find the class.

If the class was found using the above steps, and the resolve flag is true, this method will then invoke the resolveClass(Class) method on the resulting Class object.

Subclasses of ClassLoader are encouraged to override findClass(String), rather than this method.

Unless overridden, this method synchronizes on the result of getClassLoadingLock method during the entire class loading process.

Exceptions
ClassNotFoundException:
If the class could not be found
stopback to summary
public void stop()

Overrides com.sun.enterprise.module.impl.ClassLoaderProxy.stop.

called by the facade class loader when it is garbage collected. this is a good time to see if this module should be unloaded.

Annotations
@Override
toStringback to summary
public String toString()

Overrides com.sun.enterprise.module.impl.ClassLoaderProxy.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.