Skip to content

gunnarmorling/scripting-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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");
		// ...
	}

}

About

A CDI portable extension allowing to retrieve JSR 223 scripting engines via dependency injection

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages