There are several simple tasks that can be used as the basis of extending the workflow environment by adding your own tasks. Here are some:
org.dwfa.bpa.tasks.web.FetchFromWeb A task that reads a string from a URL, parses the string,
and presents the string to the user in a dialog. This task demonstrates how tasks can connecting to servers over the network,
and do something with those results. org.dwfa.bpa.tasks.dialog.ShowInfoDialog A task that displays a message to the user. The message was set when the process
was created in the process builder, using standard JavaBeans property editor conventions.org.dwfa.bpa.tasks.AbstractTask. Put the
code to execute the tasks desired action in the evaluate method of your class. Pattern your class after one of the existing example tasks, then add new functionality as desired.
The org.dwfa.bpa.tasks.web.FetchFromWeb task and the org.dwfa.bpa.tasks.dialog.ShowInfoDialog tasks provide simple examples. beanSpec entry such as this entry for the FetchFromWeb task:
<plugin>
<groupId>org.dwfa.maven</groupId>
<artifactId>dwfa-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<specs>
<beanSpec>
<sourceName>org.dwfa.bpa.tasks.web.FetchFromWeb</sourceName>
<dirName>web</dirName>
</beanSpec>
<specs>
<configuration>
<plugin>
Additional bean specifications can be
specified by adding additional beanSpec entries to the plugin configuration.process module into your eclipse environment.org.dwfa.bpa.tasks.dialog package. Right click on this package, and select New > Class.
Name the new class HelloWorldDialog, and set the Superclass to be org.dwfa.bpa.tasks.AbstractTask, and select the
checkbox labeled "Inherited abstract methods". Now commit this dialog, and create the class.
public int[] getDataContainerIds() {
// TODO Auto-generated method stub
return null;
}
to the following:
public int[] getDataContainerIds() {
return new int[] {};
}
This method will be deprecated in future versions of the architecture.
public Collection<Condition> getConditions() {
// TODO Auto-generated method stub
return null;
}
to the following:
public Collection<Condition> getConditions() {
return CONTINUE_CONDITION;
}
This method defines the possible valid exit conditions for this task. In this case, we just want the environment to continue with the next task after executing this task, hence the
CONTINUE_CONDITION specification. Other tasks may allow for branching conditions, or other exit conditions, and may define a different collection of exit conditions.
private static final long serialVersionUID = 1;
private static final int dataVersion = 1;
private void writeObject(ObjectOutputStream out) throws IOException {
out.writeInt(dataVersion);
}
private void readObject(java.io.ObjectInputStream in) throws IOException,
ClassNotFoundException {
int objDataVersion = in.readInt();
if (objDataVersion == 1) {
//all is well :-)
} else {
throw new IOException("Can't handle dataversion: " + objDataVersion);
}
}
Although this task is very simple, other tasks may have more complicated data structures which are set at design time using standard JavaBean editing conventions. By implementing the serialization methods,
and by explicitely defining the serialVersionUID and dataVersion, we are providing a foundation for supporting task evolution over time.
public Condition evaluate(I_EncodeBusinessProcess process, I_Work worker)
throws TaskFailedException {
// TODO Auto-generated method stub
return null;
}
to the following:
public Condition evaluate(I_EncodeBusinessProcess process, I_Work worker)
throws TaskFailedException {
JOptionPane.showMessageDialog(new JFrame(), "Hello World!");
return Condition.CONTINUE;
}
The task is now fully functional. To use the task from within the Process Builder,
(see the Clinic Demonstration for an introduction to runing the bundled environment,
and the Process Builder), we must create a BeanInfo class for this task.
java.beans.SimpleBeanInfo. Within eclipse, select the
org.dwfa.bpa.tasks.dialog package. Right click on this package, and select New > Class.
Name the new class HelloWorldDialogBeanInfo, and set the Superclass to be
java.beans.SimpleBeanInfo. Now commit this dialog, and create the class.
public BeanDescriptor getBeanDescriptor() {
BeanDescriptor bd = new BeanDescriptor(HelloWorldDialog.class);
bd.setDisplayName("<html><font color='green'><center>Hello World");
return bd;
}
Now that the Task has a BeanInfo class to describe it, it can be made available to the process builder by writing the the task bean to disk. This step is managed by adding an entry to the Maven pom.xml file.
org.dwfa.bpa.tasks.dialog.ShowInfoDialog
(you can use eclipse to search the file to find this entry):
<beanSpec>
<sourceName>org.dwfa.bpa.tasks.dialog.HelloWorldDialog</sourceName>
<dirName>dialog</dirName>
</beanSpec>