IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Developing client applications for BPEL processes and tasks > Developing EJB client applications > Developing applications for human tasks

Create task templates and task instances at run time

You normally use a modeling tool, such as IBM Integration Designer to build task templates. You then install the task templates in IBM BPM and create instances from these templates, for example, using Business Process Choreographer Explorer. However, you can also create human or participating task instances or templates at run time.

You might want to do this, for example, when the task definition is not available when the application is deployed, the tasks that are part of a workflow are not yet known, or you need a task to cover some ad hoc collaboration between a group of people.

You can model ad hoc To-do or Collaboration tasks by creating instances of the com.ibm.task.api.TaskModel class, and using them to either create a reusable task template, or directly create a run-once task instance. To create an instance of the TaskModel class, a set of factory methods is available in the com.ibm.task.api.ClientTaskFactory factory class. Modeling human tasks at run time is based on the Eclipse Modeling Framework (EMF).


Procedure

  1. Create an org.eclipse.emf.ecore.resource.ResourceSet using the createResourceSet factory method.

  2. If you intend to use complex message types, you can either define them using the org.eclipse.xsd.XSDFactory that you can get using the factory method getXSDFactory(), or directly import an existing XML schema using the loadXSDSchema factory method .

    To make the complex types available to the Process Server, deploy them as part of an enterprise application.

  3. Create or import a Web Services Definition Language (WSDL) definition of the type javax.wsdl.Definition.

    You can create a new WSDL definition using the createWSDLDefinition method. Then you can add it a port type and operation. You can also directly import an existing WSDL definition using the loadWSDLDefinition factory method.

  4. Create the task definition using the createTTask factory method.

    If you want to add or manipulate more complex task elements, you can use the com.ibm.wbit.tel.TaskFactory class that you can retrieve using the getTaskFactory factory method .

  5. Create the task model using the createTaskModel factory method, and pass it the resource bundle created in the step 1 and which aggregates all other artifacts you created in the meantime.

  6. Optional: Validate the model using the TaskModel validate method.


Results

Use one of the Human Task Manager EJB API create methods that have a TaskModel parameter to either create a reusable task template, or a run-once task instance.

Developing applications for human tasks