方法一(流程部署至服务器上之后可使用):
BpmnModel model = repositoryService.getBpmnModel(processDefinitionId);
if(model != null) {
Collection<FlowElement> flowElements = model.getMainProcess().getFlowElements();
for(FlowElement e : flowElements) {
System.out.println("flowelement id:" + e.getId() + " name:" + e.getName() + " class:" + e.getClass().toString());
}
}
方法二 读取流程定义文件方式
InputStream resouceStream = this.getClass().getClassLoader().getResourceAsStream("leave-formkey.bpmn20.xml");
XMLInputFactory xif = XMLInputFactory.newInstance();
InputStreamReader in;
XMLStreamReader xtr;
try {
in = new InputStreamReader(resouceStream, "UTF-8");
xtr = xif.createXMLStreamReader(in);
BpmnModel model = new BpmnXMLConverter().convertToBpmnModel(xtr);
Collection<FlowElement> flowElements = model.getMainProcess().getFlowElements();
for(FlowElement e : flowElements) {
System.out.println("flowelement id:" + e.getId() + " name:" + e.getName() + " class:" + e.getClass().toString());
}
} catch (XMLStreamException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
http://blog.csdn.net/hiyohu/article/details/51682005