Class PluginIndex

  • All Implemented Interfaces:
    Iterable<PluginInfo<?>>, Collection<PluginInfo<?>>

    public class PluginIndex
    extends SortedObjectIndex<PluginInfo<?>>
    Data structure for managing registered plugins.

    The plugin index is a special type of ObjectIndex that classifies each PluginInfo object into a type hierarchy compatible with its associated plugin type (i.e., PluginInfo.getPluginType()), rather than PluginInfo's type hierarchy (i.e., PluginInfo, UIDetails, Instantiable, etc.).

    NB: This type hierarchy will typically not include the plugin class itself; for example, the DefaultPluginService has a plugin type of Service, and hence will be categorized beneath Service.class, not DefaultPluginService.class or PluginService.class. The rationale is that to fully classify each plugin including its own class, said class would need to be loaded, which SciJava makes an effort not to do until the plugin is actually needed for the first time.

    Author:
    Curtis Rueden
    • Constructor Detail

      • PluginIndex

        public PluginIndex()
        Constructs a new plugin index which uses a DefaultPluginFinder to discover plugins.
      • PluginIndex

        public PluginIndex​(PluginFinder pluginFinder)
        Constructs a new plugin index which uses the given PluginFinder to discover plugins.

        A null PluginFinder is allowed, in which case no plugins will be discovered during discover() calls.

    • Method Detail

      • discover

        public void discover()
        Adds all plugins discovered by the attached PluginFinder to this index, or does nothing if the attached PluginFinder is null.
      • getExceptions

        public Map<String,​Throwable> getExceptions()
        Gets the exceptions which occurred during the last invocation of discover().
      • getPlugins

        public <PT extends SciJavaPluginList<PluginInfo<PT>> getPlugins​(Class<PT> type)
        Gets a list of registered plugins compatible with the given type.

        This method is more specific than ObjectIndex.get(Class) since that method returns only a List<PluginInfo<?>>, whereas this one is guaranteed to return a List<PluginInfo<P>>.

        Returns:
        Read-only list of registered objects of the given type, or an empty list if no such objects exist (this method never returns null).