Developing New Plugins: SDK Tools

The Dalet Flex team have developed a library to ease plugin development and further integration with the Dalet Flex Enterprise product and SDK libraries. Expression resolution and Action Steps are the first two components of SDK Tools.

Action Steps

In Action Progress, it was explained how JEF can run a large number of asynchronous jobs. ActionProgress can be used to phase a plugin flow in multiple iterations at execution time. With each iteration of the ActionProgress, the execution developer can define what to do in the JEF plugin execution.

However, there might be a formal requirement to break down the plugin task. For example, you might want a plugin to:

  1. Load and parse a file.
  2. Using the result of the parsing, execute another asynchronous task.
  3. When the asynchronous tasks are complete, update Dalet Flex.
  4. Finally, perform some file writing.

Action steps ease the development of the above steps in independent classes. JEF will orchestrate calling these steps. The steps can be defined linearly, or could be a graph of options based on the logic of the plugin and current status.

Action steps can also be used to reuse part of plugins, or orchestrate different flows depending on plugin logic or retry status.

Please see the flex-jefexampleexecutor-service for a plugin example.

ActionStep

Define your implementation of ActionStep with an enum that contains each of the steps you’d like to register in the plugin:

public enum StepExampleActionStep implements ActionStep {

   _STEP1_("step1"),
   _STEP2_("step2"),
   _STEP3_("step3"),
   _STEP4_("step4");
…

ActionProgressStepData

A new ActionProgressStepData class (extending ActionProgressData) will define the ActionStep defined for this plugin and provide support to track the step where the plugin is running at every call to execute().

public class StepExampleActionStepData extendsActionProgressStepData {
   ...

   @Override
  public Class<? extends ActionStep> getActionStepClass() {

       return StepExampleActionStep.class;
   }
}

Hooking your ActionStep to ActionProgress

In your ActionProgress, use the autowired ActionStepService to delegate the execution:

@Override
public ActionExecutorMessage execute(Job job, StepExampleActionStepData actionProgressData) {

   return actionStepService.execute(this, job, actionProgressData);
}

ActionStepHandler

For each of your steps, define a class implementing ActionStepHandler. In this class, you’ll be called to execute(…) receiving the ActionStepData.

Also define which step you can resolve in your class.

public class StepExampleActionStepHandler1 implements ActionStepHandler<StepExampleActionStepData>{

   @Override
   public ActionExecutorMessage doHandle(ActionProgress actionProgress, Job job,
           StepExampleActionStepData actionStepData) {

       ….

       actionProgress.getActionExecutorLogger().info("Step1 completed.");
       return new ActionExecutorUpdate(executionId, JobStatus.RUNNING, 30, "Job is Running");
   }

   @Override
   public boolean canHandle(StepExampleActionStepData actionStepData) {

       return actionStepData.getActionStep() == StepExampleActionStep.STEP1;
   }
}

This is all you need to organise your plugin execution into smaller, reusable functional components.