ScriptFactory
delegates the creation of the ScriptWrapper to the appropriate ScriptLanguageFactoryScriptFactory
creates the script objectScriptFactory
, you just have to implement the ScriptFactory.createScriptLanguageFactoryImpl(short, int, ScriptSource) method to return the appropriate ScriptLanguageFactory
depending on: ScriptSource
which encapsulate the script fileScriptFactory
allows to: ScriptLanguageFactory
, you just have to implement the AbstractScriptLanguageFactory.createBuilderClass(short) and declare which interface this factory makes the scripts implement. public interface MyScript { public default void subscribe() { }Then we could have the following
ScriptLanguageFactory
code: public class CustomScriptLanguageFactory extends AbstractScriptLanguageFactory<MyScript> { protected Class<ScriptBuilder> createBuilderClass(short scriptType) { Class<ScriptBuilder> clazz = null; if (scriptType == ScriptTypes.GROOVY) { clazz = createBuilderClassImpl("my.factory.MyGroovyScriptBuilder"); } else if (scriptType == ScriptTypes.JAVASCRIPT) { clazz = createBuilderClassImpl("my.factory.MyJSScriptBuilder"); } else if (scriptType == ScriptTypes.Ruby) { clazz = createBuilderClassImpl("my.factory.MyRubyScriptBuilder"); } else if (scriptType == ScriptTypes.Python) { clazz = createBuilderClassImpl("my.factory.MyPythonScriptBuilder"); } return clazz; } }And for the code of the builders:
public class CustomGroovyScriptBuilder extends AbstractScriptBuilder { public ScriptWrapper<MyScript> createScriptWrapper() { ScriptWrapper<MyScript> wrapper = new GroovyScriptWrapper<MyScript>() { }; wrapper.addExceptionListener(exceptionListener); wrapper.setScriptContext(context); return wrapper; } }
Copyright 2008-2020 Herve Girod. All Rights Reserved. Documentation and source under the LGPL licence