jworkflow
jworkflow copied to clipboard
Nashorn engine is remove from Java 15.
Nashorn engine is remove from Java 15. It is hard code in WorkflowModule class which will cause issues if someone will use this library with Java 15 or above.
bind(ScriptEngine.class).toInstance(new ScriptEngineManager().getEngineByName("nashorn"));
I had a similar case, I wanted to use this lib on Android and nashorn engine was not found.
I created a new class and call the rhino engine instead.
Take a look at this example, so you could create your own:
` public class AndroidWorkflowModule extends WorkflowModule {
@Override
protected void configure()
{
bind( WorkflowHost .class).to( DefaultWorkflowHost .class);
bind( WorkflowExecutor .class).to( DefaultWorkflowExecutor .class);
bind( WorkflowRegistry .class).to( DefaultWorkflowRegistry .class);
bind( ExecutionPointerFactory .class).to( DefaultExecutionPointerFactory .class);
bind( ExecutionResultProcessor .class).to( DefaultExecutionResultProcessor .class);
bind( DefinitionLoader .class).to( DefaultDefinitionLoader .class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
bind(Clock.class).toInstance(Clock.systemUTC());
}
ScriptEngine theManager = new ScriptEngineManager().getEngineByName ("rhino");
bind( ScriptEngine .class ).toInstance ( theManager );
Multibinder<BackgroundService> backgroundServiceBinder = Multibinder.newSetBinder(binder(), BackgroundService.class);
Multibinder<StepErrorHandler> errorHandlerBinder = Multibinder.newSetBinder(binder(), StepErrorHandler.class );
backgroundServiceBinder .addBinding().to ( WorkflowWorker .class );
backgroundServiceBinder .addBinding().to ( EventWorker .class );
backgroundServiceBinder .addBinding().to ( PollThread .class );
errorHandlerBinder .addBinding().to ( RetryHandler .class );
errorHandlerBinder .addBinding().to ( CompensateHandler .class );
errorHandlerBinder .addBinding().to ( SuspendHandler .class );
errorHandlerBinder .addBinding().to ( TerminateHandler .class );
bind(PersistenceService .class).toProvider ( persistenceProvider );
bind(LockService .class).toProvider ( lockProvider ).asEagerSingleton( );
bind(QueueService .class).toProvider ( queueProvider ).asEagerSingleton( );
}
} `