01-31-2015 08:55 AM
<bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/activiti" />
<property name="username" value="root" />
<property name="password" value="password" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="processEngineConfiguration"
class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="false" />
<property name="deploymentResources" value="classpath*:/demoprocess.bpmn20.xml" />
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
@Service
public class BOProcess {
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Autowired
private DAOMyTab daoMyTab;
protected final static Logger logger = Logger.getLogger(BOProcess.class);
@Transactional
public void start(){
logger.info("Entering start method….");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("activitiDemo");
logger.info("Started Process instance id: " + pi.getProcessInstanceId());
daoMyTab.insert("PROCESS INSTANCE ID STARTED: " + pi.getProcessInstanceId());
logger.info("Finish");
}
@Transactional
public void completeTask(String taskId){
logger.info("Entering completeTask method….");
logger.info("TASK ID: " + taskId);
taskService.complete(taskId);
daoMyTab.insert(taskId);
logger.info("Finish");
}
}
@Repository
public class DAOMyTab {
@Autowired
private DataSource dataSource;
public void insert(String value){
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String query = "insert into activiti.mytab(valore) values('" + value + "')";
jdbcTemplate.update(query);
}
public void insertError(String value) throws Exception{
throw new Exception("ERRORE");
}
}
02-10-2015 07:50 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.