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_START
Fields inherited from interface org.eclipse.ease.service.IScriptService
TRACE_SCRIPT_SERVICE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener for engine creations.void
bundleChanged
(org.osgi.framework.BundleEvent event) createEngine
(EngineDescription description) Create an engine from a given description.executeScript
(String scriptLocation, String engineID, String... arguments) Execute a given script and returns the execution result.Get a map of available module categories.Get a map of available modules.Get a map of available script tpye.static ICodeFactory
getCodeFactory
(IScriptEngine engine) Get the defaultICodeFactory
for a given script engine.static ICodeParser
getCodeParser
(IScriptEngine engine) Get the defaultICodeParser
for a given script engine.Get default engine for a given script type.getEngineByID
(String engineID) Get a dedicated engine description.Get available engine descriptions.getEngines
(String scriptType) Get available engine descriptions for a given script type.static ScriptService
getLaunchExtensions
(EngineDescription engineDescription) Get Launch extensions for a dedicated script engine.getModuleDefinition
(String moduleId) Get the definition of the module with given ID.Get all running script engines.getScriptType
(String location) Get the script type for a given resource location.static IScriptService
void
notify
(IScriptEngine engine, Script script, int status) Notifies the listeners when script execution started/ended or when the engine itself is started/ended.void
Remove a listener for engine creations.
-
Method Details
-
getService
-
getInstance
-
addEngineListener
Description copied from interface:IScriptService
Add a listener for engine creations. If already added, nothing will happen.- Specified by:
addEngineListener
in interfaceIScriptService
- Parameters:
listener
- listener to add.
-
removeEngineListener
Description copied from interface:IScriptService
Remove a listener for engine creations.- Specified by:
removeEngineListener
in interfaceIScriptService
- Parameters:
listener
- listener to remove
-
getEngineByID
Description copied from interface:IScriptService
Get a dedicated engine description. Allows to get an engine description for a dedicated engine identifier.- Specified by:
getEngineByID
in interfaceIScriptService
- Parameters:
engineID
- engine identifier- Returns:
- script engine description or
null
-
getAvailableModules
Description copied from interface:IScriptService
Get a map of available modules. Keys contain the full module name, values contain its descriptor.- Specified by:
getAvailableModules
in interfaceIScriptService
- Returns:
- available modules or empty map
-
getEngines
Description copied from interface:IScriptService
Get available engine descriptions.- Specified by:
getEngines
in interfaceIScriptService
- Returns:
- available descriptions or empty collection
-
getEngines
Description copied from interface:IScriptService
Get 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:
getEngines
in interfaceIScriptService
- Parameters:
scriptType
- type of script- Returns:
- available descriptions or empty collection
-
getLaunchExtensions
public Collection<IScriptEngineLaunchExtension> getLaunchExtensions(EngineDescription engineDescription) Description copied from interface:IScriptService
Get Launch extensions for a dedicated script engine.- Specified by:
getLaunchExtensions
in interfaceIScriptService
- Parameters:
engineDescription
- engine description for further filtering- Returns:
- launch extensions or empty collection
-
getAvailableScriptTypes
Description copied from interface:IScriptService
Get a map of available script tpye. Keys contain the type name, values contain its descriptor.- Specified by:
getAvailableScriptTypes
in interfaceIScriptService
- Returns:
- available script types or empty map
-
getScriptType
Description copied from interface:IScriptService
Get the script type for a given resource location.- Specified by:
getScriptType
in interfaceIScriptService
- Parameters:
location
- resource location- Returns:
- script type associated with file extension or
null
-
getEngine
Description copied from interface:IScriptService
Get default engine for a given script type. While there might exist multiple engines, the returned one has the highest priority.- Specified by:
getEngine
in interfaceIScriptService
- Parameters:
scriptType
- type of script- Returns:
- engine description or
null
-
getAvailableModuleCategories
Description copied from interface:IScriptService
Get a map of available module categories. Keys contain the category id, values contain its descriptor.- Specified by:
getAvailableModuleCategories
in interfaceIScriptService
- Returns:
- available modules or empty map
-
getModuleDefinition
Description copied from interface:IScriptService
Get the definition of the module with given ID.- Specified by:
getModuleDefinition
in interfaceIScriptService
- Parameters:
moduleId
- id to look for- Returns:
- module definition
-
getCodeFactory
Get the defaultICodeFactory
for a given script engine.- Parameters:
engine
- script engine to look up- Returns:
- code factory or
null
-
getCodeParser
Get the defaultICodeParser
for 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:
bundleChanged
in interfaceorg.osgi.framework.BundleListener
-
executeScript
public Object executeScript(String scriptLocation, String engineID, String... arguments) throws Throwable Description copied from interface:IScriptService
Execute a given script and returns the execution result.- Specified by:
executeScript
in interfaceIScriptService
- Parameters:
scriptLocation
- script location to executeengineID
- script engine ID ornull
to automatically select a matching enginearguments
- script arguments- Returns:
- script result
- Throws:
Throwable
- any exception thrown by the script
-
createEngine
Description copied from interface:IScriptService
Create an engine from a given description.- Specified by:
createEngine
in interfaceIScriptService
- Parameters:
description
- engine description- Returns:
- script engine instance
-
getRunningEngines
Description copied from interface:IScriptService
Get all running script engines.- Specified by:
getRunningEngines
in interfaceIScriptService
- Returns:
- running engines
-
notify
Description copied from interface:IExecutionListener
Notifies the listeners when script execution started/ended or when the engine itself is started/ended.- Specified by:
notify
in interfaceIExecutionListener
- Parameters:
engine
- Script Enginescript
- Script ornull
status
- Event Status
-