AnsweredAssumed Answered

Programmatic process definition and deployment (without xml)

Question asked by hieu.ho on Aug 1, 2011
Latest reply on Mar 2, 2012 by heymjo
Hi everyone

I'm new to Activiti and wanted to see if it will work for a project we're migrating.

I couldn't find a good example of creating a processDefinition and deploying it programatically.  I took point from ProcessDefinitionsTest, and a few others, but they seem to be deploying a process by reading from an existing xml resource or from a process string. (ie. DeploymentBuilder.addClasspathResource and addString)

I have a requirement where I am reading from external sources (ie. lists from db and flat files).  I want to avoid having to preprocess and convert them all to bpmn xml files.  I have List objects created from them, and would like to see if I can create a process definition from it, using something similar to the following

ProcessDefinitionBuilder processDefinitionBuilder = new ProcessDefinitionBuilder(someName);

processDefinitionBuilder = processDefinitionBuilder.createActivity(top.getName())
                                                               .behavior(new BaseServiceTaskHandler("start node"))

for (int i = 0; i < myChecklist.size(); i++) {
                    if(i<myChecklist.size() - 1) {
                        processDefinitionBuilder = processDefinitionBuilder.createActivity(myChecklist.get(i).getName())
                                                             .behavior(new ReminderActivityHandler())
                                                             .transition(myChecklist.get(i + 1).getName())
                    } else {
                        processDefinitionBuilder = processDefinitionBuilder.createActivity(top.getRoutine().get(i).getName())

PvmProcessDefinition processDefinition = processDefinitionBuilder.buildProcessDefinition();

How do I deploy this now?  Would this be the best way to do this?  Is there an example you can point me to?