Interface SimpleActivity
- All Superinterfaces:
Interruptible
- All Known Implementing Classes:
WaitStep
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 Summary
Modifier and TypeMethodDescriptionA human-readable description for this activity.default ObjectgetLocalCache(String key, Supplier<Object> supplier) Retrieve an item from a local cache that is available during the lifecycle of a singleSimpleWorkflow.start(Map)run.getName()The unique name for this business task.default WorkflowInformationRetrieve the workflow information for this activity.default voidAdd a log message to the execution history for this activity.default voidputLocalCache(String key, Object value) Put an item into a local cache that is available during the lifecycle of a singleSimpleWorkflow.start(Map)run.Begin execution of the taskMethods inherited from interface com.broadleafcommerce.orchestration.internal.Interruptible
allowThreadInterrupt, isInterrupted
-
Method Details
-
start
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
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
Put an item into a local cache that is available during the lifecycle of a singleSimpleWorkflow.start(Map)run. SeegetLocalCache(String, Supplier)for more details.- Parameters:
key- The key for the cache itemvalue- The value to cache
-
getLocalCache
Retrieve an item from a local cache that is available during the lifecycle of a singleSimpleWorkflow.start(Map)run. As a result, there is no guarantee a value previously put into cache will always be available from this method.SimpleActivityimplementations 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 itemsupplier- A supplier to populate the cache if the value is not present. Optional.- Returns:
- The cached value, if available
-
log
Add a log message to the execution history for this activity. Logs are generally referenced in the execution history of the workflow. SeeHistoryElement.getLogs().- Parameters:
logName- Identifying name for the log messagelogMessage- The message to log
-