de.grogra.pf.registry
Class Plugin

java.lang.Object
  extended by de.grogra.pf.registry.Plugin
All Implemented Interfaces:
RegistryContext
Direct Known Subclasses:
BillboardPlugin, ExchangeGraphPlugin, GPUFlux, IMP, IMP3D, OpenAleaPlugin, UI, X3DPlugin

public class Plugin
extends java.lang.Object
implements RegistryContext

An instance of Plugin is the representation of a plugin and can response to lifetime events of the plugin. It may also opt to disable the plugin when the application boots. This may be used, e.g., if the environment does not provide some features required by the plugin.

Normally, instances of this class Plugin are used to represent a plugin. If a plugin needs a specific implementation of methods of Plugin, it has to provide a specialized subclass and declare this in the root element of the plugin.xml file as in

 <plugin id="de.grogra.foo" version="0.9.7"
         class="de.grogra.foo.MyPlugin"
         xmlns="http://grogra.de/registry">
 ...
 </plugin>
 

Author:
Ole Kniemeyer

Constructor Summary
Plugin()
           
 
Method Summary
 boolean checkConfigure()
          This method returns true iff it is has not yet been invoked before for the same plugin and the same user (extending over all application invocations).
 I18NBundle getI18NBundle()
          Returns the resource bundle which represents the contents of the plugin.properties file.
 PluginDescriptor getPluginDescriptor()
          Returns the plugin descriptor of this plugin.
 Registry getRegistry()
          Returns the Registry which is linked with this instance.
 boolean initialize()
          Initializes the plugin during booting of application.
 void shutdown()
          This method is invoked when an active plugin is deactivated, i.e., when the whole application is terminated.
 void startup()
          This method is invoked when the plugin is activated, i.e., when the first class defined by the plugin is loaded (except for the Plugin class itself).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Plugin

public Plugin()
Method Detail

checkConfigure

public boolean checkConfigure()
This method returns true iff it is has not yet been invoked before for the same plugin and the same user (extending over all application invocations). To be more precise, the method sets a plugin-specific flag in the preferences of the user and checks whether this flag has not yet been set before.

Returns:
true iff this method is invoked for the first time

getI18NBundle

public final I18NBundle getI18NBundle()
Returns the resource bundle which represents the contents of the plugin.properties file.

Returns:
resource bundle of plugin.properties

getPluginDescriptor

public final PluginDescriptor getPluginDescriptor()
Returns the plugin descriptor of this plugin.

Returns:
plugin descriptor

getRegistry

public final Registry getRegistry()
Description copied from interface: RegistryContext
Returns the Registry which is linked with this instance.

Specified by:
getRegistry in interface RegistryContext
Returns:
the registry linked with this instance

initialize

public boolean initialize()
Initializes the plugin during booting of application. If this method returns false, the plugin is disabled throughout the lifetime of the application.

The default implementation simply returns true. Subclasses may override this method if they have to check some preconditions which are required by their plugin.

Returns:
true iff plugin shall be enabled

shutdown

public void shutdown()
This method is invoked when an active plugin is deactivated, i.e., when the whole application is terminated. The default implementation executes all executable items in the directory /hooks/shutdown/name, where name is the name of the plugin.


startup

public void startup()
This method is invoked when the plugin is activated, i.e., when the first class defined by the plugin is loaded (except for the Plugin class itself). The default implementation executes all executable items in the directory /hooks/startup/name, where name is the name of the plugin.

The method initialize() has been invoked before. Only if this invocation has returned true, the plugin may be activated.