public class DefaultScriptService extends AbstractSingletonService<ScriptLanguage> implements ScriptService
SCRIPTS_PATH_PROPERTY, SCRIPTS_RESOURCE_DIR| Constructor and Description | 
|---|
| DefaultScriptService() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addAlias(String alias,
        Class<?> type)TODO | 
| void | addScriptDirectory(File scriptDirectory)Adds a base directory to scan for scripts. | 
| void | addScriptDirectory(File scriptDirectory,
                  MenuPath menuPrefix)Adds a base directory to scan for scripts, placing discovered scripts
 beneath the given menu path prefix. | 
| Map<String,Class<?>> | getAliases()TODO | 
| ScriptLanguageIndex | getIndex()Gets the index of available scripting languages. | 
| MenuPath | getMenuPrefix(File scriptDirectory)Gets the menu path prefix for the given script directory, or null if none. | 
| ScriptInfo | getScript(File scriptFile)Gets the cached  ScriptInfometadata for the script at the given
 file, creating it if it does not already exist. | 
| List<File> | getScriptDirectories()Gets the base directories to scan for scripts. | 
| Collection<ScriptInfo> | getScripts()Gets all available scripts. | 
| void | initialize()Performs any needed initialization when the service is first loaded. | 
| Class<?> | lookupClass(String alias)TODO | 
| void | removeScriptDirectory(File scriptDirectory)Removes a base directory to scan for scripts. | 
| Future<ScriptModule> | run(File file,
   boolean process,
   Map<String,Object> inputMap)Executes the script in the given file. | 
| Future<ScriptModule> | run(File file,
   boolean process,
   Object... inputs)Executes the script in the given file. | 
| Future<ScriptModule> | run(ScriptInfo info,
   boolean process,
   Map<String,Object> inputMap)Executes the given script. | 
| Future<ScriptModule> | run(ScriptInfo info,
   boolean process,
   Object... inputs)Executes the given script. | 
getInstance, getInstances, objectService, onEvent, onEventpluginServicegetContext, setContext, toStringgetInfo, getPriority, setInfo, setPrioritycontextclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddAlias, canHandleFile, canHandleFile, getLanguageByExtension, getLanguageByName, getLanguages, getPluginType, run, run, run, runcreate, filterInstances, getInstance, getInstances, objectServicegetPlugins, getPluginService, pluginServiceregisterEventHandlersgetIdentifier, logcontext, getContext, setContextcompareTo, getPriority, setPrioritygetInfo, setInfogetLocationgetVersiondisposepublic ScriptLanguageIndex getIndex()
ScriptServicegetIndex in interface ScriptServicepublic List<File> getScriptDirectories()
ScriptServicegetScriptDirectories in interface ScriptServicepublic MenuPath getMenuPrefix(File scriptDirectory)
ScriptServicegetMenuPrefix in interface ScriptServicepublic void addScriptDirectory(File scriptDirectory)
ScriptServiceaddScriptDirectory in interface ScriptServicepublic void addScriptDirectory(File scriptDirectory, MenuPath menuPrefix)
ScriptServiceaddScriptDirectory in interface ScriptServicepublic void removeScriptDirectory(File scriptDirectory)
ScriptServiceremoveScriptDirectory in interface ScriptServicepublic Collection<ScriptInfo> getScripts()
ScriptServicegetScripts in interface ScriptServicepublic ScriptInfo getScript(File scriptFile)
ScriptServiceScriptInfo metadata for the script at the given
 file, creating it if it does not already exist.getScript in interface ScriptServicepublic Future<ScriptModule> run(File file, boolean process, Object... inputs)
ScriptServicerun in interface ScriptServicefile - File containing the script to execute.process - If true, executes the script with pre- and postprocessing
          steps from all available PreprocessorPlugins and
          PostprocessorPlugins in the plugin index; if false,
          executes the script 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 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<ScriptModule> run(File file, boolean process, Map<String,Object> inputMap)
ScriptServicerun in interface ScriptServicefile - File containing the script to execute.process - If true, executes the script with pre- and postprocessing
          steps from all available PreprocessorPlugins and
          PostprocessorPlugins in the plugin index; if false,
          executes the script with no pre- or postprocessing.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<ScriptModule> run(ScriptInfo info, boolean process, Object... inputs)
ScriptServicerun in interface ScriptServiceinfo - The script to instantiate and run.process - If true, executes the script with pre- and postprocessing
          steps from all available PreprocessorPlugins and
          PostprocessorPlugins in the plugin index; if false,
          executes the script 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 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<ScriptModule> run(ScriptInfo info, boolean process, Map<String,Object> inputMap)
ScriptServicerun in interface ScriptServiceinfo - The script to instantiate and run.process - If true, executes the script with pre- and postprocessing
          steps from all available PreprocessorPlugins and
          PostprocessorPlugins in the plugin index; if false,
          executes the script with no pre- or postprocessing.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 void addAlias(String alias, Class<?> type)
ScriptServiceaddAlias in interface ScriptServicepublic Map<String,Class<?>> getAliases()
ScriptServicegetAliases in interface ScriptServicepublic Class<?> lookupClass(String alias) throws ScriptException
ScriptServicelookupClass in interface ScriptServiceScriptExceptionpublic 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 SingletonService<ScriptLanguage>initialize in interface ServiceCopyright © 2009–2022 SciJava. All rights reserved.