|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ModuleService
Interface for service that tracks and executes available modules.
The module service keeps a master index of all modules known to the system.
At heart, a module is a Runnable
piece of code, but with explicit
typed input and output parameters.
The module service has no innate ability to discover modules, and must be
explicitly told about them via the addModule(org.scijava.module.ModuleInfo)
and addModules(java.util.Collection extends org.scijava.module.ModuleInfo>)
methods.
A module is distinct from a plugin in that plugins extend
ImageJ's functionality in some way, taking many forms, whereas modules are
always runnable code with typed inputs and outputs. There is a particular
type of plugin called a Command
which is also a
module, but many plugins (e.g., Tool
s and
Display
s) are not modules.
Module
,
PluginService
Method Summary | ||
---|---|---|
void |
addModule(ModuleInfo module)
Manually registers a module with the module service. |
|
void |
addModules(Collection<? extends ModuleInfo> modules)
Manually registers a list of modules with the module service. |
|
Module |
createModule(ModuleInfo info)
Creates an instance of the given module. |
|
ModuleIndex |
getIndex()
Gets the index of available modules. |
|
ModuleInfo |
getModuleForAccelerator(Accelerator acc)
Gets the module for a given keyboard shortcut. |
|
List<ModuleInfo> |
getModules()
Gets the list of available modules. |
|
|
getSingleInput(Module module,
Class<T> type)
Checks the given module for a solitary unresolved input of the given type, returning the relevant ModuleItem if found, or null if not exactly
one unresolved input of that type. |
|
|
getSingleOutput(Module module,
Class<T> type)
Checks the given module for a solitary unresolved output of the given type, returning the relevant ModuleItem if found, or null if not exactly
one unresolved output of that type. |
|
void |
removeModule(ModuleInfo module)
Manually unregisters a module with the module service. |
|
void |
removeModules(Collection<? extends ModuleInfo> modules)
Manually unregisters a list of modules with the module service. |
|
|
run(M module,
boolean process,
Map<String,Object> inputMap)
Executes the given module. |
|
|
run(M module,
boolean process,
Object... inputs)
Executes the given module. |
|
|
run(M module,
List<? extends ModulePreprocessor> pre,
List<? extends ModulePostprocessor> post,
Map<String,Object> inputMap)
Executes the given module. |
|
|
run(M module,
List<? extends ModulePreprocessor> pre,
List<? extends ModulePostprocessor> post,
Object... inputs)
Executes the given module. |
|
Future<Module> |
run(ModuleInfo info,
boolean process,
Map<String,Object> inputMap)
Executes the given module. |
|
Future<Module> |
run(ModuleInfo info,
boolean process,
Object... inputs)
Executes the given module. |
|
Future<Module> |
run(ModuleInfo info,
List<? extends ModulePreprocessor> pre,
List<? extends ModulePostprocessor> post,
Map<String,Object> inputMap)
Executes the given module. |
|
Future<Module> |
run(ModuleInfo info,
List<? extends ModulePreprocessor> pre,
List<? extends ModulePostprocessor> post,
Object... inputs)
Executes the given module. |
|
|
waitFor(Future<M> future)
Blocks until the given module is finished executing. |
Methods inherited from interface org.scijava.service.Service |
---|
initialize, registerEventHandlers |
Methods inherited from interface org.scijava.Contextual |
---|
context, getContext, setContext |
Methods inherited from interface org.scijava.Prioritized |
---|
getPriority, setPriority |
Methods inherited from interface java.lang.Comparable |
---|
compareTo |
Methods inherited from interface org.scijava.plugin.HasPluginInfo |
---|
getInfo, setInfo |
Methods inherited from interface org.scijava.Disposable |
---|
dispose |
Method Detail |
---|
ModuleIndex getIndex()
void addModule(ModuleInfo module)
void removeModule(ModuleInfo module)
void addModules(Collection<? extends ModuleInfo> modules)
void removeModules(Collection<? extends ModuleInfo> modules)
List<ModuleInfo> getModules()
ModuleInfo getModuleForAccelerator(Accelerator acc)
acc
- the accelerator for which to search.
Module createModule(ModuleInfo info)
If the module implements the Contextual
interface, the
appropriate context is injected. Similarly, if the module implements the
Prioritized
interface, 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.
Future<Module> run(ModuleInfo info, boolean process, Object... inputs)
info
- The module to instantiate and run.process
- If true, executes the module with pre- and postprocessing
steps from all available PreprocessorPlugin
s and
PostprocessorPlugin
s in the plugin index; if false,
executes the module with no pre- or postprocessing.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 module, 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.Future<Module> run(ModuleInfo info, boolean process, Map<String,Object> inputMap)
info
- The module to instantiate and run.process
- If true, executes the module with pre- and postprocessing
steps from all available PreprocessorPlugin
s and
PostprocessorPlugin
s in the plugin index; if false,
executes the module with no pre- or postprocessing.inputMap
- Table of input parameter values, with keys matching the
ModuleInfo
'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.Future<Module> run(ModuleInfo info, List<? extends ModulePreprocessor> pre, List<? extends ModulePostprocessor> post, Object... inputs)
info
- The module to instantiate and run.pre
- List of preprocessing steps to perform.post
- List of postprocessing steps to perform.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 module, 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.Future<Module> run(ModuleInfo info, List<? extends ModulePreprocessor> pre, List<? extends ModulePostprocessor> post, Map<String,Object> inputMap)
info
- The module to instantiate and run.pre
- List of preprocessing steps to perform.post
- List of postprocessing steps to perform.inputMap
- Table of input parameter values, with keys matching the
ModuleInfo
'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.<M extends Module> Future<M> run(M module, boolean process, Object... inputs)
module
- The module to run.process
- If true, executes the module with pre- and postprocessing
steps from all available PreprocessorPlugin
s and
PostprocessorPlugin
s in the plugin index; if false,
executes the module with no pre- or postprocessing.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 module, 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.<M extends Module> Future<M> run(M module, boolean process, Map<String,Object> inputMap)
module
- The module to run.process
- If true, executes the module with pre- and postprocessing
steps from all available PreprocessorPlugin
s and
PostprocessorPlugin
s in the plugin index; if false,
executes the module with no pre- or postprocessing.inputMap
- Table of input parameter values, with keys matching the
ModuleInfo
'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.<M extends Module> Future<M> run(M module, List<? extends ModulePreprocessor> pre, List<? extends ModulePostprocessor> post, Object... inputs)
module
- The module to run.pre
- List of preprocessing steps to perform.post
- List of postprocessing steps to perform.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 module, 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.<M extends Module> Future<M> run(M module, List<? extends ModulePreprocessor> pre, List<? extends ModulePostprocessor> post, Map<String,Object> inputMap)
module
- The module to run.pre
- List of preprocessing steps to perform.post
- List of postprocessing steps to perform.inputMap
- Table of input parameter values, with keys matching the
module's ModuleInfo
'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.<M extends Module> M waitFor(Future<M> future)
<T> ModuleItem<T> getSingleInput(Module module, Class<T> type)
ModuleItem
if found, or null if not exactly
one unresolved input of that type.
<T> ModuleItem<T> getSingleOutput(Module module, Class<T> type)
ModuleItem
if found, or null if not exactly
one unresolved output of that type.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |