Adding plugins

Alternative ways of adding plugins:


try
{
    // There are two ways to add by class

    plugin_manager.add("Plugin 1", SomePlugin.class, an_object, true);
    plugin_manager.add(ASecondPlugin.class, false);

    // There are two ways to add by instance

    plugin_manager.add("Plugin 3", specific_plugin, another_object, false);
    plugin_manager.add(fourth_plugin, true);
}
catch (BeatrixPluginException e)
{
    // Deal with a failed add
}

The first two plugins are added by class. The first one is given a specific name (Plugin 1), an arbitrary object which will be given to its init() method, and it is true that it will be initialised right away (eager initialisation).

The second plugin is added more simply. It will have no name, no initialisation parameter (actually, the argument will be null), and the false indicates it will only be initialised on a lookup. If it never matches a lookup on the plugin manager then it will never be initialised.

The third and fourth plugins are added by instance. Plugin 3 has that name and is again given an arbitrary object for its init() method. It will not be initialised until needed, however.

The fourth plugin has no name and no init argument (actually, a null init argument), but it will be initialised now.

Adding plugins can lead to a BeatrixPluginException, either if initialisation fails or if we add a class which is not an IPlugin.

Nik Silver 2002-03-09