Openfire 3.3.2 Javadoc

org.jivesoftware.openfire.container
Class PluginClassLoader

java.lang.Object
  extended by org.jivesoftware.openfire.container.PluginClassLoader

public class PluginClassLoader
extends Object

ClassLoader for plugins. It searches the plugin directory for classes and JAR files, then constructs a class loader for the resources found. Resources are loaded as follows:

Author:
Derek DeMoro

Constructor Summary
PluginClassLoader()
          Constructs a plugin loader for the given plugin directory.
 
Method Summary
 void addDirectory(File directory, boolean developmentMode)
          Adds a directory to the class loader.
 void addURL(URL url)
          Adds a URL to the class loader.
 void destroy()
          Destroys this class loader.
 ClassLoader getClassLoader()
          Returns the URLClassloader used.
 Collection<URL> getURLS()
           
 void initialize()
          Initializes the class loader with all configured classpath URLs.
 Class loadClass(String name)
          Load a class using this plugin class loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginClassLoader

public PluginClassLoader()
                  throws SecurityException
Constructs a plugin loader for the given plugin directory.

Throws:
SecurityException - if the created class loader violates existing security constraints.
Method Detail

addDirectory

public void addDirectory(File directory,
                         boolean developmentMode)
Adds a directory to the class loader. The initialize() method should be called after adding the directory to make the change take effect.

Parameters:
directory - the directory.
developmentMode - true if the plugin is running in development mode. This resolves classloader conflicts between the deployed plugin and development classes.

getURLS

public Collection<URL> getURLS()

addURL

public void addURL(URL url)
Adds a URL to the class loader. The initialize() method should be called after adding the URL to make the change take effect.

Parameters:
url - the url.

initialize

public void initialize()
Initializes the class loader with all configured classpath URLs. This method can be called multiple times if the list of URLs changes.


loadClass

public Class loadClass(String name)
                throws ClassNotFoundException,
                       IllegalAccessException,
                       InstantiationException,
                       SecurityException
Load a class using this plugin class loader.

Parameters:
name - the fully qualified name of the class to load.
Returns:
The module object loaded
Throws:
ClassNotFoundException - if the class could not be loaded by this class loader.
IllegalAccessException - if the class constructor was private or protected.
InstantiationException - if the class could not be instantiated (initialization error).
SecurityException - if the custom class loader not allowed.

destroy

public void destroy()
Destroys this class loader.


getClassLoader

public ClassLoader getClassLoader()
Returns the URLClassloader used.

Returns:
the URLClassLoader used.

Openfire 3.3.2 Javadoc

Copyright © 2003-2007 Jive Software.