You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2007/06/27 01:31:13 UTC

svn commit: r550985 - in /roller/trunk: apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePersistenceStrategy.java apps/planet/web/WEB-INF/classes/planet.properties tools/roller-planet/roller-planet-business.jar

Author: agilliland
Date: Tue Jun 26 16:31:12 2007
New Revision: 550985

URL: http://svn.apache.org/viewvc?view=rev&rev=550985
Log:
some final cleanup on planet persistence strategy stuff.


Modified:
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePersistenceStrategy.java
    roller/trunk/apps/planet/web/WEB-INF/classes/planet.properties
    roller/trunk/tools/roller-planet/roller-planet-business.jar

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePersistenceStrategy.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePersistenceStrategy.java?view=diff&rev=550985&r1=550984&r2=550985
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePersistenceStrategy.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePersistenceStrategy.java Tue Jun 26 16:31:12 2007
@@ -18,6 +18,7 @@
 
 package org.apache.roller.planet.business.hibernate;
 
+import java.util.Enumeration;
 import java.util.Properties;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -28,8 +29,6 @@
 import org.hibernate.Transaction;
 import org.hibernate.cfg.Configuration;
 import org.apache.roller.planet.config.PlanetConfig;
-import org.hibernate.cfg.Environment;
-
 
 /**
  * Base class for Hibernate persistence implementation.
@@ -43,29 +42,28 @@
     
     private static final Log log = LogFactory.getLog(HibernatePersistenceStrategy.class);
     
-    protected SessionFactory sessionFactory;
+    private final SessionFactory sessionFactory;
     
     
     /**
-     * Persistence strategy configures itself by using Roller properties:
-     * 'hibernate.configResource' - the resource name of Roller's Hibernate XML configuration file, 
-     * 'hibernate.dialect' - the classname of the Hibernate dialect to be used,
-     * 'hibernate.connectionProvider - the classname of Roller's connnection provider impl.
+     * Persistence strategy configures itself by using properties from the
+     * planet config starting with hibernate.*
      */
     protected HibernatePersistenceStrategy() throws PlanetException {
         
-        String dialect =  
-            PlanetConfig.getProperty("hibernate.dialect");
-        String connectionProvider = 
-            PlanetConfig.getProperty("hibernate.connectionProvider");
-        
         Configuration config = new Configuration();
         config.configure("/META-INF/planet-hibernate.cfg.xml");
 
-        // Add dialect specified by Roller config and our connection provider
+        // Add all Hibernate properties found in PlanetConfig
         Properties props = new Properties();
-        props.put(Environment.DIALECT, dialect);
-        props.put(Environment.CONNECTION_PROVIDER, connectionProvider);
+        Enumeration keys = PlanetConfig.keys();
+        while (keys.hasMoreElements()) {
+            String key = (String)keys.nextElement();
+            if (key.startsWith("hibernate.")) {
+                String value = PlanetConfig.getProperty(key);
+                props.setProperty(key, value);
+            }
+        }
         config.mergeProperties(props);
         
         sessionFactory = config.buildSessionFactory(); 

Modified: roller/trunk/apps/planet/web/WEB-INF/classes/planet.properties
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/web/WEB-INF/classes/planet.properties?view=diff&rev=550985&r1=550984&r2=550985
==============================================================================
--- roller/trunk/apps/planet/web/WEB-INF/classes/planet.properties (original)
+++ roller/trunk/apps/planet/web/WEB-INF/classes/planet.properties Tue Jun 26 16:31:12 2007
@@ -62,9 +62,10 @@
 database.jdbc.username=
 database.jdbc.password=
 
-# Hibernate dialect: You must override this to use a database other than MySQL4
+# Hibernate settings
 hibernate.dialect=org.hibernate.dialect.MySQLDialect
-
+hibernate.connection.provider_class=\
+org.apache.roller.planet.business.hibernate.HibernateConnectionProvider
 
 
 #----------------------------------------------------
@@ -75,10 +76,6 @@
 
 # Number of Technorati queries allowed per day
 planet.aggregator.technorati.limit=500
-
-# Connection provider to be used - don't touch unless you are customizing Planet
-hibernate.connectionProvider=\
-org.apache.roller.planet.business.hibernate.HibernateConnectionProvider
 
 # The set of default Roller renderer factories.
 rendering.rollerRendererFactories=\

Modified: roller/trunk/tools/roller-planet/roller-planet-business.jar
URL: http://svn.apache.org/viewvc/roller/trunk/tools/roller-planet/roller-planet-business.jar?view=diff&rev=550985&r1=550984&r2=550985
==============================================================================
Binary files - no diff available.