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 155 156 157 158 159 160 161 162 163
|
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<!-- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd" -->
<!-- ************ SERVICE *********** -->
<!-- La Transaction -->
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:advice id="serviceTxAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="serviceMethods" expression="execution(* service.nasch.*.*(..))" />
<aop:advisor advice-ref="serviceTxAdvice" pointcut-ref="serviceMethods" />
</aop:config>
<!-- Configuration de proxy spécifiques, héritant du proxy général, devant chaque bean potentiellement transactionnel -->
<!-- ***********************
** Beans Service **
************************ -->
<bean id="ServiceContinentGeonamesTarget" class="service.nasch.ville.ServiceContinentGeonames">
<property name="continentDao" ref="continentDao"/>
</bean>
<bean id="ServiceContinentGeonames" parent="transactionProxy">
<property name="target">
<ref bean="ServiceContinentGeonamesTarget"/>
</property>
<property name="transactionAttributeSource">
<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
</property>
</bean>
<!-- ************ MODELE ************** -->
<!-- ***************************
** TransactionManager **
***************************** -->
<!-- Gestions des Transactions BDD -->
<!-- Définition du proxy général abstrait de manière globale à lapplication -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<!-- ****************************
** TransactionProxy **
***************************** -->
<bean id="transactionProxy" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED, readOnly</prop>
</props>
</property>
</bean>
<!-- ***********************
** BDD DataSource **
************************ -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/madb</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>mdp</value>
</property>
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceUnitName" value="jpaVille"/>
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
</bean>
</property>
</bean>
<!-- ***********************
** JBDC Exception **
************************ -->
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator ">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
<!-- ***********************
** Beans DAO **
************************ -->
<!-- General -->
<bean id="continentDao" class="dao.nasch.ville.impl.ContinentGeonamesHome">
<property name="entityManagerFactory">
<ref bean="entityManagerFactory"/>
</property>
</bean>
<!-- *********** BEAN FOR TEST *************** -->
<bean id="welcomeServiceBean" class="com.nasch.welcomeService.WelcomeService"/>
<!-- *********** CLASS ************ -->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
<!-- ************* PACKAGE ******************* -->
<!-- tell spring to use annotation based congfigurations -->
<context:annotation-config/>
<!-- tell spring where to find the beans -->
<context:component-scan base-package="dao.nasch.ville.impl" />
<tx:annotation-driven/>
<tx:jta-transaction-manager/>
</beans> |
Partager