Package org.eclipse.ease.service
Class ScriptService
java.lang.Object
org.eclipse.ease.service.ScriptService
- All Implemented Interfaces:
EventListener,IExecutionListener,IScriptService,org.osgi.framework.BundleListener
public final class ScriptService extends Object implements IScriptService, org.osgi.framework.BundleListener, IExecutionListener
-
Field Summary
Fields inherited from interface org.eclipse.ease.IExecutionListener
ENGINE_END, ENGINE_START, SCRIPT_END, SCRIPT_INJECTION_END, SCRIPT_INJECTION_START, SCRIPT_STARTFields inherited from interface org.eclipse.ease.service.IScriptService
TRACE_SCRIPT_SERVICE -
Method Summary
Modifier and Type Method Description voidaddEngineListener(IScriptEngineLaunchExtension listener)Add a listener for engine creations.voidbundleChanged(org.osgi.framework.BundleEvent event)IScriptEnginecreateEngine(EngineDescription description)Create an engine from a given description.ObjectexecuteScript(String scriptLocation, String engineID, String... arguments)Execute a given script and returns the execution result.Map<String,ModuleCategoryDefinition>getAvailableModuleCategories()Get a map of available module categories.Collection<ModuleDefinition>getAvailableModules()Get a map of available modules.Map<String,ScriptType>getAvailableScriptTypes()Get a map of available script tpye.static ICodeFactorygetCodeFactory(IScriptEngine engine)Get the defaultICodeFactoryfor a given script engine.static ICodeParsergetCodeParser(IScriptEngine engine)Get the defaultICodeParserfor a given script engine.EngineDescriptiongetEngine(String scriptType)Get default engine for a given script type.EngineDescriptiongetEngineByID(String engineID)Get a dedicated engine description.Collection<EngineDescription>getEngines()Get available engine descriptions.List<EngineDescription>getEngines(String scriptType)Get available engine descriptions for a given script type.static ScriptServicegetInstance()Collection<IScriptEngineLaunchExtension>getLaunchExtensions(EngineDescription engineDescription)Get Launch extensions for a dedicated script engine.ModuleDefinitiongetModuleDefinition(String moduleId)Get the definition of the module with given ID.Collection<IScriptEngine>getRunningEngines()Get all running script engines.ScriptTypegetScriptType(String location)Get the script type for a given resource location.static IScriptServicegetService()voidnotify(IScriptEngine engine, Script script, int status)Notifies the listeners when script execution started/ended or when the engine itself is started/ended.voidremoveEngineListener(IScriptEngineLaunchExtension listener)Remove a listener for engine creations.
-
Method Details
-
getService
-
getInstance
-
addEngineListener
Description copied from interface:IScriptServiceAdd a listener for engine creations. If already added, nothing will happen.- Specified by:
addEngineListenerin interfaceIScriptService- Parameters:
listener- listener to add.
-
removeEngineListener
Description copied from interface:IScriptServiceRemove a listener for engine creations.- Specified by:
removeEngineListenerin interfaceIScriptService- Parameters:
listener- listener to remove
-
getEngineByID
Description copied from interface:IScriptServiceGet a dedicated engine description. Allows to get an engine description for a dedicated engine identifier.- Specified by:
getEngineByIDin interfaceIScriptService- Parameters:
engineID- engine identifier- Returns:
- script engine description or
null
-
getAvailableModules
Description copied from interface:IScriptServiceGet a map of available modules. Keys contain the full module name, values contain its descriptor.- Specified by:
getAvailableModulesin interfaceIScriptService- Returns:
- available modules or empty map
-
getEngines
Description copied from interface:IScriptServiceGet available engine descriptions.- Specified by:
getEnginesin interfaceIScriptService- Returns:
- available descriptions or empty collection
-
getEngines
Description copied from interface:IScriptServiceGet available engine descriptions for a given script type. The resulting list is sorted by priority. Index 0 contains the engine with the highest priority.- Specified by:
getEnginesin interfaceIScriptService- Parameters:
scriptType- type of script- Returns:
- available descriptions or empty collection
-
getLaunchExtensions
public Collection<IScriptEngineLaunchExtension> getLaunchExtensions(EngineDescription engineDescription)Description copied from interface:IScriptServiceGet Launch extensions for a dedicated script engine.- Specified by:
getLaunchExtensionsin interfaceIScriptService- Parameters:
engineDescription- engine description for further filtering- Returns:
- launch extensions or empty collection
-
getAvailableScriptTypes
Description copied from interface:IScriptServiceGet a map of available script tpye. Keys contain the type name, values contain its descriptor.- Specified by:
getAvailableScriptTypesin interfaceIScriptService- Returns:
- available script types or empty map
-
getScriptType
Description copied from interface:IScriptServiceGet the script type for a given resource location.- Specified by:
getScriptTypein interfaceIScriptService- Parameters:
location- resource location- Returns:
- script type associated with file extension or
null
-
getEngine
Description copied from interface:IScriptServiceGet default engine for a given script type. While there might exist multiple engines, the returned one has the highest priority.- Specified by:
getEnginein interfaceIScriptService- Parameters:
scriptType- type of script- Returns:
- engine description or
null
-
getAvailableModuleCategories
Description copied from interface:IScriptServiceGet a map of available module categories. Keys contain the category id, values contain its descriptor.- Specified by:
getAvailableModuleCategoriesin interfaceIScriptService- Returns:
- available modules or empty map
-
getModuleDefinition
Description copied from interface:IScriptServiceGet the definition of the module with given ID.- Specified by:
getModuleDefinitionin interfaceIScriptService- Parameters:
moduleId- id to look for- Returns:
- module definition
-
getCodeFactory
Get the defaultICodeFactoryfor a given script engine.- Parameters:
engine- script engine to look up- Returns:
- code factory or
null
-
getCodeParser
Get the defaultICodeParserfor a given script engine.- Parameters:
engine- script engine to look up- Returns:
- code factory or
null
-
bundleChanged
public void bundleChanged(org.osgi.framework.BundleEvent event)- Specified by:
bundleChangedin interfaceorg.osgi.framework.BundleListener
-
executeScript
public Object executeScript(String scriptLocation, String engineID, String... arguments) throws ThrowableDescription copied from interface:IScriptServiceExecute a given script and returns the execution result.- Specified by:
executeScriptin interfaceIScriptService- Parameters:
scriptLocation- script location to executeengineID- script engine ID ornullto automatically select a matching enginearguments- script arguments- Returns:
- script result
- Throws:
Throwable- any exception thrown by the script
-
createEngine
Description copied from interface:IScriptServiceCreate an engine from a given description.- Specified by:
createEnginein interfaceIScriptService- Parameters:
description- engine description- Returns:
- script engine instance
-
getRunningEngines
Description copied from interface:IScriptServiceGet all running script engines.- Specified by:
getRunningEnginesin interfaceIScriptService- Returns:
- running engines
-
notify
Description copied from interface:IExecutionListenerNotifies the listeners when script execution started/ended or when the engine itself is started/ended.- Specified by:
notifyin interfaceIExecutionListener- Parameters:
engine- Script Enginescript- Script ornullstatus- Event Status
-