public interface Module extends Runnable
There are several types of modules, including plugins and scripts, as well as workflows, which are directed acyclic graphs consisting of modules whose inputs and outputs are connected.
The Module
interface represents a specific instance of a module,
while the corresponding ModuleInfo
represents metadata about that
module, particularly its input and output names and types.
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Performs necessary cleanup in response to cancellation of the module
execution.
|
Object |
getDelegateObject()
Gets the object containing the module's actual implementation.
|
ModuleInfo |
getInfo()
Gets metadata about this module.
|
Object |
getInput(String name)
Gets the value of the input with the given name.
|
Map<String,Object> |
getInputs()
Gets a table of input values.
|
Object |
getOutput(String name)
Gets the value of the output with the given name.
|
Map<String,Object> |
getOutputs()
Gets a table of output values.
|
void |
initialize()
Initializes the module.
|
boolean |
isInputResolved(String name)
Gets the resolution status of the input with the given name.
|
boolean |
isOutputResolved(String name)
Gets the resolution status of the output with the given name.
|
default boolean |
isResolved(String name)
Deprecated.
Use
isInputResolved(String) instead. |
void |
preview()
Computes a preview of the module's execution results, if available.
|
void |
resolveInput(String name)
Marks the input with the given name as resolved.
|
void |
resolveOutput(String name)
Marks the output with the given name as resolved.
|
void |
setInput(String name,
Object value)
Sets the value of the input with the given name.
|
void |
setInputs(Map<String,Object> inputs)
Sets input values according to the given table.
|
void |
setOutput(String name,
Object value)
Sets the value of the output with the given name.
|
void |
setOutputs(Map<String,Object> outputs)
Sets output values according to the given table.
|
default void |
setResolved(String name,
boolean resolved)
Deprecated.
Use
resolveInput(String) and
unresolveInput(String) instead. |
void |
unresolveInput(String name)
Marks the input with the given name as unresolved.
|
void |
unresolveOutput(String name)
Marks the output with the given name as unresolved.
|
void preview()
Runnable.run()
. Not all modules support
previews.ModuleInfo.canPreview()
void cancel()
preview()
to undo
any changes made as a result of the preview.ModuleInfo.canCancel()
void initialize() throws MethodCallException
First, the module's global initializer method (if any) is called, followed
by each individual ModuleItem
initializer method (i.e.,
ModuleItem.initialize(Module)
).
MethodCallException
ModuleInfo.getInitializer()
,
ModuleItem.initialize(Module)
ModuleInfo getInfo()
Object getDelegateObject()
getInfo().getDelegateClassName()
. This object must possess all
callback methods specified by ModuleItem.getCallback()
.
The nature of this method is implementation-specific; e.g., a
CommandModule
will return its associated Command
. For
modules that are not plugins, the result may be something else. If you are
implementing this interface directly, a good rule of thumb is to return
this
.
void setOutput(String name, Object value)
void setOutputs(Map<String,Object> outputs)
boolean isInputResolved(String name)
resolveInput(String)
boolean isOutputResolved(String name)
resolveOutput(String)
void resolveInput(String name)
ModulePreprocessor
s in the module execution chain that populate
input values (e.g. InputHarvester
plugins) will typically skip over
inputs which have already been resolved.
void resolveOutput(String name)
ModulePostprocessor
s in the module execution chain that handle
output values (e.g. the DisplayPostprocessor
) will typically skip
over outputs which have already been resolved.
void unresolveInput(String name)
resolveInput(String)
void unresolveOutput(String name)
resolveOutput(String)
@Deprecated default boolean isResolved(String name)
isInputResolved(String)
instead.@Deprecated default void setResolved(String name, boolean resolved)
resolveInput(String)
and
unresolveInput(String)
instead.Copyright © 2015–2022 SciJava. All rights reserved.