Class PluginIndex
- java.lang.Object
-
- org.scijava.object.ObjectIndex<E>
-
- org.scijava.object.SortedObjectIndex<PluginInfo<?>>
-
- 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
ObjectIndexthat classifies eachPluginInfoobject into a type hierarchy compatible with its associated plugin type (i.e.,PluginInfo.getPluginType()), rather thanPluginInfo's type hierarchy (i.e.,PluginInfo,UIDetails,Instantiable, etc.).NB: This type hierarchy will typically not include the plugin class itself; for example, the
DefaultPluginServicehas a plugin type ofService, and hence will be categorized beneathService.class, notDefaultPluginService.classorPluginService.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
Constructors Constructor Description PluginIndex()Constructs a new plugin index which uses aDefaultPluginFinderto discover plugins.PluginIndex(PluginFinder pluginFinder)Constructs a new plugin index which uses the givenPluginFinderto discover plugins.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddiscover()Adds all plugins discovered by the attachedPluginFinderto this index, or does nothing if the attachedPluginFinderis null.Map<String,Throwable>getExceptions()Gets the exceptions which occurred during the last invocation ofdiscover().<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 booleanremove(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, parallelStream, removeIf, spliterator, stream
-
-
-
-
Constructor Detail
-
PluginIndex
public PluginIndex()
Constructs a new plugin index which uses aDefaultPluginFinderto discover plugins.
-
PluginIndex
public PluginIndex(PluginFinder pluginFinder)
Constructs a new plugin index which uses the givenPluginFinderto 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 attachedPluginFinderto this index, or does nothing if the attachedPluginFinderis null.
-
getExceptions
public Map<String,Throwable> getExceptions()
Gets the exceptions which occurred during the last invocation ofdiscover().
-
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 aList<PluginInfo<?>>, whereas this one is guaranteed to return aList<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:
getTypein classObjectIndex<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
ObjectIndexbehavior in that theinfoobject's actual type hierarchy is not used for classification, but rather the object is classified according toPluginInfo.getPluginType().- Overrides:
removein classObjectIndex<PluginInfo<?>>- See Also:
PluginInfo.getPluginType()
-
-