Whack

org.jivesoftware.whack.container
Class ComponentFinder

java.lang.Object
  extended by org.jivesoftware.whack.container.ComponentFinder

public class ComponentFinder
extends Object

Loads and manages components. The components directory is monitored for any new components, and they are dynamically loaded.

Author:
Matt Tucker, Gaston Dombiak
See Also:
Component, ServerContainer.start()

Constructor Summary
ComponentFinder(ServerContainer server, File componentDir)
          Constructs a new component manager.
 
Method Summary
 String getAuthor(org.xmpp.component.Component component)
          Returns the author of a component.
 org.xmpp.component.Component getComponent(String name)
          Returns a component by name or null if a component with that name does not exist.
 File getComponentDirectory(org.xmpp.component.Component component)
          Returns the component's directory.
 Collection<org.xmpp.component.Component> getComponents()
          Returns a Collection of all found components.
 String getDescription(org.xmpp.component.Component component)
          Returns the description of a component.
 String getName(org.xmpp.component.Component component)
          Returns the name of a component.
 String getVersion(org.xmpp.component.Component component)
          Returns the version of a component.
 Class loadClass(String className, org.xmpp.component.Component component)
           
 void shutdown()
          Shuts down running components that were found by the service.
 void start()
          Starts the service that looks for components.
 void unloadComponent(String componentName)
          Unloads a component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentFinder

public ComponentFinder(ServerContainer server,
                       File componentDir)
Constructs a new component manager.

Parameters:
componentDir - the component directory.
Method Detail

start

public void start()
Starts the service that looks for components.


shutdown

public void shutdown()
Shuts down running components that were found by the service.


getComponents

public Collection<org.xmpp.component.Component> getComponents()
Returns a Collection of all found components.

Returns:
a Collection of all found components.

getComponent

public org.xmpp.component.Component getComponent(String name)
Returns a component by name or null if a component with that name does not exist. The name is the name of the directory that the component is in such as "broadcast".

Parameters:
name - the name of the component.
Returns:
the component.

getComponentDirectory

public File getComponentDirectory(org.xmpp.component.Component component)
Returns the component's directory.

Parameters:
component - the component.
Returns:
the component's directory.

unloadComponent

public void unloadComponent(String componentName)
Unloads a component. The ComponentManager.removeComponent(String) method will be called and then any resources will be released. The name should be the name of the component directory and not the name as given by the component meta-data. This method only removes the component but does not delete the component JAR file. Therefore, if the component JAR still exists after this method is called, the component will be started again the next time the component monitor process runs. This is useful for "restarting" components.

This method is called automatically when a component's JAR file is deleted.

Parameters:
componentName - the name of the component to unload.

loadClass

public Class loadClass(String className,
                       org.xmpp.component.Component component)
                throws ClassNotFoundException,
                       IllegalAccessException,
                       InstantiationException
Throws:
ClassNotFoundException
IllegalAccessException
InstantiationException

getName

public String getName(org.xmpp.component.Component component)
Returns the name of a component. The value is retrieved from the component.xml file of the component. If the value could not be found, null will be returned. Note that this value is distinct from the name of the component directory.

Parameters:
component - the component.
Returns:
the component's name.

getDescription

public String getDescription(org.xmpp.component.Component component)
Returns the description of a component. The value is retrieved from the component.xml file of the component. If the value could not be found, null will be returned.

Parameters:
component - the component.
Returns:
the component's description.

getAuthor

public String getAuthor(org.xmpp.component.Component component)
Returns the author of a component. The value is retrieved from the component.xml file of the component. If the value could not be found, null will be returned.

Parameters:
component - the component.
Returns:
the component's author.

getVersion

public String getVersion(org.xmpp.component.Component component)
Returns the version of a component. The value is retrieved from the component.xml file of the component. If the value could not be found, null will be returned.

Parameters:
component - the component.
Returns:
the component's version.

Whack

Copyright © 2003-2008 Jive Software.