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 |
isResolved(String name)
Gets the resolution status of the input with the given name.
|
void |
preview()
Computes a preview of the module's execution results, if available.
|
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.
|
void |
setResolved(String name,
boolean resolved)
Sets the resolution status of the input with the given name.
|
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 isResolved(String name)
void setResolved(String name, boolean resolved)
Copyright © 2009–2015 SciJava. All rights reserved.