Interface SimpleActivity

All Superinterfaces:
Interruptible
All Known Implementing Classes:
WaitStep

public interface SimpleActivity extends Interruptible
Prescribed interface to support initiation of a business task as part of an ordered/orchestrated workflow.

Example for a fictitious provisioning activity:

 
 @RequiredArgsConstructor
 public class ProvisionRequestActivityImpl implements SimpleActivity {

      private final ConnectionProperties connectionProperties;

     @Override
     public ActivityResponse start(Map<String, Object> context) {
         // do work
     }

     @Override
     public String getName() {
          return "provisionRequestActivity";
     }

 }
 
 
  • Method Details

    • start

      ActivityResponse start(Map<String,Object> context)
      Begin execution of the task
      Parameters:
      context - Any information needed to perform the task
      Returns:
      status and context data resulting from execution
    • getName

      String getName()
      The unique name for this business task. Should match the Spring bean name for the activity bean.
      Returns:
      The unique name for this business task.
    • getDescription

      String getDescription()
      A human-readable description for this activity. Generally also unique like the name to ensure clarity in the admin UI.
      Returns:
      A human-readable description for this activity.
    • getWorkflowInformation

      default WorkflowInformation getWorkflowInformation()
      Retrieve the workflow information for this activity. This is generally used to provide additional context for the activity execution.
      Returns:
      The workflow information for this activity
    • putLocalCache

      default void putLocalCache(String key, Object value)
      Put an item into a local cache that is available during the lifecycle of a single SimpleWorkflow.start(Map) run. See getLocalCache(String, Supplier) for more details.
      Parameters:
      key - The key for the cache item
      value - The value to cache
    • getLocalCache

      @Nullable default Object getLocalCache(String key, @Nullable Supplier<Object> supplier)
      Retrieve an item from a local cache that is available during the lifecycle of a single SimpleWorkflow.start(Map) run. As a result, there is no guarantee a value previously put into cache will always be available from this method. SimpleActivity implementations that wish to use this feature should be coded defensively to fetch necessary items and re-add to cache should null be returned from here. Optionally, a supplier can be provided to populate the cache if the value is not present.
      Parameters:
      key - The key for the cache item
      supplier - A supplier to populate the cache if the value is not present. Optional.
      Returns:
      The cached value, if available
    • log

      default void log(String logName, String logMessage)
      Add a log message to the execution history for this activity. Logs are generally referenced in the execution history of the workflow. See HistoryElement.getLogs().
      Parameters:
      logName - Identifying name for the log message
      logMessage - The message to log