org.scijava.plugin
Class PluginIndex

java.lang.Object
  extended by org.scijava.object.ObjectIndex<E>
      extended by org.scijava.object.SortedObjectIndex<PluginInfo<?>>
          extended by org.scijava.plugin.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

Field Summary
 
Fields inherited from class org.scijava.object.ObjectIndex
hoard
 
Constructor Summary
PluginIndex()
          Constructs a new plugin index which uses a DefaultPluginFinder to discover plugins.
PluginIndex(PluginFinder pluginFinder)
          Constructs a new plugin index which uses the given PluginFinder to discover plugins.
 
Method Summary
 void discover()
          Adds all plugins discovered by the attached PluginFinder to this index, or does nothing if the attached PluginFinder is null.
 Map<String,Throwable> getExceptions()
          Gets the exceptions which occurred during the last invocation of discover().
<PT extends SciJavaPlugin>
List<PluginInfo<PT>>
getPlugins(Class<PT> type)
          Gets a list of registered plugins compatible with the given type.
protected  Class<?> getType(PluginInfo<?> info)
          Overrides the type by which the entries are indexed.
protected  boolean remove(Object o, boolean batch)
          Removes the plugin from all type lists compatible with its plugin type.
 
Methods inherited from class org.scijava.object.SortedObjectIndex
addAll, addToList, contains, containsAll
 
Methods inherited from class org.scijava.object.ObjectIndex
add, add, add, addLater, clear, get, getAll, getBaseClass, getTypes, isEmpty, iterator, remove, remove, removeAll, removeFromList, retainAll, retrieveList, retrieveListsForType, size, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

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 SciJavaPlugin> List<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).

getType

protected Class<?> getType(PluginInfo<?> info)
Overrides the type by which the entries are indexed.

Overrides:
getType in class ObjectIndex<PluginInfo<?>>
See Also:
PluginInfo.getPluginType()

remove

protected boolean remove(Object o,
                         boolean batch)
Removes the plugin from all type lists compatible with its plugin type.

NB: This behavior differs from the default ObjectIndex behavior in that the info object's actual type hierarchy is not used for classification, but rather the object is classified according to PluginInfo.getPluginType().

Overrides:
remove in class ObjectIndex<PluginInfo<?>>
See Also:
PluginInfo.getPluginType()


Copyright © 2009–2015 SciJava. All rights reserved.