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.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
etc
src
.gitignore
pom.xml
readme.md

readme.md

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:

@RequestScoped
public class MyBean {

	@Inject 
	@Language("javascript") 
	private ScriptEngine jsEngine;

	// ...

	public void foo() throws ScriptException {

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

}