As found in org.jtrix.project.beatrix.plugins:
public interface IPlugin
{
    /**
     * Initialise the plugin before first needed.
     * Here, "first needed" is when it successfully
     * matches against a lookup on its plugin manager.
     * Should only be called by the plugin manager which will
     * only call it once.
     * If initialisation fails the plugin manager will
     * remove this plugin.
     *
     * @param plugin_manager Plugin manager that holds this plugin.
     * @param data   Arbitrary argument data supplied when it
     *               was originally added to the plugin manager.
     * @return  Success flag. If false then the plugin will be
     *          removed from its plugin manager.
     */
    public boolean init(IPluginManager plugin_manager, Object data);
    /**
     * Shutdown the plugin. Should only be called by the plugin
     * manager, which will only call it if was previously
     * successfully initialised.
     */
    public void shutdown();
}
Recall from Sections ![[*]](crossref.png) -
-![[*]](crossref.png) how plugin initialisation and shutdown occur: initialisation will
occur some time before first use, and possibly when it is added to
its plugin manager; shutdown will only occur after a successful initialisation,
just before it is removed from its plugin manager.
how plugin initialisation and shutdown occur: initialisation will
occur some time before first use, and possibly when it is added to
its plugin manager; shutdown will only occur after a successful initialisation,
just before it is removed from its plugin manager.
Recall also (Section ![[*]](crossref.png) ) our various ways
of adding plugins.
) our various ways
of adding plugins.
Thus our IPlugin.init() method above may be called immediately on add, depending on whether it was added with the ``eager initialisation'' flag as true. Certainly it will be called before it is first returned by a lookup on its plugin manager.
When init() is called its two parameters are the plugin manager itself and the Object (if any) specified when it was added. Our implementation above saves the plugin manager reference (even though we don't use it) as it can be useful if we want to lookup other plugins via that plugin manager.
Note that if the init() method returns false then it will be removed from its plugin manager; the shutdown() method will not be called in this case.
Nik Silver 2002-03-09