05-29-2012 11:02 PM
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="Test processes">
<process id="test-process" name="Test process">
<extensionElements>
<activiti:executionListener event="end" class="foo.bar.ProcessEndArchiveListener"></activiti:executionListener>
</extensionElements>
<startEvent id="startevent1" name="Start" activiti:initiator="initiator"></startEvent>
<userTask id="usertask1" name="Enter information" activiti:assignee="${initiator}" activiti:formKey="enter.jsf"></userTask>
<sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
<userTask id="usertask2" name="Update information" activiti:assignee="${initiator}" activiti:formKey="update.jsf"></userTask>
<sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow3" name="" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
</process>
</definitions>
public class ProcessEndArchiveListener implements ExecutionListener {
public void notify(DelegateExecution execution) throws Exception {
DestructibleBeanInstance<ProcessArchiver> processArchiverBean = null;
try {
processArchiverBean = BeanLookup.getBean(ProcessArchiver.class);
ProcessArchiver processArchiver = processArchiverBean.getInstance();
processArchiver.archive(execution);
} finally {
if (processArchiverBean != null) {
processArchiverBean.destroy();
}
}
}
}
@ApplicationScoped
public class ProcessArchiver {
@Inject
protected ProcessEngine processEngine;
public void archive(DelegateExecution execution) {
HistoryService historyService = processEngine.getHistoryService();
// …
List<HistoricDetail> historicDetails = historyService.createHistoricDetailQuery()
.processInstanceId(execution.getProcessInstanceId()).variableUpdates().list();
List<HistoricVariableUpdate> historicVariableUpdates = new ArrayList<HistoricVariableUpdate>();
for (HistoricDetail historicDetail : historicDetails) {
if (historicDetail instanceof HistoricVariableUpdate) {
// historicDetail.getTaskId() is always null here
historicVariableUpdates.add((HistoricVariableUpdate) historicDetail);
}
}
// …
}
}
@Named
@BusinessProcessScoped
public class TestProcessBean implements Serializable {
private static final long serialVersionUID = 1L;
protected String title;
protected String comment;
// Getters & setters
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!– lookup the JTA-Transaction manager –>
<bean id="transactionManager" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:jboss/TransactionManager"></property>
<property name="resourceRef" value="true" />
</bean>
<!– process engine configuration –>
<bean id="processEngineConfiguration" class="org.activiti.cdi.CdiJtaProcessEngineConfiguration">
<property name="dataSourceJndiName" value="java:/DB/Activiti" />
<property name="databaseType" value="mysql" />
<property name="transactionManager" ref="transactionManager" />
<property name="transactionsExternallyManaged" value="true" />
<property name="databaseSchemaUpdate" value="true" />
<property name="history" value="full" />
<property name="customPostBPMNParseListeners">
<list>
<bean class="org.activiti.cdi.impl.event.CdiEventSupportBpmnParseListener" />
</list>
</property>
</bean>
</beans>
06-01-2012 05:11 AM
06-12-2012 01:09 AM
06-12-2012 10:09 AM
06-12-2012 02:40 PM
06-13-2012 03:02 AM
06-13-2012 05:03 AM
06-15-2012 03:58 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.