SPRING + HIBERNATE +OSWORKFLOW 的配置文件(1)
?這是我實際項目經驗中配置,還有一個applicationContext-hibernate.xml,和hibernate.cfg.xml下遍文檔發
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "<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>
?