public class PluginIndex extends SortedObjectIndex<PluginInfo<?>>
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.
hoard
Constructor and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
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> |
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.
|
addAll, addToList, contains, containsAll
add, add, add, addLater, clear, get, getAll, getBaseClass, getTypes, isEmpty, iterator, remove, remove, removeAll, removeFromList, retainAll, retrieveList, retrieveListsForType, size, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode, parallelStream, removeIf, spliterator, stream
public PluginIndex()
DefaultPluginFinder
to
discover plugins.public PluginIndex(PluginFinder pluginFinder)
PluginFinder
to
discover plugins.
A null PluginFinder is allowed, in which case no plugins will be discovered
during discover()
calls.
public void discover()
PluginFinder
to this
index, or does nothing if the attached PluginFinder
is null.public Map<String,Throwable> getExceptions()
discover()
.public <PT extends SciJavaPlugin> List<PluginInfo<PT>> getPlugins(Class<PT> 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>>
.
protected Class<?> getType(PluginInfo<?> info)
getType
in class ObjectIndex<PluginInfo<?>>
PluginInfo.getPluginType()
protected boolean remove(Object o, boolean batch)
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()
.
remove
in class ObjectIndex<PluginInfo<?>>
PluginInfo.getPluginType()
Copyright © 2015–2022 SciJava. All rights reserved.