ScriptLanguageFactory
is that it will create scripts which will implement one specified interface. For example, if you want to create scripts which will implement the following interface: public interface MyScript { public int compute(); }You will have to define the following
ScriptLanguageFactory
: public class DefaultScriptLanguageFactory extends AbstractScriptLanguageFactory<MyScript> { protected Class<ScriptBuilder> createBuilderClass(short scriptType) { create a builder which will create scripts of the specified script type } }
scriptType
is one of the values defined in the ScriptTypes: MyScript
interface, and for Groovy scripts, it would be: public class MyGroovyScriptBuilder extends AbstractScriptBuilder { public ScriptWrapper<MyScript> createScriptWrapper() { // create the GroovyScriptWrapper, see the documentation for the scriptHelper scripting library // (https://sourceforge.net/projects/scripthelper/) ScriptWrapper<MyScript> wrapper = new GroovyScriptWrapper<MyScript> () { }; // add the default imports for the javaXUL library addDefaultImports(wrapper); // set the exception listener and the script context wrapper.addExceptionListener(exceptionListener); wrapper.setScriptContext(context); return wrapper; } }
org.scripthelper.model.ScriptWrapper
is a wrapper around a script seen as implementing an interface. See the sourceforge.net/projects/scripthelper/ for more information. The Copyright 2008-2020 Herve Girod. All Rights Reserved. Documentation and source under the LGPL licence