A CDI portable extension allowing to retrieve JSR 223 scripting engines via dependency injection
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


What is it?

This project provides a CDI ("Contexts and Dependency Injection for the JavaTM EE platform", defined by JSR 299) portable extension, which allows to retrieve JSR 223 ("Scripting for the JavaTM Platform") script engines via dependency injection.

Just annotate any injection points of type javax.script.ScriptEngine with one of the qualifier annotations @Language, @Extension or @MimeType. The following shows an example of a JavaScript engine (for example the Rhino engine shipping with Java 6) being injected into some managed bean, where it can be used for arbitrary script evaluations:

public class MyBean {

	private ScriptEngine jsEngine;

	// ...

	public void foo() throws ScriptException {

		assert 42.0d == (Double)jsEngine.eval("2 * 21");
		// ...