Interface PluginService
-
- All Superinterfaces:
Comparable<Prioritized>,Contextual,Disposable,HasPluginInfo,Identifiable,Initializable,Locatable,Logged,Prioritized,RichPlugin,SciJavaPlugin,SciJavaService,Service,Versioned
- All Known Implementing Classes:
DefaultPluginService
public interface PluginService extends SciJavaService
Interface for service that keeps track of available plugins.The plugin service keeps a central index of all plugins known to the system. At heart, a plugin is a piece of functionality that extends a program's capabilities. Plugins take many forms; see
SciJavaPluginfor details.The default plugin service discovers available plugins on the classpath.
- Author:
- Curtis Rueden
- See Also:
SciJavaPlugin
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddPlugin(PluginInfo<?> plugin)Manually registers a plugin with the plugin service.<T extends PluginInfo<?>>
voidaddPlugins(Collection<T> plugins)Manually registers plugins with the plugin service.<PT extends SciJavaPlugin>
PTcreateInstance(PluginInfo<PT> info)Creates an instance of the given plugin.<PT extends SciJavaPlugin>
List<PT>createInstances(List<PluginInfo<PT>> infos)Creates an instance of each of the plugins on the given list.<PT extends SciJavaPlugin>
List<PT>createInstancesOfType(Class<PT> type)Creates one instance each of the available plugins of the given type.PluginIndexgetIndex()Gets the index of available plugins.<P extends SciJavaPlugin>
PluginInfo<SciJavaPlugin>getPlugin(Class<P> pluginClass)Gets the first available plugin of the given class, or null if none.<PT extends SciJavaPlugin,P extends PT>
PluginInfo<PT>getPlugin(Class<P> pluginClass, Class<PT> type)Gets the first available plugin of the given class, or null if none.PluginInfo<SciJavaPlugin>getPlugin(String className)Gets the first available plugin of the given class name, or null if none.List<PluginInfo<?>>getPlugins()Gets the list of known plugins.<P extends SciJavaPlugin>
List<PluginInfo<SciJavaPlugin>>getPluginsOfClass(Class<P> pluginClass)Gets the list of plugins of the given class.<PT extends SciJavaPlugin,P extends PT>
List<PluginInfo<PT>>getPluginsOfClass(Class<P> pluginClass, Class<PT> type)Gets the list of plugins of the given class.List<PluginInfo<SciJavaPlugin>>getPluginsOfClass(String className)Gets the list of plugins with the given class name.<PT extends SciJavaPlugin>
List<PluginInfo<SciJavaPlugin>>getPluginsOfClass(String className, Class<PT> type)Gets the list of plugins with the given class name.<PT extends SciJavaPlugin>
List<PluginInfo<PT>>getPluginsOfType(Class<PT> type)Gets the list of plugins of the given type (e.g.,Service).voidreloadPlugins()Rediscovers all plugins available on the classpath.voidremovePlugin(PluginInfo<?> plugin)Manually unregisters a plugin with the plugin service.<T extends PluginInfo<?>>
voidremovePlugins(Collection<T> plugins)Manually unregisters plugins with the plugin service.default <PT extends SciJavaPlugin>
voidsort(List<PT> instances, Class<PT> type)Sorts the given list of plugin instances by priority.-
Methods inherited from interface org.scijava.Contextual
context, getContext, setContext
-
Methods inherited from interface org.scijava.Disposable
dispose
-
Methods inherited from interface org.scijava.plugin.HasPluginInfo
getInfo, setInfo
-
Methods inherited from interface org.scijava.Locatable
getLocation
-
Methods inherited from interface org.scijava.Prioritized
compareTo, getPriority, setPriority
-
Methods inherited from interface org.scijava.plugin.RichPlugin
getIdentifier, log
-
Methods inherited from interface org.scijava.service.Service
initialize, registerEventHandlers
-
Methods inherited from interface org.scijava.Versioned
getVersion
-
-
-
-
Method Detail
-
getIndex
PluginIndex getIndex()
Gets the index of available plugins.
-
reloadPlugins
void reloadPlugins()
Rediscovers all plugins available on the classpath. Note that this will clear any individual plugins added programmatically.
-
addPlugin
void addPlugin(PluginInfo<?> plugin)
Manually registers a plugin with the plugin service.
-
addPlugins
<T extends PluginInfo<?>> void addPlugins(Collection<T> plugins)
Manually registers plugins with the plugin service.
-
removePlugin
void removePlugin(PluginInfo<?> plugin)
Manually unregisters a plugin with the plugin service.
-
removePlugins
<T extends PluginInfo<?>> void removePlugins(Collection<T> plugins)
Manually unregisters plugins with the plugin service.
-
getPlugins
List<PluginInfo<?>> getPlugins()
Gets the list of known plugins.
-
getPlugin
<P extends SciJavaPlugin> PluginInfo<SciJavaPlugin> getPlugin(Class<P> pluginClass)
Gets the first available plugin of the given class, or null if none.- Type Parameters:
P- The class of the plugin to look up.
-
getPlugin
<PT extends SciJavaPlugin,P extends PT> PluginInfo<PT> getPlugin(Class<P> pluginClass, Class<PT> type)
Gets the first available plugin of the given class, or null if none.- Type Parameters:
PT- The type of the plugin to look up; e.g.,Service.class.P- The class of the plugin to look up.
-
getPlugin
PluginInfo<SciJavaPlugin> getPlugin(String className)
Gets the first available plugin of the given class name, or null if none.
-
getPluginsOfType
<PT extends SciJavaPlugin> List<PluginInfo<PT>> getPluginsOfType(Class<PT> type)
Gets the list of plugins of the given type (e.g.,Service).- Type Parameters:
PT- The type of plugins to look up; e.g.,Service.class.
-
getPluginsOfClass
<P extends SciJavaPlugin> List<PluginInfo<SciJavaPlugin>> getPluginsOfClass(Class<P> pluginClass)
Gets the list of plugins of the given class.Most classes will have only a single match, but some special classes (such as ImageJ's
LegacyCommand) may match many entries.Note that this method will result in
PluginInfos with matching class names to load their pluginClasses so that they can be compared with the given one.NB: Classes are matched by strict equality, not assignability; subtypes of the specified class will not match. For this behavior, use
getPluginsOfType(Class)on a common parent interface.- Type Parameters:
P- The class of plugins to look up.- Parameters:
pluginClass- The class for which to obtain the list of matching plugins.
-
getPluginsOfClass
<PT extends SciJavaPlugin,P extends PT> List<PluginInfo<PT>> getPluginsOfClass(Class<P> pluginClass, Class<PT> type)
Gets the list of plugins of the given class.Most classes will have only a single match, but some special classes (such as ImageJ's
LegacyCommand) may match many entries.Note that this method will result in
PluginInfos with matching class names and types to load their pluginClasses so that they can be compared with the given one.NB: Classes are matched by strict equality, not assignability; subtypes of the specified class will not match. For this behavior, use
getPluginsOfType(Class)on a common parent interface.- Type Parameters:
PT- The type of plugins to look up; e.g.,Service.class.P- The class of plugins to look up.- Parameters:
pluginClass- The class for which to obtain the list of matching plugins.type- The type of plugins to which the search should be limited.
-
getPluginsOfClass
List<PluginInfo<SciJavaPlugin>> getPluginsOfClass(String className)
Gets the list of plugins with the given class name.Most classes will have only a single match, but some special classes (such as ImageJ's
LegacyCommand) may match many entries.NB: Classes are matched by strict equality, not assignability; subtypes of the specified class will not match. For this behavior, use
getPluginsOfType(Class)on a common parent interface.- Parameters:
className- The class name for which to obtain the list of matching plugins.
-
getPluginsOfClass
<PT extends SciJavaPlugin> List<PluginInfo<SciJavaPlugin>> getPluginsOfClass(String className, Class<PT> type)
Gets the list of plugins with the given class name.Most classes will have only a single match, but some special classes (such as ImageJ's
LegacyCommand) may match many entries.NB: Classes are matched by strict equality, not assignability; subtypes of the specified class will not match. For this behavior, use
getPluginsOfType(Class)on a common parent interface.- Type Parameters:
PT- The type of plugins to look up; e.g.,Service.class.- Parameters:
className- The class name for which to obtain the list of matching plugins.type- The type of plugins to which the search should be limited.
-
createInstancesOfType
<PT extends SciJavaPlugin> List<PT> createInstancesOfType(Class<PT> type)
Creates one instance each of the available plugins of the given type.Note that in the case of commands, this method does not do any preprocessing on the command instances, so parameters will not be auto-populated, initializers will not be executed, etc.
- Type Parameters:
PT- The type of plugins to instantiate; e.g.,Service.class.
-
createInstances
<PT extends SciJavaPlugin> List<PT> createInstances(List<PluginInfo<PT>> infos)
Creates an instance of each of the plugins on the given list.If the plugin implements the
Contextualinterface, the appropriate context is injected. Similarly, if the plugin implements thePrioritizedinterface, the appropriate priority is injected.Note that in the case of commands, this method does not do any preprocessing on the command instances, so parameters will not be auto-populated, initializers will not be executed, etc.
- Type Parameters:
PT- The type of plugins to instantiate; e.g.,Service.class.
-
createInstance
<PT extends SciJavaPlugin> PT createInstance(PluginInfo<PT> info)
Creates an instance of the given plugin.If the plugin implements the
Contextualinterface, the appropriate context is injected. Similarly, if the plugin implements thePrioritizedinterface, the appropriate priority is injected.Note that in the case of commands, this method does not do any preprocessing on the command instances, so parameters will not be auto-populated, initializers will not be executed, etc.
- Type Parameters:
PT- The type of plugin to instantiate; e.g.,Service.class.
-
sort
default <PT extends SciJavaPlugin> void sort(List<PT> instances, Class<PT> type)
Sorts the given list of plugin instances by priority.- Parameters:
instances- List of plugin instances to sort.type- The type of plugin these instances represent.
-
-