org.rhq.enterprise.server.plugin.pc
Class ClassLoaderManager

java.lang.Object
  extended by org.rhq.enterprise.server.plugin.pc.ClassLoaderManager

public class ClassLoaderManager
extends Object

Manages the classloaders created and used by the master plugin container and all plugins.

Author:
John Mazzitelli

Constructor Summary
ClassLoaderManager(Map<URL,? extends ServerPluginDescriptorType> plugins, ClassLoader rootClassLoader, File tmpDir)
          Creates the object that will manage all classloaders for the plugins deployed in the server.
 
Method Summary
 int getNumberOfServerPluginClassLoaders()
          Returns the total number of plugin classloaders that have been created and managed.
 ClassLoader getRootClassLoader()
          Returns the classloader that should be the ancestor (i.e.
 Map<org.rhq.core.domain.plugin.PluginKey,ClassLoader> getServerPluginClassLoaders()
          Returns a shallow copy of the plugin classloaders keyed on plugin key.
 void loadPlugin(URL pluginUrl, ServerPluginDescriptorType descriptor)
          Hot-deploys a plugin into this classloader manager.
 ClassLoader obtainServerPluginClassLoader(org.rhq.core.domain.plugin.PluginKey pluginKey)
          Returns a plugin classloader (creating it if necessary).
 void shutdown()
          Cleans up this object and all classloaders it has created.
 String toString()
           
 void unloadPlugin(org.rhq.core.domain.plugin.PluginKey pluginKey)
          Unloads the plugin identified with the current key from this classloader manager and destroys that plugin's classloader, if one existed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassLoaderManager

public ClassLoaderManager(Map<URL,? extends ServerPluginDescriptorType> plugins,
                          ClassLoader rootClassLoader,
                          File tmpDir)
Creates the object that will manage all classloaders for the plugins deployed in the server.

Parameters:
plugins - maps a plugin URL to that plugin's descriptor
rootClassLoader - the classloader at the top of the classloader hierarchy
tmpDir - where the classloaders can write out the jars that are embedded in the plugin jars
Method Detail

shutdown

public void shutdown()
Cleans up this object and all classloaders it has created.


loadPlugin

public void loadPlugin(URL pluginUrl,
                       ServerPluginDescriptorType descriptor)
Hot-deploys a plugin into this classloader manager.

Parameters:
pluginUrl - location of the plugin jar file
descriptor - the plugin descriptor

unloadPlugin

public void unloadPlugin(org.rhq.core.domain.plugin.PluginKey pluginKey)
Unloads the plugin identified with the current key from this classloader manager and destroys that plugin's classloader, if one existed.

Parameters:
pluginKey - identifies the plugin to be unloaded

toString

public String toString()
Overrides:
toString in class Object

getRootClassLoader

public ClassLoader getRootClassLoader()
Returns the classloader that should be the ancestor (i.e. top most parent) of all plugin classloaders.

Returns:
the root plugin classloader for all plugins

obtainServerPluginClassLoader

public ClassLoader obtainServerPluginClassLoader(org.rhq.core.domain.plugin.PluginKey pluginKey)
                                          throws Exception
Returns a plugin classloader (creating it if necessary).

Parameters:
pluginKey - the plugin whose classloader is to be created
Returns:
the plugin classloader
Throws:
Exception

getNumberOfServerPluginClassLoaders

public int getNumberOfServerPluginClassLoaders()
Returns the total number of plugin classloaders that have been created and managed. This method is here just to support a plugin container management MBean.

Returns:
number of plugin classloaders that are currently created and being used

getServerPluginClassLoaders

public Map<org.rhq.core.domain.plugin.PluginKey,ClassLoader> getServerPluginClassLoaders()
Returns a shallow copy of the plugin classloaders keyed on plugin key. This method is here just to support a plugin container management MBean. Do not use this method to obtain a plugin's classloader, instead, you want to use #obtainServerPluginClassLoader(String).

Returns:
all plugin classloaders currently assigned to plugins (will never be null)


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.