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
  • Method Details

    • getService

      public static IScriptService getService()
    • getInstance

      public static ScriptService getInstance()
    • addEngineListener

      public void addEngineListener​(IScriptEngineLaunchExtension listener)
      Description copied from interface: IScriptService
      Add a listener for engine creations. If already added, nothing will happen.
      Specified by:
      addEngineListener in interface IScriptService
      Parameters:
      listener - listener to add.
    • removeEngineListener

      public void removeEngineListener​(IScriptEngineLaunchExtension listener)
      Description copied from interface: IScriptService
      Remove a listener for engine creations.
      Specified by:
      removeEngineListener in interface IScriptService
      Parameters:
      listener - listener to remove
    • getEngineByID

      public EngineDescription getEngineByID​(String engineID)
      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 interface IScriptService
      Parameters:
      engineID - engine identifier
      Returns:
      script engine description or null
    • getAvailableModules

      public Collection<ModuleDefinition> 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 interface IScriptService
      Returns:
      available modules or empty map
    • getEngines

      public Collection<EngineDescription> getEngines()
      Description copied from interface: IScriptService
      Get available engine descriptions.
      Specified by:
      getEngines in interface IScriptService
      Returns:
      available descriptions or empty collection
    • getEngines

      public List<EngineDescription> getEngines​(String scriptType)
      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 interface IScriptService
      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 interface IScriptService
      Parameters:
      engineDescription - engine description for further filtering
      Returns:
      launch extensions or empty collection
    • getAvailableScriptTypes

      public Map<String,​ScriptType> 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 interface IScriptService
      Returns:
      available script types or empty map
    • getScriptType

      public ScriptType getScriptType​(String location)
      Description copied from interface: IScriptService
      Get the script type for a given resource location.
      Specified by:
      getScriptType in interface IScriptService
      Parameters:
      location - resource location
      Returns:
      script type associated with file extension or null
    • getEngine

      public EngineDescription getEngine​(String scriptType)
      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 interface IScriptService
      Parameters:
      scriptType - type of script
      Returns:
      engine description or null
    • getAvailableModuleCategories

      public Map<String,​ModuleCategoryDefinition> 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 interface IScriptService
      Returns:
      available modules or empty map
    • getModuleDefinition

      public ModuleDefinition getModuleDefinition​(String moduleId)
      Description copied from interface: IScriptService
      Get the definition of the module with given ID.
      Specified by:
      getModuleDefinition in interface IScriptService
      Parameters:
      moduleId - id to look for
      Returns:
      module definition
    • getCodeFactory

      public static ICodeFactory getCodeFactory​(IScriptEngine engine)
      Get the default ICodeFactory for a given script engine.
      Parameters:
      engine - script engine to look up
      Returns:
      code factory or null
    • getCodeParser

      public static ICodeParser getCodeParser​(IScriptEngine engine)
      Get the default ICodeParser 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 interface org.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 interface IScriptService
      Parameters:
      scriptLocation - script location to execute
      engineID - script engine ID or null to automatically select a matching engine
      arguments - script arguments
      Returns:
      script result
      Throws:
      Throwable - any exception thrown by the script
    • createEngine

      public IScriptEngine createEngine​(EngineDescription description)
      Description copied from interface: IScriptService
      Create an engine from a given description.
      Specified by:
      createEngine in interface IScriptService
      Parameters:
      description - engine description
      Returns:
      script engine instance
    • getRunningEngines

      public Collection<IScriptEngine> getRunningEngines()
      Description copied from interface: IScriptService
      Get all running script engines.
      Specified by:
      getRunningEngines in interface IScriptService
      Returns:
      running engines
    • notify

      public void notify​(IScriptEngine engine, Script script, int status)
      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 interface IExecutionListener
      Parameters:
      engine - Script Engine
      script - Script or null
      status - Event Status