Chapter 60. Work item handler project customization
You can customize the code of a work item handler project. There are two Java methods required by a work item handler, executeWorkItem
and abortWorkItem
.
Java Method | Description |
---|---|
| Executed by default when the work item handler is run. |
| Executed when the work item is aborted. |
In both methods, the WorkItemDefinition
parameter contains any of the parameters entered into the custom task through a GUI or API call, and the WorkItem
parameter is responsible for tracking the state of the custom task.
Example code structure
public class MyWorkItemWorkItemHandler extends AbstractLogOrThrowWorkItemHandler { public void executeWorkItem(WorkItem workItem, WorkItemManager manager) { try { RequiredParameterValidator.validate(this.getClass(), workItem); // sample parameters String sampleParam = (String) workItem.getParameter("SampleParam"); String sampleParamTwo = (String) workItem.getParameter("SampleParamTwo"); // complete workitem impl... // return results String sampleResult = "sample result"; Map<String, Object> results = new HashMap<String, Object>(); results.put("SampleResult", sampleResult); manager.completeWorkItem(workItem.getId(), results); } catch(Throwable cause) { handleException(cause); } } @Override public void abortWorkItem(WorkItem workItem, WorkItemManager manager) { // similar } }
Parameter | Description |
---|---|
|
Checks that all parameters marked “required” are present. If they are not, an |
|
Example of getting a parameter from the |
| Executes the custom Java code when a parameter is received. |
| Passes results to the custom task. The results are placed in the data output areas of the custom task. |
|
Marks the work item handler as complete. The |
| Aborts the custom Java code. May be left blank if the work item is not designed to be aborted |
Red Hat Process Automation Manager includes a limited set of supported custom tasks. Custom tasks that are not included in Red Hat Process Automation Manager are not supported.