09-19-2012 11:10 AM
09-20-2012 05:15 AM
09-20-2012 11:53 AM
<tx:annotation-driven transaction-manager="transactionManager" mode="aspectj"/>
<task:annotation-driven/>
<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>
…
<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" />
<property name="history" value="full" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="true" />
…
Is something wrong in my configuration?09-21-2012 04:47 AM
09-21-2012 07:59 AM
public class TestServiceTask implements JavaDelegate{
private VersionDAO versionDAO;
public TestServiceTask(){
versionDAO = new BeanAccessor().getBean(VersionDAO.class);
}
public void execute(DelegateExecution execution) throws Exception {
Version version = versionDAO.loadDistributionVersion("Test");
}
}
My DAO:@Transactional
public Version loadDistributionVersion(String productName) {
return (Version) getCurrentSession().createQuery("" +
"from Version as v " +
"where v.product.name = roductName " +
"and v.product.distributionVersion.id = v.id")
.setParameter("productName", productName)
.uniqueResult();
}
And my getCurrentSession() which is in GenericDAO:public GenericDAO{
@Autowired
private SessionFactory sessionFactory;
…
protected Session getSession() {
return sessionFactory.getCurrentSession();
}
}
I can't use the @Autowired within ServiceTask, so I use the class BeanAccessor:@Configurable
public class BeanAccessor {
@Autowired
private WebApplicationContext context;
public <T> T getBean(Class<T> beanClass) {
return context.getBean(beanClass);
}
public <T> Map<String, T> getBeansOfType(Class<T> beanClass) {
return context.getBeansOfType(beanClass);
}
}
09-24-2012 05:03 AM
10-15-2012 08:47 AM
10-16-2012 05:35 AM
10-16-2012 09:51 AM
10-16-2012 09:52 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.