Skip to content
Horacio Hoyos Rodriguez edited this page Jul 30, 2019 · 2 revisions

Using the executors

The minimum required elements for execution are a:

  • Epsilon Executor
  • Language Executor
  • Script

The Epsilon Executor is responsible for correctly configuring the context by add models, parameters and native delegates, and for the actual execution: parsing the script, execution and retrieving the result. An Epsilon Executor requires the specific Language Executor for the language of the script.

A Language Executor is provided for each Epsilon language (EOL, EVL, ETL, EPL, etc.). Each Language Executor provides additional methods/constructors to provide additional information for the specific language.

The Script is the file or string that contains the code we want to execute.

Epsilon Executor

The Epsilon Executor provides different constructors to create executors with different level of details. The full-fledged constructor is presented next:

public EpsilonExecutor(
	EpsilonLanguageExecutor<?> languageExecutor,
	Path scriptPath,
	String code,
	Collection<org.eclipse.epsilon.eol.models.IModel> models,
	Map<String,Object> parameters,
	Collection<org.eclipse.epsilon.eol.types.IToolNativeTypeDelegate> nativeDelegates,
	boolean disposeModels,
	boolean profileExecution)

The parameters are:

  • languageExecutor: the specific language executor
  • scriptPath: the path to the script we want to execute
  • code: the code to execute. If both the script and code are given, only the script is used.
  • models: the collection of models used in the script
  • parameters: external parameters, provided as name:value map
  • nativeDelegates: the native delegates required for execution
  • disposeModels: flag to indicate if models are disposed after execution
  • profileExecution: flag to indicate if the execution should be profiled

Models

Models need to be created before hand using the API of the respective model type, e.g. EMF, CSV, Simulink, etc. The Epsilon-Sigma-Builders project provides a set of Builders that can be used to easily construct models.

Parameters

Parameters are name:value pairs that will be made available to the script during execution as global variables. The value will usually be a primitive type, but it can be any POJO. Note that the executor will correctly wrap the values inside Epsilon variables so no need to do this before hand.

Native type delegates

Epsilon is capable of using java from within a script. To do have access to Java libraries other than the core Java, users need to provide a IToolNativeTypeDelegate. Within Eclipse, this is done via extension points. In non-eclipse scenarios, this parameter allows the user to specify any native delegates required by the script.

Dispose models

After execution the executor can dispose the models used: remove them from the context and unload them. If the models are used between multiple executors it is desirable not to dispose them.

Profile Execution

This flag, if true, enables the execution profiler. The profile results can be retrieved after execution via the

EOL Executor

Assuming you have an EOL script "demo.eol", with the following contents:

operation printHelloWorldAndMessage(message: String) {
    message.print("Hello World, ");
}

The EOL executor can be used to invoke the printHelloWorldAndMessage operation:

EolExecutor eol = new SimpleEolExecutor("printHelloWorldAndMessage", Collections.singletonList("Epsilon"));
Executor executor = new EpsilonExecutor(eol, Paths.get("some/path/to/demo.eol));
executor.invokeExecutor();
Clone this wiki locally