08-02-2012 03:43 AM
08-02-2012 07:57 AM
08-02-2012 05:09 PM
08-08-2012 06:02 AM
08-14-2012 01:40 AM
08-14-2012 11:08 AM
08-23-2012 07:27 AM
<!– DataSource Definition –>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/activiti"/>
<property name="username" value="root" />
<property name="password" value="root" />
<property name="poolPreparedStatements" value="true" />
<property name="maxActive" value="50" />
<property name="maxIdle" value="10" />
</bean>
<!– Session Factory Definition –>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
…
</bean>
<!– Hibernate Transaction Manager Definition –>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
<property name="dataSource">
<ref local="dataSource" />
</property>
</bean>
<!– Process Engine Definition –>
<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" />
</bean>
protected TransactionStatus startTransaction() {
PlatformTransactionManager manager = getTransactionManager();
DefaultTransactionDefinition d = new DefaultTransactionDefinition();
d.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW);
transaction = manager.getTransaction(d);
return transaction;
}
protected void commit(TransactionStatus transaction) {
PlatformTransactionManager manager = getTransactionManager();
manager.commit(transaction);
}
protected void rollback(TransactionStatus transaction) {
PlatformTransactionManager manager = getTransactionManager();
manager.rollback(transaction);
}
private PlatformTransactionManager getTransactionManager() {
return (PlatformTransactionManager) this.appContext
.getBean("transactionManager");
}
09-04-2012 08:15 AM
09-07-2012 06:36 AM
public class MyBean() extends BaseAction{
private MyObject pojo;
private MyService service;
private RuntimeService runtimeService;
…
public void doSomeStuff() {
pojo.setText("demo");
pojo.setValue(42);
save(); // Or just call the save from your GUI for example
}
public void save() {
try {
service.save(pojo);
runtimeService.setVariable(pInst.getId(), "pojoid", pojo.getId());
commit();
}
catch(Exception e) {
onError(e);
}
}
public void onError(Exception e) {
// do some stuff
rollback();
}
…
}
09-10-2012 10:31 AM
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${database.driver}" />
<property name="jdbcUrl" value="${database.url}" />
<property name="user" value="${database.username}" />
<property name="password" value="${database.password}" />
<property name="initialPoolSize" value="3" />
<property name="minPoolSize" value="1" />
<property name="maxPoolSize" value="17" />
</bean>
…
<tx:annotation-driven transaction-manager="transactionManager" mode="aspectj"/>
…
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="dataSource" ref="dataSource" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
…
<bean
class="org.springframework.transaction.aspectj.AnnotationTransactionAspect"
factory-method="aspectOf">
<property name="transactionManager">
<ref local="transactionManager" />
</property>
</bean>
…
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="databaseType" value="postgres" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
…
@Override
@Transactional
public ProcessInstance startWorkflowProcess(String processDefinitionId, Map<String, Object> variables, String currentUser){
log.debug("Starting new process with the id: "+processDefinitionId+" and the variables are :"+variables);
identityService.setAuthenticatedUserId(currentUser);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinitionId, variables);
identityService.setAuthenticatedUserId(null);
return processInstance;
}
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
public class JPASessionFactory {
@Autowired
private SessionFactory sessionFactory;
public Session getCurrentSession() {
return sessionFactory.getCurrentSession();
}
public SessionFactory getSessionFactory() {
return sessionFactory;
}
}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.