public class DefaultModuleService extends AbstractService implements ModuleService
Module,
ModuleInfo| Constructor and Description |
|---|
DefaultModuleService() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
<T> T |
getDefaultValue(ModuleItem<T> item)
Gets the default value of the given
ModuleItem. |
ModuleIndex |
getIndex()
Gets the index of available modules.
|
ModuleInfo |
getModuleById(String id)
Gets the module with the given identifier string.
|
ModuleInfo |
getModuleForAccelerator(Accelerator acc)
Gets the module for a given keyboard shortcut.
|
List<ModuleInfo> |
getModules()
Gets the list of available modules.
|
<T> ModuleItem<T> |
getSingleInput(Module module,
Class<T> type)
Checks the given module for a solitary unresolved fillable input of the
given type, returning the relevant
ModuleItem if found, or null if
not exactly one unresolved fillable input of that type. |
ModuleItem<?> |
getSingleInput(Module module,
Collection<Class<?>> types)
As
ModuleService.getSingleInput(Module, Class) but will match with a set of
potential classes, at the cost of generic parameter safety. |
<T> ModuleItem<T> |
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. |
ModuleItem<?> |
getSingleOutput(Module module,
Collection<Class<?>> types)
As
ModuleService.getSingleOutput(Module, Class) but will match with a set of
potential classes, at the cost of generic parameter safety. |
void |
initialize()
Performs any needed initialization when the service is first loaded.
|
<T> T |
load(ModuleItem<T> item)
Returns the value, if any, stored in the
PrefService for the given
ModuleItem. |
void |
loadInputs(Module module)
Loads values from persistent storage into the given
Module. |
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.
|
<M extends Module> |
run(M module,
boolean process,
Map<String,Object> inputMap)
Executes the given module.
|
<M extends Module> |
run(M module,
boolean process,
Object... inputs)
Executes the given module.
|
<M extends Module> |
run(M module,
List<? extends ModulePreprocessor> pre,
List<? extends ModulePostprocessor> post,
Map<String,Object> inputMap)
Executes the given module.
|
<M extends 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.
|
<T> void |
save(ModuleItem<T> item,
T value)
Registers the given value for the given
ModuleItem using the
PrefService. |
void |
saveInputs(Module module)
Saves values to persistent storage from the given
Module. |
<M extends Module> |
waitFor(Future<M> future)
Blocks until the given module is finished executing.
|
getContext, setContext, toStringgetInfo, getPriority, setInfo, setPrioritycontextclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitregisterEventHandlersgetIdentifier, logcontext, getContext, setContextcompareTo, getPriority, setPrioritygetInfo, setInfogetLocationgetVersiondisposepublic ModuleIndex getIndex()
ModuleServicegetIndex in interface ModuleServicepublic void addModule(ModuleInfo module)
ModuleServiceaddModule in interface ModuleServicepublic void removeModule(ModuleInfo module)
ModuleServiceremoveModule in interface ModuleServicepublic void addModules(Collection<? extends ModuleInfo> modules)
ModuleServiceaddModules in interface ModuleServicepublic void removeModules(Collection<? extends ModuleInfo> modules)
ModuleServiceremoveModules in interface ModuleServicepublic List<ModuleInfo> getModules()
ModuleServicegetModules in interface ModuleServicepublic ModuleInfo getModuleById(String id)
ModuleServicegetModuleById in interface ModuleServiceid - The identifier string corresponding to the desired module.Identifiable module with the given identifier.public ModuleInfo getModuleForAccelerator(Accelerator acc)
ModuleServicegetModuleForAccelerator in interface ModuleServiceacc - the accelerator for which to search.public Module createModule(ModuleInfo info)
ModuleService
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.
createModule in interface ModuleServicepublic Future<Module> run(ModuleInfo info, boolean process, Object... inputs)
ModuleServicerun in interface ModuleServiceinfo - The module to instantiate and run.process - If true, executes the module with pre- and postprocessing
steps from all available PreprocessorPlugins and
PostprocessorPlugins 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.public Future<Module> run(ModuleInfo info, boolean process, Map<String,Object> inputMap)
ModuleServicerun in interface ModuleServiceinfo - The module to instantiate and run.process - If true, executes the module with pre- and postprocessing
steps from all available PreprocessorPlugins and
PostprocessorPlugins 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.public Future<Module> run(ModuleInfo info, List<? extends ModulePreprocessor> pre, List<? extends ModulePostprocessor> post, Object... inputs)
ModuleServicerun in interface ModuleServiceinfo - 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.public Future<Module> run(ModuleInfo info, List<? extends ModulePreprocessor> pre, List<? extends ModulePostprocessor> post, Map<String,Object> inputMap)
ModuleServicerun in interface ModuleServiceinfo - 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.public <M extends Module> Future<M> run(M module, boolean process, Object... inputs)
ModuleServicerun in interface ModuleServicemodule - The module to run.process - If true, executes the module with pre- and postprocessing
steps from all available PreprocessorPlugins and
PostprocessorPlugins 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.public <M extends Module> Future<M> run(M module, boolean process, Map<String,Object> inputMap)
ModuleServicerun in interface ModuleServicemodule - The module to run.process - If true, executes the module with pre- and postprocessing
steps from all available PreprocessorPlugins and
PostprocessorPlugins 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.public <M extends Module> Future<M> run(M module, List<? extends ModulePreprocessor> pre, List<? extends ModulePostprocessor> post, Object... inputs)
ModuleServicerun in interface ModuleServicemodule - 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.public <M extends Module> Future<M> run(M module, List<? extends ModulePreprocessor> pre, List<? extends ModulePostprocessor> post, Map<String,Object> inputMap)
ModuleServicerun in interface ModuleServicemodule - 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.public <M extends Module> M waitFor(Future<M> future)
ModuleServicewaitFor in interface ModuleServicepublic <T> ModuleItem<T> getSingleInput(Module module, Class<T> type)
ModuleServiceModuleItem if found, or null if
not exactly one unresolved fillable input of that type.getSingleInput in interface ModuleServicepublic <T> ModuleItem<T> getSingleOutput(Module module, Class<T> type)
ModuleServiceModuleItem if found, or null if not exactly
one unresolved output of that type.getSingleOutput in interface ModuleServicepublic ModuleItem<?> getSingleInput(Module module, Collection<Class<?>> types)
ModuleServiceModuleService.getSingleInput(Module, Class) but will match with a set of
potential classes, at the cost of generic parameter safety.getSingleInput in interface ModuleServicepublic ModuleItem<?> getSingleOutput(Module module, Collection<Class<?>> types)
ModuleServiceModuleService.getSingleOutput(Module, Class) but will match with a set of
potential classes, at the cost of generic parameter safety.getSingleOutput in interface ModuleServicepublic <T> void save(ModuleItem<T> item, T value)
ModuleServiceModuleItem using the
PrefService.save in interface ModuleServicepublic <T> T load(ModuleItem<T> item)
ModuleServicePrefService for the given
ModuleItem.load in interface ModuleServicepublic <T> T getDefaultValue(ModuleItem<T> item)
ModuleServiceModuleItem.getDefaultValue in interface ModuleServicepublic void saveInputs(Module module)
ModuleServiceModule.saveInputs in interface ModuleServicepublic void loadInputs(Module module)
ModuleServiceModule.loadInputs in interface ModuleServicepublic 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 ServiceCopyright © 2015–2022 SciJava. All rights reserved.