Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 7.0.29
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.catalina.loader
Class WebappLoader

    java.lang.Object
      org.apache.catalina.util.LifecycleBase
          org.apache.catalina.util.LifecycleMBeanBase
              org.apache.catalina.loader.WebappLoader

All Implemented Interfaces:
  PropertyChangeListener, EventListener, MBeanRegistration, Lifecycle, Loader

Direct Known Subclasses:
  VirtualWebappLoader

    public class WebappLoader

extends LifecycleMBeanBase
implements Loader, PropertyChangeListener

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:
  $Id: WebappLoader.java 1232850 2012-01-18 12:05:43Z markt $
Author:
  Craig R. McClanahan, Remy Maucherat

Field Summary
`protected static StringManager` | `sm` The string manager for this package.
`protected PropertyChangeSupport` | `support` The property change support for this component.

Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase
`mserver`

Fields inherited from interface org.apache.catalina.Lifecycle
`AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT`

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
`void` | `addPropertyChangeListener(PropertyChangeListener listener)` Add a property change listener to this component.
`void` | `addRepository(String repository)` Add a new repository to the set of repositories for this class loader.
`void` | `backgroundProcess()` Execute a periodic task, such as reloading, etc.
`void` | `closeJARs(boolean force)` Used to periodically signal to the classloader to release JAR resources.
`String[]` | `findRepositories()` Return the set of repositories defined for this class loader.
`ClassLoader` | `getClassLoader()` Return the Java class loader to be used by this Container.
`String` | `getClasspath()` Classpath, as set in org.apache.catalina.jsp_classpath context property
`Container` | `getContainer()` Return the Container with which this Logger has been associated.
`boolean` | `getDelegate()` Return the "follow standard delegation model" flag used to configure our ClassLoader.
`protected String` | `getDomainInternal()` Method implemented by sub-classes to identify the domain in which MBeans should be registered.
`String` | `getInfo()` Return descriptive information about this Loader implementation and the corresponding version number, in the format `<description>/<version>`.
`String` | `getLoaderClass()` Return the ClassLoader class name.
`String[]` | `getLoaderRepositories()`
`String` | `getLoaderRepositoriesString()`
`protected String` | `getObjectNameKeyProperties()` Allow sub-classes to specify the key properties component of the `ObjectName` that will be used to register this component.
`boolean` | `getReloadable()` Return the reloadable flag for this Loader.
`String[]` | `getRepositories()`
`String` | `getRepositoriesString()` Extra repositories for this loader
`boolean` | `getSearchExternalFirst()`
`boolean` | `modified()` Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded?
`void` | `propertyChange(PropertyChangeEvent event)` Process property change events from our associated Context.
`void` | `removePropertyChangeListener(PropertyChangeListener listener)` Remove a property change listener from this component.
`void` | `setContainer(Container container)` Set the Container with which this Logger has been associated.
`void` | `setDelegate(boolean delegate)` Set the "follow standard delegation model" flag used to configure our ClassLoader.
`void` | `setLoaderClass(String loaderClass)` Set the ClassLoader class name.
`void` | `setReloadable(boolean reloadable)` Set the reloadable flag for this Loader.
`void` | `setSearchExternalFirst(boolean searchExternalFirst)`
`protected void` | `startInternal()` Start associated `ClassLoader` and implement the requirements of `LifecycleBase.startInternal()`.
`protected void` | `stopInternal()` Stop associated `ClassLoader` and implement the requirements of `LifecycleBase.stopInternal()`.
`String` | `toString()` Return a String representation of this component.

Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
`destroyInternal, getDomain, getObjectName, initInternal, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister`

Methods inherited from class org.apache.catalina.util.LifecycleBase
`addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stop`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### 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

### getClassLoader

    public ClassLoader getClassLoader()

  Return the Java class loader to be used by this Container.

  Specified by:
    `getClassLoader` in interface `Loader`

### getContainer

    public Container getContainer()

  Return the Container with which this Logger has been associated.

  Specified by:
    `getContainer` in interface `Loader`

### setContainer

    public void setContainer(Container container)

  Set the Container with which this Logger has been associated.

  Specified by:
    `setContainer` in interface `Loader`
  Parameters:
    `container` - The associated Container

### getDelegate

    public boolean getDelegate()

  Return the "follow standard delegation model" flag used to configure our ClassLoader.

  Specified by:
    `getDelegate` in interface `Loader`

