com.caucho.loader
Class EnvironmentClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by com.caucho.loader.DynamicClassLoader
                  extended by com.caucho.loader.EnvironmentClassLoader
All Implemented Interfaces:
Make, DynamicClassLoaderMXBean, Dependency
Direct Known Subclasses:
EnhancingClassLoader, SystemClassLoader

public class EnvironmentClassLoader
extends DynamicClassLoader

Class loader which checks for changes in class files and automatically picks up new jars.

DynamicClassLoaders can be chained creating one virtual class loader. From the perspective of the JDK, it's all one classloader. Internally, the class loader chain searches like a classpath.


Constructor Summary
protected EnvironmentClassLoader(java.lang.ClassLoader parent, java.lang.String id)
          Creates a new environment class loader.
 
Method Summary
 void addListener(EnvironmentListener listener)
          Adds a listener to detect environment lifecycle changes.
 void addLoaderListener(AddLoaderListener listener)
          Adds a child listener.
 void addScanListener(ScanListener listener)
          Adds a scan listener.
 void addURL(java.net.URL url)
          Adds the URL to the URLClassLoader.
protected  void buildImportClassPath(java.lang.StringBuilder sb)
           
protected  void configureEnhancerEvent()
          Adds a listener to detect class loader changes.
static EnvironmentClassLoader create()
          Creates a new environment class loader.
static EnvironmentClassLoader create(java.lang.ClassLoader parent)
          Creates a new environment class loader.
static EnvironmentClassLoader create(java.lang.ClassLoader parent, java.lang.String id)
          Creates a new environment class loader.
static EnvironmentClassLoader create(java.lang.String id)
          Creates a new environment class loader.
 void destroy()
          Destroys the class loader.
protected  java.lang.Class findImportClass(java.lang.String name)
          Returns any import class, e.g.
 EnvironmentMXBean getAdmin()
          Returns the admin
 java.lang.Object getAttribute(java.lang.String name)
          Returns the named attributes
 java.lang.Throwable getConfigException()
          Gets the config exception.
protected  java.util.ArrayList<EnvironmentListener> getEnvironmentListeners()
          Returns the listeners.
protected  java.util.ArrayList<AddLoaderListener> getLoaderListeners()
          Returns the listeners.
 OsgiManager getOsgiManager()
          Returns the osgi manager
 EnvironmentBean getOwner()
          Returns the environment's owner.
 void init()
          Initialize the environment.
protected  void initEnvironment()
           
static void initializeEnvironment()
          Initializes the environment
 boolean isActive()
          Returns true if the environment is active
 java.lang.Object removeAttribute(java.lang.String name)
          Removes the named attributes
 void removeListener(EnvironmentListener listener)
          Adds a listener to detect environment lifecycle changes.
protected  void replace(EnvironmentClassLoader source)
          Copies the loader.
 void scan()
           
 java.lang.Object setAttribute(java.lang.String name, java.lang.Object obj)
          Sets the named attributes
 void setConfigException(java.lang.Throwable e)
          Sets the config exception.
 void setOwner(EnvironmentBean owner)
          Sets the environment's owner.
 void start()
          Marks the environment of the class loader as started.
 void stop()
          Stops the environment, closing down any resources.
 java.lang.String toString()
           
 void validate()
          Called when the completes.
 
Methods inherited from class com.caucho.loader.DynamicClassLoader
addCodeBasePath, addDependency, addJar, addJarManifestClassPath, addListener, addLoader, addLoader, addManifestClassPath, addNative, addParentPriorityPackage, addParentPriorityPackages, addPathClass, addPermission, addPermission, addPermissions, addPriorityPackage, addRoot, addTransformer, addURL, addURL, appendToClassPathForInstrumentation, buildClassPath, buildResourcePathSpecificFirst, buildSourcePath, clearModified, containsURL, definePackage, findClass, findClassImpl, findLibrary, findPath, findResources, getClassEntry, getClassPath, getDependencyCheckInterval, getGlobalDependencyCheckInterval, getId, getInstrumentableClassLoader, getListeners, getLoaders, getLocalClassPath, getNewTempClassLoader, getPermissions, getPermissions, getResource, getResourceAsStream, getResourcePathSpecificFirst, getSecurityManager, getSourcePath, getThrowawayClassLoader, getTransformerList, getURLs, isDestroyed, isJarCacheEnabled, isModified, isModified, isModified, isModifiedNow, loadClass, loadClass, loadClass, loadClassImpl, logModified, make, removeListener, replace, resetDependencyCheckInterval, sendAddLoaderEvent, setDependencyCheckInterval, setEnableDependencyCheck, setGlobalDependencyCheckInterval, setId, setJarCacheEnabled, setOldLoader, setServletHack
 
