Difference between revisions of "Use of node node"
From OpenKM Documentation
(Created page with 'You can define the behavior of a node of type node suing the Action element. This Action is executed when the process arrives to the node. The Action to be executed can be defin…') |
|||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | You can define the behavior of a node of type node | + | You can define the behavior of a node of type node using the Action element. This Action is executed when the process arrives to the node. |
The Action to be executed can be defined in two ways: | The Action to be executed can be defined in two ways: | ||
* Using a BeanShell script. | * Using a BeanShell script. | ||
− | * Using an action handler, this is a Java class which implements the ActionHandler interface. | + | * Using an action handler, this is a Java class which implements the [http://docs.jboss.com/jbpm/v3.2/javadoc-jpdl/org/jbpm/graph/def/ActionHandler.html ActionHandler] interface. |
+ | |||
+ | Below we are going to create a sample process with a ''node'' node which make use of an implementation of the [http://docs.jboss.com/jbpm/v3.2/javadoc-jpdl/org/jbpm/graph/def/ActionHandler.html ActionHandler] interface. | ||
+ | |||
+ | {{Note|Source Eclipse project at [[File:Workflow samples.zip]].}} | ||
+ | |||
+ | In this image you can see the process definition graph: | ||
+ | |||
+ | [[File:Jbpm sample node.png|center]] | ||
+ | |||
+ | This process begins in a start node and go to a ''node'' node where the action to be performed is defined by the class ''MyAction'' which implements the [http://docs.jboss.com/jbpm/v3.2/javadoc-jpdl/org/jbpm/graph/def/ActionHandler.html ActionHandler] interface. | ||
+ | |||
+ | <source lang="java"> | ||
+ | public class MyAction implements ActionHandler { | ||
+ | private static final long serialVersionUID = 1L; | ||
+ | |||
+ | @Override | ||
+ | public void execute(ExecutionContext executionContext) throws Exception { | ||
+ | System.out.println("Executing programmed action..."); | ||
+ | |||
+ | // Go to next node | ||
+ | executionContext.getToken().signal(); | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | The last line of this action tell the jBPM engine to go to the next node, which in this case is the end node. | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="node node"> | ||
+ | <start-state name="start"> | ||
+ | <transition to="node"></transition> | ||
+ | </start-state> | ||
+ | <node name="node"> | ||
+ | <action class="com.openkm.sample.MyAction"></action> | ||
+ | <transition to="end"></transition> | ||
+ | </node> | ||
+ | <end-state name="end"></end-state> | ||
+ | </process-definition> | ||
+ | </source> | ||
[[Category: Workflow Guide]] | [[Category: Workflow Guide]] |
Latest revision as of 11:47, 3 December 2012
You can define the behavior of a node of type node using the Action element. This Action is executed when the process arrives to the node.
The Action to be executed can be defined in two ways:
- Using a BeanShell script.
- Using an action handler, this is a Java class which implements the ActionHandler interface.
Below we are going to create a sample process with a node node which make use of an implementation of the ActionHandler interface.
Source Eclipse project at File:Workflow samples.zip. |
In this image you can see the process definition graph:
This process begins in a start node and go to a node node where the action to be performed is defined by the class MyAction which implements the ActionHandler interface.
public class MyAction implements ActionHandler {
private static final long serialVersionUID = 1L;
@Override
public void execute(ExecutionContext executionContext) throws Exception {
System.out.println("Executing programmed action...");
// Go to next node
executionContext.getToken().signal();
}
}
The last line of this action tell the jBPM engine to go to the next node, which in this case is the end node.
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="node node">
<start-state name="start">
<transition to="node"></transition>
</start-state>
<node name="node">
<action class="com.openkm.sample.MyAction"></action>
<transition to="end"></transition>
</node>
<end-state name="end"></end-state>
</process-definition>