Calling Javascript classes before script execution

Hi,

we are currently using the Camunda Engine as wildfly module within our application. We have defined some Javascript classes which we would evaluate before executing the script defined in a script task in the BPMN workflow.

We have added a custom ScriptEngineFactory and evaluated those javascript classes in this script engine but somehow they are not known while executing the scripts.

Any ideas ?

Thanks,

Asad.

Hi Asad,

I am not sure I understand the question. You want to invoke some javascript out of another script? Could you may be publish a small example somewhere?

Cheers,
Askar

Sure… This is my custom ScriptEngineFactory:
public class TestScriptEngineFactory implements ScriptEngineFactory {

@Override
public List getNames() {
List names = new ArrayList<>(factory.getNames());
names.add(“test”);
names.add(“Test”);
return names;
}

@Override
public String getLanguageName() {
return “test”;
}

@Override
public String getLanguageVersion() {
return “1.0.0”;
}

@Override
public ScriptEngine getScriptEngine() {
ScriptEngine nse = factory.getScriptEngine(classFilter);
try {
nse.eval(getScriptLibraries());

} catch (ScriptException e) {
  throw new KolibriException("failed to create Kolibri script engine", e);
}
return nse;

}

}

========================

I’m expecting that the camunda engine evaluate my code nse.eval(getScriptLibraries()); before executing the javascript in the script task.
I have put my script engine “test” into the task in the field Script format which seems to work but still it fails to evaluate my scriptlibraries before the execution of the java script in the script task. I guess the variables are not in the right scope but i’m not sure.

Thanks for your help!

Asad