Methods inherited from class java.net.URLClassLoader
definePackage, findResource, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnvironmentClassLoader

protected EnvironmentClassLoader(java.lang.ClassLoader parent,
                                 java.lang.String id)
Creates a new environment class loader.

Method Detail

create

public static EnvironmentClassLoader create()
Creates a new environment class loader.


create

public static EnvironmentClassLoader create(java.lang.String id)
Creates a new environment class loader.


create

public static EnvironmentClassLoader create(java.lang.ClassLoader parent)
Creates a new environment class loader.


create

public static EnvironmentClassLoader create(java.lang.ClassLoader parent,
                                            java.lang.String id)
Creates a new environment class loader.


getOwner

public EnvironmentBean getOwner()
Returns the environment's owner.


setOwner

public void setOwner(EnvironmentBean owner)
Sets the environment's owner.


setConfigException

public void setConfigException(java.lang.Throwable e)
Sets the config exception.


getConfigException

public java.lang.Throwable getConfigException()
Gets the config exception.


isActive

public boolean isActive()
Returns true if the environment is active


getAdmin

public EnvironmentMXBean getAdmin()
Returns the admin


init

public void init()
Initialize the environment.

Overrides:
init in class DynamicClassLoader

initEnvironment

protected void initEnvironment()

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the named attributes


setAttribute

public java.lang.Object setAttribute(java.lang.String name,
                                     java.lang.Object obj)
Sets the named attributes


removeAttribute

public java.lang.Object removeAttribute(java.lang.String name)
Removes the named attributes


addListener

public void addListener(EnvironmentListener listener)
Adds a listener to detect environment lifecycle changes.


removeListener

public void removeListener(EnvironmentListener listener)
Adds a listener to detect environment lifecycle changes.


getEnvironmentListeners

protected java.util.ArrayList<EnvironmentListener> getEnvironmentListeners()
Returns the listeners.


addLoaderListener

public void addLoaderListener(AddLoaderListener listener)
Adds a child listener.


getLoaderListeners

protected java.util.ArrayList<AddLoaderListener> getLoaderListeners()
Returns the listeners.


configureEnhancerEvent

protected void configureEnhancerEvent()
Adds a listener to detect class loader changes.

Overrides:
configureEnhancerEvent in class DynamicClassLoader

addURL

public void addURL(java.net.URL url)
Adds the URL to the URLClassLoader.

Overrides:
addURL in class DynamicClassLoader

addScanListener

public void addScanListener(ScanListener listener)
Adds a scan listener.


getOsgiManager

public OsgiManager getOsgiManager()
Returns the osgi manager


findImportClass

protected java.lang.Class findImportClass(java.lang.String name)
Returns any import class, e.g. from an osgi bundle

Overrides:
findImportClass in class DynamicClassLoader

buildImportClassPath

protected void buildImportClassPath(java.lang.StringBuilder sb)
Overrides:
buildImportClassPath in class DynamicClassLoader

validate

public void validate()
Called when the completes.

Overrides:
validate in class DynamicClassLoader

scan

public void scan()
Overrides:
scan in class DynamicClassLoader

start

public void start()
Marks the environment of the class loader as started. The class loader itself doesn't use this, but a callback might.


stop

public void stop()
Stops the environment, closing down any resources. The resources are closed in the reverse order that they're started

Overrides:
stop in class DynamicClassLoader

replace

protected void replace(EnvironmentClassLoader source)
Copies the loader.


destroy

public void destroy()
Destroys the class loader.

Overrides:
destroy in class DynamicClassLoader

toString

public java.lang.String toString()
Overrides:
toString in class DynamicClassLoader

initializeEnvironment

public static void initializeEnvironment()
Initializes the environment