The camunda BPMN model API is a simple, lightweight Java library for parsing, creating and editing BPMN 2.0 XML files. It is licensed under the Apache 2.0 license.
Note
|
camunda BPMN model can be used standalone, independenly of camunda BPM platform / process engine. |
-
Web Site: http://www.camunda.org/
-
User Guide: http://docs.camunda.org
-
Issue Tracker: https://app.camunda.com/jira/
-
Contribution Guidelines: http://www.camunda.org/community/contribute.html
-
License: Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
To easily create simple BPMN 2.0 processes we provide the fluent builder API. It supports most BPMN 2.0 elements and allows you to set attributes and add some child elements. The following process is deployable and can be executed by the camunda BPM platform.
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("processId")
.startEvent()
.userTask()
.endEvent()
.done();
For more complex examples see the docs, the tests in ProcessBuilderTest.java or this example.
You can easily create a new empty BPMN model.
BpmnModelInstance modelInstance = Bpmn.createEmptyModel();
Definitions definitions = modelInstance.newInstance(Definitions.class);
definitions.setTargetNamespace("http://camunda.org/examples");
modelInstance.setDefinitions(definitions);
At any time you can validate your model against the BPMN 2.0 specification.
BpmnModelInstance modelInstance = [...]
Bpmn.validateModel(modelInstance);
The fluent API is usually a good choice for creating a new BPMN process. However, not all elements supported by the model are exposed through fluent builders and the fluent api may not be the appropriate API style for all usecases. In such cases, the full API can be used for creating a process model. The following code creates a simple Process as a jUnit4 test using the full API: CreateModelTest.java.
// find element instance by ID
ModelElementInstance elementInstance = modelInstance.getModelElementById("start");
// find all elements of the type task
ModelElementType taskType = modelInstance.getModel().getType(Task.class);
Collection<ModelElementInstance> elementInstances = modelInstance.getModelElementsByType(taskType);
The model API allows you to save your model in several ways
// create BPMN model
BpmnModelInstance modelInstance = [...]
// convert to string
String xmlString = Bpmn.convertToString(modelInstance);
// write to output stream
OutputStream outputStream = new OutputStream(...);
Bpmn.writeModelToStream(outputStream, modelInstance);
// write to file
File file = new File(...);
Bpmn.writeModelToFile(file, modelInstance);
Read the BPMN 2.0 Tutorial on camunda.org.
Java JRE 1.6+ is required. We test camunda BPMN model API on Oracle and IBM JVMs.
No, but support is already quite extensive. See org.camunda.bpm.model.bpmn.instance for a list of currently supported elements.