← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1869: Replaced HibernateConfigurationProvider definition with annotations

 

------------------------------------------------------------
revno: 1869
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Mon 2010-05-17 23:31:03 +0200
message:
  Replaced HibernateConfigurationProvider definition with annotations
modified:
  dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/ConnectionPropertyFactoryBean.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingDirectoryLocationsFactoryBean.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingJarLocationsFactoryBean.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernatePropertiesFactoryBean.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/configuration/JdbcConfigurationFactoryBean.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/HibernateDatabaseInfoProvider.java
  dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml	2010-05-17 21:11:03 +0000
+++ dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml	2010-05-17 21:31:03 +0000
@@ -13,9 +13,7 @@
 
   <context:component-scan base-package="org.hisp.dhis"/>
   
-  <bean id="locationManager"
-    class="org.hisp.dhis.external.location.DefaultLocationManager"
-    init-method="init">
+  <bean id="locationManager" class="org.hisp.dhis.external.location.DefaultLocationManager" init-method="init">
     <property name="environmentVariable" value="DHIS2_HOME"/> <!-- Change environment variable -->
     <property name="systemProperty" value="dhis2.home"/>
   </bean>

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/ConnectionPropertyFactoryBean.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/ConnectionPropertyFactoryBean.java	2010-05-10 17:50:39 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/ConnectionPropertyFactoryBean.java	2010-05-17 21:31:03 +0000
@@ -28,6 +28,7 @@
  */
 
 import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * @author Lars Helge Overland
@@ -40,12 +41,8 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    @Autowired
     private HibernateConfigurationProvider hibernateConfigurationProvider;
-
-    public void setHibernateConfigurationProvider( HibernateConfigurationProvider hibernateConfigurationProvider )
-    {
-        this.hibernateConfigurationProvider = hibernateConfigurationProvider;
-    }
     
     private String hibernateProperty;
 

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java	2010-05-17 21:05:26 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java	2010-05-17 21:31:03 +0000
@@ -37,6 +37,8 @@
 import java.util.List;
 import java.util.Properties;
 
+import javax.annotation.PostConstruct;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.cfg.Configuration;
@@ -46,11 +48,13 @@
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.FileSystemResource;
 import org.springframework.core.io.Resource;
+import org.springframework.stereotype.Component;
 import org.springframework.util.ResourceUtils;
 
 /**
  * @author Torgeir Lorange Ostby
  */
+@Component("hibernateConfigurationProvider")
 public class DefaultHibernateConfigurationProvider
     implements HibernateConfigurationProvider
 {
@@ -82,7 +86,8 @@
     // Initialise
     // -------------------------------------------------------------------------
 
-    public void initialise()
+    @PostConstruct
+    public void init()
         throws Exception
     {
         Configuration configuration = new Configuration();
@@ -227,5 +232,5 @@
         {
             inputStream.close();
         }
-    }    
+    }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingDirectoryLocationsFactoryBean.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingDirectoryLocationsFactoryBean.java	2010-05-10 17:50:39 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingDirectoryLocationsFactoryBean.java	2010-05-17 21:31:03 +0000
@@ -28,12 +28,15 @@
  */
 
 import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.Resource;
+import org.springframework.stereotype.Component;
 
 /**
  * @author Lars Helge Overland
  * @version $Id$
  */
