org.apache.catalina.loader

Class WebappLoader

public class WebappLoader extends Object implements Lifecycle, Loader, PropertyChangeListener, MBeanRegistration

Classloader implementation which is specialized for handling web applications in the most efficient way, while being Catalina aware (all accesses to resources are made through the DirContext interface). This class loader supports detection of modified Java classes, which can be used to implement auto-reload support.

This class loader is configured by adding the pathnames of directories, JAR files, and ZIP files with the addRepository() method, prior to calling start(). When a new class is required, these repositories will be consulted first to locate the class. If it is not present, the system class loader will be used instead.

Version: $Revision: 893564 $ $Date: 2009-12-23 17:31:31 +0100 (Wed, 23 Dec 2009) $

Author: Craig R. McClanahan Remy Maucherat

Field Summary
protected LifecycleSupportlifecycle
The lifecycle event support for this component.
protected static StringManagersm
The string manager for this package.
protected PropertyChangeSupportsupport
The property change support for this component.
Constructor Summary
WebappLoader()
Construct a new WebappLoader with no defined parent class loader (so that the actual parent will be the system class loader).
WebappLoader(ClassLoader parent)
Construct a new WebappLoader with the specified class loader to be defined as the parent of the ClassLoader we ultimately create.
Method Summary
voidaddLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.
voidaddPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.
voidaddRepository(String repository)
Add a new repository to the set of repositories for this class loader.
voidbackgroundProcess()
Execute a periodic task, such as reloading, etc.
voidcloseJARs(boolean force)
Used to periodically signal to the classloader to release JAR resources.
voiddestroy()
LifecycleListener[]findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle.
String[]findRepositories()
Return the set of repositories defined for this class loader.
ClassLoadergetClassLoader()
Return the Java class loader to be used by this Container.
StringgetClasspath()
Classpath, as set in org.apache.catalina.jsp_classpath context property
ContainergetContainer()
Return the Container with which this Logger has been associated.
ObjectNamegetController()
booleangetDelegate()
Return the "follow standard delegation model" flag used to configure our ClassLoader.
StringgetInfo()
Return descriptive information about this Loader implementation and the corresponding version number, in the format <description>/<version>.
StringgetLoaderClass()
Return the ClassLoader class name.
String[]getLoaderRepositories()
StringgetLoaderRepositoriesString()
booleangetReloadable()
Return the reloadable flag for this Loader.
String[]getRepositories()
StringgetRepositoriesString()
Extra repositories for this loader
voidinit()
booleanmodified()
Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?
voidpostDeregister()
voidpostRegister(Boolean registrationDone)
voidpreDeregister()
ObjectNamepreRegister(MBeanServer server, ObjectName name)
voidpropertyChange(PropertyChangeEvent event)
Process property change events from our associated Context.
voidremoveLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.
voidremovePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.
voidsetContainer(Container container)
Set the Container with which this Logger has been associated.
voidsetController(ObjectName controller)
voidsetDelegate(boolean delegate)
Set the "follow standard delegation model" flag used to configure our ClassLoader.
voidsetLoaderClass(String loaderClass)
Set the ClassLoader class name.
voidsetReloadable(boolean reloadable)
Set the reloadable flag for this Loader.
voidstart()
Start this component, initializing our associated class loader.
voidstop()
Stop this component, finalizing our associated class loader.
StringtoString()
Return a String representation of this component.

Field Detail

lifecycle

protected LifecycleSupport lifecycle
The lifecycle event support for this component.

sm

protected static final StringManager sm
The string manager for this package.

support

protected PropertyChangeSupport support
The property change support for this component.

Constructor Detail

WebappLoader

public WebappLoader()
Construct a new WebappLoader with no defined parent class loader (so that the actual parent will be the system class loader).

WebappLoader

public WebappLoader(ClassLoader parent)
Construct a new WebappLoader with the specified class loader to be defined as the parent of the ClassLoader we ultimately create.

Parameters: parent The parent class loader

Method Detail

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.

Parameters: listener The listener to add

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.

Parameters: listener The listener to add

addRepository

public void addRepository(String repository)
Add a new repository to the set of repositories for this class loader.

Parameters: repository Repository to be added

backgroundProcess

public void backgroundProcess()
Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.

closeJARs

public void closeJARs(boolean force)
Used to periodically signal to the classloader to release JAR resources.

destroy

public void destroy()

findLifecycleListeners

public LifecycleListener[] findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.

findRepositories

public String[] findRepositories()
Return the set of repositories defined for this class loader. If none are defined, a zero-length array is returned. For security reason, returns a clone of the Array (since String are immutable).

getClassLoader

public ClassLoader getClassLoader()
Return the Java class loader to be used by this Container.

getClasspath

public String getClasspath()
Classpath, as set in org.apache.catalina.jsp_classpath context property

Returns: The classpath

getContainer

public Container getContainer()
Return the Container with which this Logger has been associated.

getController

public ObjectName getController()

getDelegate

public boolean getDelegate()
Return the "follow standard delegation model" flag used to configure our ClassLoader.

getInfo

public String getInfo()
Return descriptive information about this Loader implementation and the corresponding version number, in the format <description>/<version>.

getLoaderClass

public String getLoaderClass()
Return the ClassLoader class name.

getLoaderRepositories

public String[] getLoaderRepositories()

getLoaderRepositoriesString

public String getLoaderRepositoriesString()

getReloadable

public boolean getReloadable()
Return the reloadable flag for this Loader.

getRepositories

public String[] getRepositories()

getRepositoriesString

public String getRepositoriesString()
Extra repositories for this loader

init

public void init()

modified

public boolean modified()
Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?

postDeregister

public void postDeregister()

postRegister

public void postRegister(Boolean registrationDone)

preDeregister

public void preDeregister()

preRegister

public ObjectName preRegister(MBeanServer server, ObjectName name)

propertyChange

public void propertyChange(PropertyChangeEvent event)
Process property change events from our associated Context.

Parameters: event The property change event that has occurred

removeLifecycleListener

public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.

Parameters: listener The listener to remove

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.

Parameters: listener The listener to remove

setContainer

public void setContainer(Container container)
Set the Container with which this Logger has been associated.

Parameters: container The associated Container

setController

public void setController(ObjectName controller)

setDelegate

public void setDelegate(boolean delegate)
Set the "follow standard delegation model" flag used to configure our ClassLoader.

Parameters: delegate The new flag

setLoaderClass

public void setLoaderClass(String loaderClass)
Set the ClassLoader class name.

Parameters: loaderClass The new ClassLoader class name

setReloadable

public void setReloadable(boolean reloadable)
Set the reloadable flag for this Loader.

Parameters: reloadable The new reloadable flag

start

public void start()
Start this component, initializing our associated class loader.

Throws: LifecycleException if a lifecycle error occurs

stop

public void stop()
Stop this component, finalizing our associated class loader.

Throws: LifecycleException if a lifecycle error occurs

toString

public String toString()
Return a String representation of this component.
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.