11-27-2010 12:20 AM
public class UserBean {
/** injected by Spring */
private RuntimeService runtimeService;
@Transactional
public void hello() {
// here you can do transactional stuff in your domain model
// and it will be combined in the same transaction as
// the startProcessInstanceByKey to the Activiti RuntimeService
runtimeService.startProcessInstanceByKey("helloProcess");
}
public void setRuntimeService(RuntimeService runtimeService) {
this.runtimeService = runtimeService;
}
}
public class ManagedTransactionFactory implements TransactionFactory {
private boolean closeConnection = true;
public void setProperties(Properties props) {
if (props != null) {
String closeConnectionProperty = props.getProperty("closeConnection");
if (closeConnectionProperty != null) {
closeConnection = Boolean.valueOf(closeConnectionProperty);
}
}
}
public Transaction newTransaction(Connection conn, boolean autoCommit) {
// Silently ignores autocommit, as managed transactions are entirely
// controlled by an external manager. It's silently ignored so that
// code remains portable between managed and unmanaged configurations.
return new ManagedTransaction(conn, closeConnection);
}
}
DbSqlSessionFactory:
public void configurationCompleted(ProcessEngineConfiguration processEngineConfiguration) {
this.databaseType = processEngineConfiguration.getDatabaseType();
this.idGenerator = processEngineConfiguration.getIdGenerator();
this.statementMappings = databaseSpecificStatements.get(processEngineConfiguration.getDatabaseType());
DataSource dataSource = processEngineConfiguration.getDataSource();
if (dataSource==null) { // standalone usage
dataSource = createPooledDatasource(processEngineConfiguration);
}
TransactionFactory transactionFactory = null;
if (processEngineConfiguration.isTransactionsExternallyManaged()) {
transactionFactory = new ManagedTransactionFactory();
} else {
transactionFactory = new JdbcTransactionFactory();
}
this.sqlSessionFactory = createSessionFactory(dataSource, transactionFactory);
}
11-29-2010 05:12 AM
11-29-2010 08:00 AM
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" >
<property name="driverClassName">
<value>${database.driver_class}</value>
</property>
<property name="url">
<value>${database.url}</value>
</property>
<property name="username">
<value>${database.username}</value>
</property>
<property name="password">
<value>${database.password}</value>
</property>
<property name="defaultAutoCommit">
<value>false</value>
</property>
<property name="maxActive">
<value>${database.maxActive}</value>
</property>
<!–
<property name="validationQuery">
<value>select * from Test</value>
</property>–>
</bean>
11-30-2010 11:48 AM
12-02-2010 04:38 AM
12-03-2010 08:17 PM
09-01-2015 10:25 PM
09-08-2015 05:59 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.