SPRING + HIBERNATE +OSWORKFLOW 的配置文件(1)
这是我实际项目经验中配置,还有一个applicationContext-hibernate.xml,和hibernate.cfg.xml下遍文档发
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- hibernate configuration -->
<import resource="applicationContext-hibernate.xml" />
<!-- ======================== dao helper ,set to service,transation ============ -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- ======================== end dao setup ============ -->
<!-- ============================================================================ -->
<!-- ======================== 系统业务层 ======================================= -->
<!-- ============================================================================ -->
<!-- ======================== begin to setup dgsei System Service ============ -->
<!-- ************ 公共transactionManager proxy 继承后就能有事务管理 方法是set parent="baseServiceProxy" === -->
<bean id="baseServiceProxy" lazy-init="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="modify*">
PROPAGATION_REQUIRED,-com.newsoft.notMoneyException
</prop>
<prop key="update*">
PROPAGATION_REQUIRED,-Exception
</prop>
<prop key="add*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="create*">
PROPAGATION_REQUIRED,-Exception
</prop>
<prop key="save*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="delete*">
PROPAGATION_REQUIRED,-Exception
</prop>
<prop key="remove*">
PROPAGATION_REQUIRED,-Exception
</prop>
<prop key="do*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="is*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<!-- prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="someOtherBusinessMethod">PROPAGATION_MANDATORY</prop-->
</props>
</property>
</bean>
<!-- ============= end ==== -->
<!--
OS
-->
<bean id="workflowStore"
class="com.opensymphony.workflow.spi.hibernate3.SpringHibernateWorkflowStore" >
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
<property name="propertySetDelegate">
<bean id="propertySetDelegate"
class="com.opensymphony.workflow.util.PropertySetDelegateImpl" />
</property>
</bean>
<bean id="workflowFactory"
class="com.opensymphony.workflow.spi.hibernate.SpringWorkflowFactory"
init-method="init">
<property name="resource">
<value>workflows.xml</value>
</property>
</bean>
<bean id="workflowConfiguration"
class="com.opensymphony.workflow.config.SpringConfiguration">
<property name="store">
<ref local="workflowStore" />
</property>
<property name="factory">
<ref local="workflowFactory" />
</property>
</bean>
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref local="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="workflowTarget" class="com.opensymphony.workflow.basic.BasicWorkflow" singleton="false">
<constructor-arg>
<value>admin</value>
</constructor-arg>
<property name="configuration">
<ref local="workflowConfiguration" />
</property>
</bean>
<bean id="workflow" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="singleton">
<value>false</value>
</property>
<property name="proxyInterfaces">
<value>com.opensymphony.workflow.Workflow</value>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
<value>workflowTarget</value>
</list>
</property>
</bean>
<!-- OS END -->
<!-- 监管中心创建记录 -->
<!-- dao的实现 sessionFactory用的是前面Spring定义的-->
<bean id="maintRecordDao"
class="com.newsoft.equipmentMaintenance.dao.MaintRecordDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- BO的接口 target 是指向BO实现类id parent是事物代理类的ID ,proxyInterfaces是被代理的接口类-->
<bean id="maintRecordService" parent="baseServiceProxy">
<property name="target">
<ref local="maintRecordImpl" />
</property>
<property name="proxyInterfaces">
<value>
com.newsoft.equipmentMaintenance.bo.maintenanceRecord.MaintRecordService
</value>
</property>
</bean>
<!-- BO的实现 MaintRecordDao 是指向DAO接口类id-->
<bean id="maintRecordImpl"
class="com.newsoft.equipmentMaintenance.bo.maintenanceRecord.impl.MaintRecordImpl">
<property name="maintRecordDao">
<ref local="maintRecordDao" />
</property>
<property name="workflow">
<ref local="workflow" />
</property>
</bean>
</beans>