Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: for the plan.

Jump to: navigation, search

EASE/Module Contribution

Modules: what they do

A module is a simple java class, providing some public methods. When a module gets loaded EASE creates wrapper code in the target script language to access these public methods. Such methods are far more convenient to use than providing pure Java code. Furthermore they render your script more readable.

Use existing code

The simplest way to create such wrappers is to use the wrap(instance) command, which is provided by the Environment module. Use it to wrap public methods from a given Java instance.

homeFolder = new"/home/me");
exists(); // maps to homeFolder.exists()

While the file class might not be a suitable candidate for wrapping, utility classes are typically a better choice.

Write your own module

Writing your own module gives you a better chance to fine tune which methods you like to expose to scripting. Start by creating a new extension point org.eclipse.ease.modules and add a module contribution to it. Provide a name and an implementing class, which may be a POJO. Optionally provide a category and the default visibility of your module. Modules may have dependencies to other modules (which will be loaded automatically on a loadModule()),

When implementing your class you may use @WrapToScript annotations for methods (and static fields) to be exposed. Method parameters may be defined as optional in the script language. Therefore add a @ScriptParameter(defaultValue="something") annotation in front of the parameter and provide a useful default value. As we may provide strings only, EASE will do its best to adapt the given string to the correct object type expected by the method.

A simple implementation might look like this

public class Calculator {

 public static final double PI = 3.1415;

 public double area(double radius) {
   return radius * PI;

A more detailed example can be found in the Code & me blog.

Module Parameters using Reflection

To enable the Module Explorer and other features in EASE to display the name of the parameters in the view you need the -parameters option to javac when compiling the Module file. In Eclipse this is done for the JDT compiler in the project settings by checking "Store information about method parameters" (formally org.eclipse.jdt.core.compiler.codegen.methodParameters=generate in .settings/org.eclipse.jdt.core.prefs). See the JDT help. See Bug 514855 for details of when this feature was added.

Back to the top