public class DefaultCommandService extends AbstractPTService<Command> implements CommandService
Commands. Available commands are
obtained from the plugin service. Loading of the actual command classes can
be deferred until a particular command's first execution.Command| Constructor and Description |
|---|
DefaultCommandService() |
| Modifier and Type | Method and Description |
|---|---|
EventService |
eventService() |
<C extends Command> |
getCommand(Class<C> commandClass)
Gets the first available command of the given class, or null if none.
|
CommandInfo |
getCommand(String className)
Gets the first available command of the given class name, or null if none.
|
List<CommandInfo> |
getCommands()
Gets the list of all available
Commands). |
<CT extends Command> |
getCommands(List<PluginInfo<CT>> plugins)
Gets the list of
Commands corresponding to the given plugins. |
<C extends Command> |
getCommandsOfClass(Class<C> commandClass)
Gets the list of commands of the given class.
|
List<CommandInfo> |
getCommandsOfClass(String className)
Gets the list of commands with the given class name.
|
<CT extends Command> |
getCommandsOfType(Class<CT> type)
Gets the list of
Commands of the given type. |
Class<Command> |
getPluginType()
Gets the type of plugins managed by this service.
|
void |
initialize()
Performs any needed initialization when the service is first loaded.
|
ModuleService |
moduleService() |
protected void |
onEvent(PluginsAddedEvent event) |
protected void |
onEvent(PluginsRemovedEvent event) |
PluginService |
pluginService()
Gets the service responsible for discovering and managing this service's
plugins.
|
<C extends Command> |
run(Class<C> commandClass,
boolean process,
Map<String,Object> inputMap)
Executes the first command of the given class.
|
<C extends Command> |
run(Class<C> commandClass,
boolean process,
Object... inputs)
Executes the first command of the given class.
|
Future<CommandModule> |
run(CommandInfo info,
boolean process,
Map<String,Object> inputMap)
Executes the given command.
|
Future<CommandModule> |
run(CommandInfo info,
boolean process,
Object... inputs)
Executes the given command.
|
Future<CommandModule> |
run(String className,
boolean process,
Map<String,Object> inputMap)
Executes the first command of the given class name.
|
Future<CommandModule> |
run(String className,
boolean process,
Object... inputs)
Executes the first command of the given class name.
|
getContext, setContext, toStringgetInfo, getPriority, setInfo, setPrioritycontextclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetEventService, getModuleServicecreate, getPlugins, getPluginServiceregisterEventHandlersgetIdentifier, logcontext, getContext, setContextcompareTo, getPriority, setPrioritygetInfo, setInfogetLocationgetVersiondisposepublic EventService eventService()
eventService in interface CommandServicepublic PluginService pluginService()
PTServicepluginService in interface PTService<Command>pluginService in class AbstractPTService<Command>public ModuleService moduleService()
moduleService in interface CommandServicepublic List<CommandInfo> getCommands()
CommandServiceCommands).getCommands in interface CommandServicepublic <CT extends Command> List<CommandInfo> getCommands(List<PluginInfo<CT>> plugins)
CommandServiceCommands corresponding to the given plugins.getCommands in interface CommandServicepublic <CT extends Command> List<CommandInfo> getCommandsOfType(Class<CT> type)
CommandServiceCommands of the given type.getCommandsOfType in interface CommandServicepublic <C extends Command> CommandInfo getCommand(Class<C> commandClass)
CommandServicegetCommand in interface CommandServicepublic CommandInfo getCommand(String className)
CommandServicegetCommand in interface CommandServicepublic <C extends Command> List<CommandInfo> getCommandsOfClass(Class<C> commandClass)
CommandService
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
CommandService.getCommandsOfType(Class) on a common parent interface.
getCommandsOfClass in interface CommandServicepublic List<CommandInfo> getCommandsOfClass(String className)
CommandService
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
CommandService.getCommandsOfType(Class) on a common parent interface.
getCommandsOfClass in interface CommandServicepublic Future<CommandModule> run(String className, boolean process, Object... inputs)
CommandServiceIf no command with the given class name is registered with the service, then a default one is created and then executed. This default command is not registered with the service for subsequent usage.
run in interface CommandServiceclassName - Class name of the command to execute.process - If true, executes the command with pre- and postprocessing
steps from all available PreprocessorPlugins and
PostprocessorPlugins in the plugin index; if false,
executes the command with no pre- or postprocessing. For more
fine-grained control, see the ModuleService.run(org.scijava.module.ModuleInfo, boolean, java.lang.Object...) methods.inputs - List of input parameter names and values. The expected order
is in pairs: an input name followed by its value, for each desired
input to populate. Leaving some inputs unpopulated is allowed.
Passing the name of an input that is not valid for the plugin, or
passing a value of a type incompatible with the associated input
parameter, will issue an error and ignore that name/value pair.Future of the module instance being executed. Calling
Future.get() will block until execution is complete.public Future<CommandModule> run(String className, boolean process, Map<String,Object> inputMap)
CommandServiceIf no command with the given class name is registered with the service, then a default one is created and then executed. This default command is not registered with the service for subsequent usage.
run in interface CommandServiceclassName - Class name of the command to execute.process - If true, executes the command with pre- and postprocessing
steps from all available PreprocessorPlugins and
PostprocessorPlugins in the plugin index; if false,
executes the command with no pre- or postprocessing. For more
fine-grained control, see the ModuleService.run(org.scijava.module.ModuleInfo, boolean, java.lang.Object...) methods.inputMap - Table of input parameter values, with keys matching the
plugin's input parameter names. Passing a value of a type
incompatible with the associated input parameter will issue an
error and ignore that value.Future of the module instance being executed. Calling
Future.get() will block until execution is complete.public <C extends Command> Future<CommandModule> run(Class<C> commandClass, boolean process, Object... inputs)
CommandServiceIf no command of the given class is registered with the service, then a default one is created and then executed. This default command is not registered with the service for subsequent usage.
run in interface CommandServiceC - Class of the command to execute.commandClass - Class object of the command to execute.process - If true, executes the command with pre- and postprocessing
steps from all available PreprocessorPlugins and
PostprocessorPlugins in the plugin index; if false,
executes the command with no pre- or postprocessing. For more
fine-grained control, see the ModuleService.run(org.scijava.module.ModuleInfo, boolean, java.lang.Object...) methods.inputs - List of input parameter names and values. The expected order
is in pairs: an input name followed by its value, for each desired
input to populate. Leaving some inputs unpopulated is allowed.
Passing the name of an input that is not valid for the plugin, or
passing a value of a type incompatible with the associated input
parameter, will issue an error and ignore that name/value pair.Future of the module instance being executed. Calling
Future.get() will block until execution is complete.public <C extends Command> Future<CommandModule> run(Class<C> commandClass, boolean process, Map<String,Object> inputMap)
CommandServiceIf no command of the given class is registered with the service, then a default one is created and then executed. This default command is not registered with the service for subsequent usage.
run in interface CommandServiceC - Class of the command to execute.commandClass - Class object of the command to execute.process - If true, executes the command with pre- and postprocessing
steps from all available PreprocessorPlugins and
PostprocessorPlugins in the plugin index; if false,
executes the command with no pre- or postprocessing. For more
fine-grained control, see the ModuleService.run(org.scijava.module.ModuleInfo, boolean, java.lang.Object...) methods.inputMap - Table of input parameter values, with keys matching the
plugin's input parameter names. Passing a value of a type
incompatible with the associated input parameter will issue an
error and ignore that value.Future of the module instance being executed. Calling
Future.get() will block until execution is complete.public Future<CommandModule> run(CommandInfo info, boolean process, Object... inputs)
CommandServicerun in interface CommandServiceinfo - The command to instantiate and run.process - If true, executes the command with pre- and postprocessing
steps from all available PreprocessorPlugins and
PostprocessorPlugins in the plugin index; if false,
executes the command with no pre- or postprocessing. For more
fine-grained control, see the ModuleService.run(org.scijava.module.ModuleInfo, boolean, java.lang.Object...) methods.inputs - List of input parameter names and values. The expected order
is in pairs: an input name followed by its value, for each desired
input to populate. Leaving some inputs unpopulated is allowed.
Passing the name of an input that is not valid for the plugin, or
passing a value of a type incompatible with the associated input
parameter, will issue an error and ignore that name/value pair.Future of the module instance being executed. Calling
Future.get() will block until execution is complete.public Future<CommandModule> run(CommandInfo info, boolean process, Map<String,Object> inputMap)
CommandServicerun in interface CommandServiceinfo - The command to instantiate and run.process - If true, executes the command with pre- and postprocessing
steps from all available PreprocessorPlugins and
PostprocessorPlugins in the plugin index; if false,
executes the command with no pre- or postprocessing. For more
fine-grained control, see the ModuleService.run(org.scijava.module.ModuleInfo, boolean, java.lang.Object...) methods.inputMap - Table of input parameter values, with keys matching the
plugin's input parameter names. Passing a value of a type
incompatible with the associated input parameter will issue an
error and ignore that value.Future of the module instance being executed. Calling
Future.get() will block until execution is complete.public Class<Command> getPluginType()
PTServicegetPluginType in interface PTService<Command>public void initialize()
Service
NB: This method is not intended to be called directly. It is called by
the service framework itself (specifically by the ServiceHelper)
when initializing the service. It should not be called a second time.
initialize in interface Initializableinitialize in interface Serviceprotected void onEvent(PluginsRemovedEvent event)
protected void onEvent(PluginsAddedEvent event)
Copyright © 2015–2022 SciJava. All rights reserved.