Plugin

public class Plugin extends PluginComponent

A Plugin represents a plugin descriptor. It contains the elements specified in the descriptor. It also contains a class loader for loading classes which stored in the libraries specified in the descriptor. If there is a plugin handler specified in the descriptor, it will be invoked when the plugin is being activated.

Author:Hugo Y. K. Lam

See also: PluginRegistry, PluginClassLoader, PluginHandler

Constructors

Plugin

public Plugin(PluginRegistry registry, File folder, String descriptor)

Creates a new instance of Plugin.

Parameters:
  • registry – the plugin registry which stores this plugin.
  • folder – the folder which holds this plugin.
  • descriptor – the descriptor of this plugin.
Throws:
  • PluginException – if this plugin cannot be initialized according to its plugin descriptor.

Methods

activate

public synchronized void activate()

Activates this plugin by invoking the plugin handler specified in the plugin descriptor. If the plugin has already been activated, nothing will be done.

Throws:
  • PluginException – if there is any error in processing activation by the handler.

deactivate

public synchronized void deactivate()

Deactivates this plugin by invoking the plugin handler specified in the plugin descriptor. If the plugin has not yet been activated, nothing will be done.

Throws:
  • PluginException – if there is any error in processing deactivation by the handler.

getClassLoader

public PluginClassLoader getClassLoader()

Gets the class loader for this plugin.

Returns:the class loader for this plugin.

getExtensionPoints

public Collection getExtensionPoints()

Gets all the extension points declared in the plugin descriptor.

Returns:all the extension points declared in the plugin descriptor.

getExtensions

public Collection getExtensions()

Gets all extensions declared in the plugin descriptor.

Returns:all extensions declared in the plugin descriptor.

getExtensions

public Collection getExtensions(String point)

Gets all extensions declared in the plugin descriptor which extends the specified extension point.

Parameters:
  • point – the extension point.
Returns:

all extensions declared in the plugin descriptor which extends the specified extension point.

getHandlerClass

public String getHandlerClass()

Gets the handler class of this plugin.

Returns:the handler class of this plugin.

getId

public String getId()

Gets the plugin ID.

Returns:the plugin ID.

getImports

public Collection getImports()

Gets all plugin imports declared in the plugin descriptor.

Returns:all plugin imports declared in the plugin descriptor.

getLibraries

public Collection getLibraries()

Gets all libraries declared in the plugin descriptor.

Returns:all libraries declared in the plugin descriptor.

getName

public String getName()

Gets the plugin name.

Returns:the plugin name.

getParameters

public Properties getParameters()

Gets the parameters of this plugin.

Returns:the parameters of this plugin.

getPluginRegistry

public PluginRegistry getPluginRegistry()

Gets the plugin registry of this plugin.

Returns:the plugin registry of this plugin.

getProviderName

public String getProviderName()

Gets the provider name of this plugin.

Returns:the provider name of this plugin.

getVersion

public String getVersion()

Gets the version of this plugin.

Returns:the version of this plugin.

isActivated

public boolean isActivated()

Checks if this plugin has been activated.

Returns:true if this plugin has been activated.

loadClass

public Class loadClass(String name)

Loads a class from this plugin’s class loader.

Parameters:
  • name – the class name.
Throws:
Returns:

the Class instance for the specified class name.

toString

public String toString()

Returns a string representation of this plugin.

Returns:a string representation of this plugin.

See also: java.lang.Object.toString()