ssh+jpbm事务整合(转)

前段时间用jbpm做了个项目,花了很多时间来处理和spring的事务整合,找了很多资料都不是很全,贴段代码,希望对大家有帮助。
jbpm.cfg.xml文件这个地方改一下,关掉jbpm事务:
Xml代码
<service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory">
<factory>
<bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
<field name="isTransactionEnabled"><false/></field>
<field name="isCurrentSessionEnabled"><true/></field>
</bean>
</factory>
</service>


spring配置文件:
Xml代码
<bean id="jbpmConfiguration" class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
<property name="sessionFactory" ref="sessionFactory" />
<property name="configuration" value="classpath:jbpm.cfg.xml" />
</bean>
<bean id="jbpmTemplate" class="org.springmodules.workflow.jbpm31.JbpmTemplate">
<constructor-arg index="0" ref="jbpmConfiguration" />
</bean>
<bean id="applyDao" parent="txProxyTemplate">
<property name="target">
<bean class="com.hljt.daos.impl.ApplyDaoImpl">
<property name="jbpmTemplate">
<ref bean="jbpmTemplate" />
</property>
</bean>
</property>
</bean>

由于springmodules里面封装的方法很少,很多方法需要接口回调(估计是叫这个我对这些名词不太了解),举个例子:
Java代码
private JbpmTemplate jbpmTemplate;
public void save(final TbApply apply,TbUser user) {
this.jbpmTemplate.execute(new JbpmCallback(){
public Object doInJbpm(JbpmContext context)throws JbpmException {
ProcessDefinition pd = context.getGraphSession().findLatestProcessDefinition("apply");
ProcessInstance pi = pd.createProcessInstance();
pi.getContextInstance().setVariable("issueUser",
apply.getTbuser().getName());
TaskInstance ti = pi.getTaskMgmtInstance().createStartTaskInstance();
ti.setActorId(apply.getTbuser().getName());
ti.setVariable("applyId", apply.getId());
ti.end();
context.save(pi);
return null;
}
});
}


原帖地址:http://jbpm.group.iteye.com/group/topic/7091
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值