### setDelegate

    public void setDelegate(boolean delegate)

  Set the "follow standard delegation model" flag used to configure our ClassLoader.

  Specified by:
    `setDelegate` in interface `Loader`
  Parameters:
    `delegate` - The new flag

### getInfo

    public String getInfo()

  Return descriptive information about this Loader implementation and the corresponding version number, in the format `<description>/<version>`.

  Specified by:
    `getInfo` in interface `Loader`

### getLoaderClass

    public String getLoaderClass()

  Return the ClassLoader class name.

### setLoaderClass

    public void setLoaderClass(String loaderClass)

  Set the ClassLoader class name.

  Parameters:
    `loaderClass` - The new ClassLoader class name

### getReloadable

    public boolean getReloadable()

  Return the reloadable flag for this Loader.

  Specified by:
    `getReloadable` in interface `Loader`

### setReloadable

    public void setReloadable(boolean reloadable)

  Set the reloadable flag for this Loader.

  Specified by:
    `setReloadable` in interface `Loader`
  Parameters:
    `reloadable` - The new reloadable flag

### getSearchExternalFirst

    public boolean getSearchExternalFirst()

  Returns:
    Returns searchExternalFirst.

### setSearchExternalFirst

    public void setSearchExternalFirst(boolean searchExternalFirst)

  Parameters:
    `searchExternalFirst` - Whether external repositories should be searched first

### addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)

  Add a property change listener to this component.

  Specified by:
    `addPropertyChangeListener` in interface `Loader`
  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.

  Specified by:
    `addRepository` in interface `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.

  Specified by:
    `backgroundProcess` in interface `Loader`

### 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).

  Specified by:
    `findRepositories` in interface `Loader`

### getRepositories

    public String[] getRepositories()

### getRepositoriesString

    public String getRepositoriesString()

  Extra repositories for this loader

### getLoaderRepositories

    public String[] getLoaderRepositories()

### getLoaderRepositoriesString

    public String getLoaderRepositoriesString()

### getClasspath

    public String getClasspath()

  Classpath, as set in org.apache.catalina.jsp_classpath context property

  Returns:
    The classpath

### modified

    public boolean modified()

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

  Specified by:
    `modified` in interface `Loader`

### closeJARs

    public void closeJARs(boolean force)

  Used to periodically signal to the classloader to release JAR resources.

### removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)

  Remove a property change listener from this component.

  Specified by:
    `removePropertyChangeListener` in interface `Loader`
  Parameters:
    `listener` - The listener to remove

### toString

    public String toString()

  Return a String representation of this component.

  Overrides:
    `toString` in class `Object`

### startInternal

    protected void startInternal()
                          throws LifecycleException

  Start associated `ClassLoader` and implement the requirements of `LifecycleBase.startInternal()`.

  Specified by:
    `startInternal` in class `LifecycleBase`
  Throws:
    `LifecycleException` - if this component detects a fatal error that prevents this component from being used

### stopInternal

    protected void stopInternal()
                         throws LifecycleException

  Stop associated `ClassLoader` and implement the requirements of `LifecycleBase.stopInternal()`.

  Specified by:
    `stopInternal` in class `LifecycleBase`
  Throws:
    `LifecycleException` - if this component detects a fatal error that prevents this component from being used

### propertyChange

    public void propertyChange(PropertyChangeEvent event)

  Process property change events from our associated Context.

  Specified by:
    `propertyChange` in interface `PropertyChangeListener`
  Parameters:
    `event` - The property change event that has occurred

### getDomainInternal

    protected String getDomainInternal()

  Description copied from class: `LifecycleMBeanBase`
  Method implemented by sub-classes to identify the domain in which MBeans should be registered.

  Specified by:
    `getDomainInternal` in class `LifecycleMBeanBase`
  Returns:
    The name of the domain to use to register MBeans.

### getObjectNameKeyProperties

    protected String getObjectNameKeyProperties()

  Description copied from class: `LifecycleMBeanBase`
  Allow sub-classes to specify the key properties component of the `ObjectName` that will be used to register this component.

  Specified by:
    `getObjectNameKeyProperties` in class `LifecycleMBeanBase`
  Returns:
    The string representation of the key properties component of the desired `ObjectName`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 7.0.29
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.