1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<!--
****************************************************************************
Spring configuration file for :
-> The datasource
-> The ORM (JPA)
-> The transactions
****************************************************************************
-->
<!-- ========================= DATASOURCE ========================= -->
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean"
p:jndiName="jdbc/PweDS" />
<!-- ========================= ORM : JPA ========================= -->
<!--
Activates a load-time weaver for the context. Any bean within the context that
implements LoadTimeWeaverAware (such as LocalContainerEntityManagerFactoryBean)
will receive a reference to the autodetected load-time weaver.
-->
<context:load-time-weaver />
<bean id="loadTimeWeaver"
class="org.springframework.instrument.classloading.oc4j.OC4JLoadTimeWeaver" />
<!-- JPA PersistenceUnitManager used to customize the selection of the persistence unit and the datasources -->
<bean id="persistenceUnitManager"
class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<!-- Multiple value can be specified here -->
<property name="persistenceXmlLocations">
<list>
<value>classpath*:META-INF/persistence.xml</value>
</list>
</property>
<property name="dataSources">
<map>
<entry key="localDataSource" value-ref="dataSource" />
<!--<entry key="remoteDataSource" value-ref="remote-db" />-->
</map>
</property>
<!-- if no datasource is specified, use this one -->
<property name="defaultDataSource" ref="dataSource" />
<property name="loadTimeWeaver" ref="loadTimeWeaver" />
</bean>
<!-- JPA EntityManagerFactory -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource"
p:persistenceUnitManager-ref="persistenceUnitManager">
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter"
p:databasePlatform="oracle.toplink.essentials.platform.database.oracle.OraclePlatform">
<property name="showSql" value="${pwe.log.showsql}" />
</bean>
</property>
<property name="jpaDialect">
<bean
class="org.springframework.orm.jpa.vendor.TopLinkJpaDialect" />
</property>
</bean>
<!-- JTA Transaction Manager -->
<tx:jta-transaction-manager />
<context:annotation-config />
<bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<!-- ================================== TRANSACTIONS ================================== -->
<!-- For the moment JPA only support ISOLATION_DEFAULT for the transaction isolation -->
<!-- Note :
The Transport layer do not intialize transactions in order to enhance the transport layer modularity from HTTP to JMS
-->
<!-- Define pointcut for txAdvices -->
<aop:config>
<!-- DAO Layer -->
<aop:advisor advice-ref="txAdviceDao"
pointcut="execution(* eu.curia.pwe.dao.impl.*.*(..))" />
<!-- Service Layer -->
<aop:advisor advice-ref="txAdviceService"
pointcut="execution(* eu.curia.pwe.service..*.*(..))" />
</aop:config>
<!-- the transactional advice for DAO layer -->
<tx:advice id="txAdviceDao" transaction-manager="transactionManager">
<!-- the transactional semantics... -->
<tx:attributes>
<!-- Read methods don''t use a transaction but supports an existing transaction -->
<tx:method name="read*" propagation="SUPPORTS"
read-only="false" />
<!-- Exclude Getter/Setter but supports an existing transaction -->
<tx:method name="set*" propagation="SUPPORTS"
read-only="false" />
<tx:method name="get*" propagation="SUPPORTS"
read-only="false" />
<!-- All others methods must use a existing transaction -->
<tx:method name="*" isolation="DEFAULT"
propagation="MANDATORY" read-only="false"
rollback-for="org.springframework.dao.DataAccessException eu.curia.pwe.error.PWEException" />
</tx:attributes>
</tx:advice>
<!-- the transactional advice for Service layer
-->
<tx:advice id="txAdviceService" transaction-manager="transactionManager">
<!-- the transactional semantics... -->
<tx:attributes>
<!-- Read methods don''t use a transaction but supports an existing transaction -->
<tx:method name="read*" propagation="SUPPORTS"
read-only="false" />
<!-- Exclude Getter/Setter but supports an existing transaction -->
<tx:method name="set*" propagation="SUPPORTS"
read-only="false" />
<tx:method name="get*" propagation="SUPPORTS"
read-only="false" />
<!-- Update method create new transaction -->
<tx:method name="update*" propagation="REQUIRES_NEW"
read-only="false" />
<!-- All others methods create a new transaction only if no transaction exists -->
<tx:method name="*" isolation="DEFAULT"
propagation="REQUIRED" read-only="false"
rollback-for="org.springframework.dao.DataAccessException eu.curia.pwe.error.PWEException" />
</tx:attributes>
</tx:advice>
</beans> |
Partager