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.


Field Summary
 
Fields inherited from class com.caucho.loader.DynamicClassLoader
_lifecycle
 
Constructor Summary
EnvironmentClassLoader()
          Creates a new environment class loader.
EnvironmentClassLoader(java.lang.ClassLoader parent)
          Creates a new environment class loader.
EnvironmentClassLoader(java.lang.ClassLoader parent, java.lang.String id)
          Creates a new environment class loader.
EnvironmentClassLoader(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.
 void destroy()
          Destroys the class loader.
 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.
 EnvironmentBean getOwner()
          Returns the environment's owner.
 void init()
          Initialize the environment.
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()
           
protected  void sendAddLoaderEventImpl()
          Adds a listener to detect class loader changes.
 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, buildClassPath, buildResourcePathSpecificFirst, buildSourcePath, clearModified, 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, isModified, isModified, isModified, isModifiedNow, loadClass, loadClass, loadClass, loadClassImpl, logModified, make, removeListener, replace, resetDependencyCheckInterval, sendAddLoaderEvent, setDependencyCheckInterval, setEnableDependencyCheck, setGlobalDependencyCheckInterval, setId, 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

public EnvironmentClassLoader()
Creates a new environment class loader.


EnvironmentClassLoader

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


EnvironmentClassLoader

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


EnvironmentClassLoader

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

Method Detail

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


init

public void init()
Initialize the environment.

Overrides:
init in class DynamicClassLoader

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.


sendAddLoaderEventImpl

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

Overrides:
sendAddLoaderEventImpl 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.


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