Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 20th, 2012  |  syntax: None  |  size: 5.66 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xmlns:aop="http://www.springframework.org/schema/aop"
  5.        xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
  6.        xmlns:osgi="http://www.springframework.org/schema/osgi"      
  7.        xmlns:tx="http://www.springframework.org/schema/tx"
  8.        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  9.                            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
  10.                            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
  11.                            http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
  12.                            http://servicemix.apache.org/cxfse/1.0 http://servicemix.apache.org/cxfse/1.0/servicemix-cxf-se.xsd">
  13.  
  14.   <cxfse:endpoint>
  15.     <cxfse:pojo>
  16.       <bean class="org.apache.servicemix.samples.wsdl_first.PersonImpl"/>
  17.     </cxfse:pojo>
  18.   </cxfse:endpoint>
  19.  
  20.   <bean class="org.apache.servicemix.common.osgi.EndpointExporter" />
  21.  
  22.   <!-- much of this was adapted from http://erich.soomsam.net/2007/04/24/spring-jpa-and-jta-with-hibernate-and-jotm/ -->
  23.   <osgi:reference id="geronimoTransactionManager" interface="javax.transaction.TransactionManager"/>
  24.  
  25.   <!-- Configure the Spring framework to use JTA transactions from Geronimo -->
  26.   <bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
  27.     <property name="transactionManager" ref="geronimoTransactionManager" />
  28.   </bean>
  29.  
  30.   <!--   enables interpretation of the @Required annotation to ensure that dependency injection actually occurs -->
  31.   <bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor" />
  32.  
  33.   <!--   enables interpretation of the @PersistenceUnit/@PersistenceContext annotations providing convenient access to EntityManagerFactory/EntityManager -->
  34.   <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
  35.  
  36.   <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  37.     <property name="persistenceUnitName" value="smx4" />
  38.     <property name="jpaVendorAdapter" ref="jpaAdapter" />
  39.     <property name="persistenceUnitManager" ref="persistenceUnitManager"/>
  40.  
  41.     <property name="jpaPropertyMap">
  42.       <map>
  43.         <entry key="hibernate.transaction.manager_lookup_class" value="org.apache.servicemix.samples.wsdl_first.OsgiTransactionManagerLookup" />
  44.         <entry key="hibernate.transaction.factory_class" value="org.apache.servicemix.samples.wsdl_first.OsgiJTATransactionFactory"/>
  45.         <entry key="hibernate.transaction.flush_before_completion" value="true" />
  46.         <entry key="hibernate.transaction.auto_close_session" value="true" />
  47.         <entry key="hibernate.current_session_context_class" value="jta" />
  48.         <entry key="hibernate.connection.release_mode" value="auto" />
  49.       </map>
  50.     </property>
  51.   </bean>
  52.  
  53.   <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
  54.     <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
  55.     <property name="showSql" value="true" />
  56.   </bean>
  57.  
  58.   <!-- get around error as shown in http://forum.springsource.org/showthread.php?t=61273 -->
  59.   <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
  60.     <property name="dataSources">
  61.       <map>
  62.         <entry key="jdbc/mainDataSource" value-ref="dataSource" />
  63.       </map>
  64.     </property>
  65.         <!-- custom implementation to enrich the PersistenceUnitInfo read from the persistence.xml JPA configuration file with the JTA datasource. specifying the JTA datasource directly
  66.       in the Spring configuration file has the advantage that we can use a direct reference to the datasource instead of using a JNDI name as requied by the jta-data-source setting in the
  67.       persistence.xml file -->
  68.     <property name="persistenceUnitPostProcessors">
  69.       <bean class="org.apache.servicemix.samples.wsdl_first.JtaPersistenceUnitPostProcessor">
  70.         <property name="jtaDataSource" ref="dataSource" />
  71.       </bean>
  72.     </property>  
  73.   </bean>
  74.  
  75.   <!-- bean id="dataSource" class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
  76.     <property name="driverName" value="org.hsqldb.jdbcDriver" />
  77.     <property name="url" value="jdbc:hsqldb:mem:smx4_jpa" />
  78.     <property name="user" value="sa" />
  79.     <property name="password" value="" />
  80.     <property name="transactionManager" ref="geronimoTransactionManager" />
  81.   </bean -->
  82.  
  83.    
  84.   <bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
  85.     <property name="dataSource">
  86.        <bean class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
  87.           <property name="transactionManager" ref="geronimoTransactionManager" />
  88.           <property name="driverName" value="com.mysql.jdbc.Driver" />
  89.           <property name="url" value="jdbc:mysql://localhost/PersonDB?relaxAutoCommit=true" />
  90.        </bean>
  91.     </property>
  92.         <property name="user" value="xxxxx"/>
  93.         <property name="password" value="xxxx"/>
  94. </bean>
  95.  
  96.  
  97.  
  98.  
  99.   <!-- enables interpretation of the @Transactional annotation for declarative transaction management using the specified JtaTransactionManager -->
  100.   <tx:annotation-driven transaction-manager="jtaTransactionManager" proxy-target-class="false" />