+@Component("hibernateMappingDirectoryLocations")
 public class HibernateMappingDirectoryLocationsFactoryBean 
     implements FactoryBean<Object[]>
 {    
@@ -41,13 +44,9 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    @Autowired
     private HibernateConfigurationProvider hibernateConfigurationProvider;
 
-    public void setHibernateConfigurationProvider( HibernateConfigurationProvider hibernateConfigurationProvider )
-    {
-        this.hibernateConfigurationProvider = hibernateConfigurationProvider;
-    }
-
     // -------------------------------------------------------------------------
     // FactoryBean implementation
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingJarLocationsFactoryBean.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingJarLocationsFactoryBean.java	2010-05-10 17:50:39 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingJarLocationsFactoryBean.java	2010-05-17 21:31:03 +0000
@@ -28,12 +28,15 @@
  */
 
 import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.Resource;
+import org.springframework.stereotype.Component;
 
 /**
  * @author Lars Helge Overland
  * @version $Id$
  */
+@Component("hibernateMappingJarLocations")
 public class HibernateMappingJarLocationsFactoryBean
     implements FactoryBean<Object[]>
 {
@@ -41,13 +44,9 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    @Autowired
     private HibernateConfigurationProvider hibernateConfigurationProvider;
 
-    public void setHibernateConfigurationProvider( HibernateConfigurationProvider hibernateConfigurationProvider )
-    {
-        this.hibernateConfigurationProvider = hibernateConfigurationProvider;
-    }
-
     // -------------------------------------------------------------------------
     // FactoryBean implementation
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernatePropertiesFactoryBean.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernatePropertiesFactoryBean.java	2010-05-10 17:50:39 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernatePropertiesFactoryBean.java	2010-05-17 21:31:03 +0000
@@ -30,11 +30,14 @@
 import java.util.Properties;
 
 import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
 
 /**
  * @author Lars Helge Overland
  * @version $Id$
  */
+@Component("hibernateProperties")
 public class HibernatePropertiesFactoryBean
     implements FactoryBean<Properties>
 {
@@ -42,13 +45,9 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    @Autowired
     private HibernateConfigurationProvider hibernateConfigurationProvider;
 
-    public void setHibernateConfigurationProvider( HibernateConfigurationProvider hibernateConfigurationProvider )
-    {
-        this.hibernateConfigurationProvider = hibernateConfigurationProvider;
-    }
-
     // -------------------------------------------------------------------------
     // FactoryBean implementation
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml	2010-05-17 21:05:26 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml	2010-05-17 21:31:03 +0000
@@ -19,10 +19,6 @@
 
   <!-- Configuration -->
 
-  <bean id="org.hisp.dhis.hibernate.HibernateConfigurationProvider"
-    class="org.hisp.dhis.hibernate.DefaultHibernateConfigurationProvider"
-    init-method="initialise"/>
-
   <bean id="sessionFactory"
     class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
     <property name="dataSource" ref="dataSource"/>
@@ -42,49 +38,23 @@
     <property name="dataSource" ref="dataSource"/>
   </bean>
     
-  <bean id="hibernateProperties"
-    class="org.hisp.dhis.hibernate.HibernatePropertiesFactoryBean">
-    <property name="hibernateConfigurationProvider"
-      ref="org.hisp.dhis.hibernate.HibernateConfigurationProvider"/>
-  </bean>
-
-  <bean id="hibernateMappingDirectoryLocations"
-    class="org.hisp.dhis.hibernate.HibernateMappingDirectoryLocationsFactoryBean">
-    <property name="hibernateConfigurationProvider"
-      ref="org.hisp.dhis.hibernate.HibernateConfigurationProvider"/>
-  </bean>
-
-  <bean id="hibernateMappingJarLocations" 
-    class="org.hisp.dhis.hibernate.HibernateMappingJarLocationsFactoryBean">
-    <property name="hibernateConfigurationProvider"
-      ref="org.hisp.dhis.hibernate.HibernateConfigurationProvider"/>
-  </bean>
-
   <bean id="driverClassName"
     class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
-    <property name="hibernateConfigurationProvider"
-      ref="org.hisp.dhis.hibernate.HibernateConfigurationProvider"/>
     <property name="hibernateProperty" value="hibernate.connection.driver_class"/>
   </bean>
     
   <bean id="url"
     class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
-    <property name="hibernateConfigurationProvider"
-      ref="org.hisp.dhis.hibernate.HibernateConfigurationProvider"/>
     <property name="hibernateProperty" value="hibernate.connection.url"/>
   </bean>
     
   <bean id="username"
     class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
-    <property name="hibernateConfigurationProvider"
-      ref="org.hisp.dhis.hibernate.HibernateConfigurationProvider"/>
     <property name="hibernateProperty" value="hibernate.connection.username"/>
   </bean>
   
   <bean id="password"
     class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
-    <property name="hibernateConfigurationProvider"
-      ref="org.hisp.dhis.hibernate.HibernateConfigurationProvider"/>
     <property name="hibernateProperty" value="hibernate.connection.password"/>
   </bean>
   
@@ -93,7 +63,7 @@
   <bean id="org.hisp.dhis.cache.HibernateCacheManager" 
     class="org.hisp.dhis.cache.DefaultHibernateCacheManager">
     <property name="sessionFactory" ref="sessionFactory"/>
-  </bean>  
+  </bean>
       
   <!-- Dbms -->
   

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/configuration/JdbcConfigurationFactoryBean.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/configuration/JdbcConfigurationFactoryBean.java	2010-05-10 17:50:39 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/configuration/JdbcConfigurationFactoryBean.java	2010-05-17 21:31:03 +0000
@@ -32,6 +32,7 @@
 import org.hibernate.cfg.Configuration;
 import org.hisp.dhis.hibernate.HibernateConfigurationProvider;
 import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * @author Lars Helge Overland
@@ -57,13 +58,9 @@
     // Dependencies
     // -------------------------------------------------------------------------
     
+    @Autowired
     private HibernateConfigurationProvider configurationProvider;
     
-    public void setConfigurationProvider( HibernateConfigurationProvider configurationProvider )
-    {
-        this.configurationProvider = configurationProvider;
-    }
-    
     private JdbcConfiguration jdbcConfiguration;
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/resources/META-INF/dhis/beans.xml	2010-05-17 14:19:14 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/resources/META-INF/dhis/beans.xml	2010-05-17 21:31:03 +0000
@@ -24,9 +24,7 @@
     
   <!-- JdbcConfiguration -->
     
-  <bean id="jdbcConfiguration" class="org.hisp.dhis.jdbc.configuration.JdbcConfigurationFactoryBean" init-method="init">
-    <property name="configurationProvider" ref="org.hisp.dhis.hibernate.HibernateConfigurationProvider"/>   
-  </bean>
+  <bean id="jdbcConfiguration" class="org.hisp.dhis.jdbc.configuration.JdbcConfigurationFactoryBean" init-method="init"/>
     
   <!-- StatementBuilder -->
     

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/HibernateDatabaseInfoProvider.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/HibernateDatabaseInfoProvider.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/database/HibernateDatabaseInfoProvider.java	2010-05-17 21:31:03 +0000
@@ -29,6 +29,7 @@
 
 import org.hibernate.cfg.Configuration;
 import org.hisp.dhis.hibernate.HibernateConfigurationProvider;
+import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * @author Lars Helge Overland
@@ -56,13 +57,9 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    @Autowired
     private HibernateConfigurationProvider configurationProvider;
     
-    public void setConfigurationProvider( HibernateConfigurationProvider configurationProvider )
-    {
-        this.configurationProvider = configurationProvider;
-    }
-
     public void init()
     {
         Configuration config = configurationProvider.getConfiguration();

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml	2010-05-17 14:19:14 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml	2010-05-17 21:31:03 +0000
@@ -23,8 +23,6 @@
   <bean id="org.hisp.dhis.system.database.DatabaseInfoProvider"
     class="org.hisp.dhis.system.database.HibernateDatabaseInfoProvider"
     init-method="init">
-    <property name="configurationProvider"
-      ref="org.hisp.dhis.hibernate.HibernateConfigurationProvider"/>
   </bean>
   
 </beans>