Author: snoopdave
Date: Thu May 24 09:05:53 2007
New Revision: 541344

URL: http://svn.apache.org/viewvc?view=rev&rev=541344
Log:
Planet and Roller using DatabaseProvider approach now still not an ideal 
situation with the way we're sharing HibernatePersistenceStrategy

Added:
    roller/trunk/src/org/apache/roller/planet/business/hibernate/
    
roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernateRollerPlanetImpl.java
Modified:
    
roller/trunk/src/org/apache/roller/business/hibernate/HibernatePersistenceStrategy.java
    
roller/trunk/src/org/apache/roller/business/hibernate/HibernateRollerImpl.java
    roller/trunk/tools/roller-planet/roller-planet-business.jar
    roller/trunk/web/WEB-INF/classes/planet-hibernate.cfg.xml
    roller/trunk/web/WEB-INF/classes/planet.properties

Modified: 
roller/trunk/src/org/apache/roller/business/hibernate/HibernatePersistenceStrategy.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/business/hibernate/HibernatePersistenceStrategy.java?view=diff&rev=541344&r1=541343&r2=541344
==============================================================================
--- 
roller/trunk/src/org/apache/roller/business/hibernate/HibernatePersistenceStrategy.java
 (original)
+++ 
roller/trunk/src/org/apache/roller/business/hibernate/HibernatePersistenceStrategy.java
 Thu May 24 09:05:53 2007
@@ -28,7 +28,6 @@
 import org.hibernate.Transaction;
 import org.hibernate.cfg.Configuration;
 import org.apache.roller.RollerException;
-import org.apache.roller.config.RollerConfig;
 import org.hibernate.cfg.Environment;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
@@ -62,18 +61,16 @@
      * 'hibernate.dialect' - the classname of the Hibernate dialect to be used,
      * 'hibernate.connectionProvider - the classname of Roller's connnection 
provider impl.
      */
-    public HibernatePersistenceStrategy() {
+    public HibernatePersistenceStrategy(String configResource, String dialect, 
String connectionProvider) {
         
         // Read Hibernate config file specified by Roller config
         Configuration config = new Configuration();
-        config.configure(RollerConfig.getProperty("hibernate.configResource"));
+        config.configure(configResource);
 
         // Add dialect specified by Roller config and our connection provider
         Properties props = new Properties();
-        props.put(Environment.DIALECT, 
-                RollerConfig.getProperty("hibernate.dialect"));
-        props.put(Environment.CONNECTION_PROVIDER, 
-                RollerConfig.getProperty("hibernate.connectionProvider"));
+        props.put(Environment.DIALECT, dialect);
+        props.put(Environment.CONNECTION_PROVIDER, connectionProvider);
         config.mergeProperties(props);
         
         this.sessionFactory = config.buildSessionFactory(); 

Modified: 
roller/trunk/src/org/apache/roller/business/hibernate/HibernateRollerImpl.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/business/hibernate/HibernateRollerImpl.java?view=diff&rev=541344&r1=541343&r2=541344
==============================================================================
--- 
roller/trunk/src/org/apache/roller/business/hibernate/HibernateRollerImpl.java 
(original)
+++ 
roller/trunk/src/org/apache/roller/business/hibernate/HibernateRollerImpl.java 
Thu May 24 09:05:53 2007
@@ -18,7 +18,6 @@
 
 package org.apache.roller.business.hibernate;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
@@ -52,20 +51,25 @@
     private HibernatePersistenceStrategy strategy = null;
     
     // references to the managers we maintain
-    private BookmarkManager bookmarkManager = null;
+    private BookmarkManager   bookmarkManager = null;
     private PropertiesManager propertiesManager = null;
-    private RefererManager refererManager = null;
-    private UserManager userManager = null;
-    private WeblogManager weblogManager = null;
-    private PingQueueManager pingQueueManager = null;
-    private AutoPingManager autoPingManager = null;
+    private RefererManager    refererManager = null;
+    private UserManager       userManager = null;
+    private WeblogManager     weblogManager = null;
+    private PingQueueManager  pingQueueManager = null;
+    private AutoPingManager   autoPingManager = null;
     private PingTargetManager pingTargetManager = null;
-    private ThreadManager threadManager = null;
+    private ThreadManager     threadManager = null;
     
     
     protected HibernateRollerImpl() throws RollerException {
         try {
-            strategy = new HibernatePersistenceStrategy();
+            String dialect =  
+                RollerConfig.getProperty("hibernate.dialect");
+            String connectionProvider = 
+                RollerConfig.getProperty("hibernate.connectionProvider");
+            strategy = new HibernatePersistenceStrategy(
+                "/hibernate.cfg.xml", dialect, connectionProvider);
         } catch(Throwable t) {
             // if this happens then we are screwed
             mLogger.fatal("Error initializing Hibernate", t);
@@ -81,6 +85,11 @@
         if (me == null) {
             mLogger.debug("Instantiating HibernateRollerImpl");
             me = new HibernateRollerImpl();
+                                
+            // Now that Roller has been instantiated, initialize individual 
managers
+            me.getPropertiesManager();
+            me.getIndexManager();
+            me.getThemeManager();          
         }
         
         return me;

Added: 
roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernateRollerPlanetImpl.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernateRollerPlanetImpl.java?view=auto&rev=541344
==============================================================================
--- 
roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernateRollerPlanetImpl.java
 (added)
+++ 
roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernateRollerPlanetImpl.java
 Thu May 24 09:05:53 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.roller.planet.business.hibernate;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.RollerException;
+import org.apache.roller.config.RollerConfig;
+import org.apache.roller.planet.business.Planet;
+
+/**
+ * Roller specific Planet implementation, uses RollerConfig to configure 
Hibernate.
+ */
+public class HibernateRollerPlanetImpl extends HibernatePlanetImpl {
+    private static Log log = 
LogFactory.getLog(HibernateRollerPlanetImpl.class);
+    
+    public HibernateRollerPlanetImpl() throws RollerException {
+        super();
+    }
+    
+    protected HibernatePersistenceStrategy getStrategy() throws 
RollerException {
+        try {
+            String dialect =  
+                RollerConfig.getProperty("hibernate.dialect");
+            String connectionProvider = 
+                RollerConfig.getProperty("hibernate.connectionProvider");
+            return new HibernatePersistenceStrategy(
+                "/planet-hibernate.cfg.xml", dialect, connectionProvider);
+
+        } catch(Throwable t) {
+            // if this happens then we are screwed
+            log.fatal("Error initializing Hibernate", t);
+            throw new RollerException(t);
+        }        
+    }
+    
+    
+    /**
+     * Instantiates and returns an instance of HibernatePlanetImpl.
+     */
+    public static Planet instantiate() throws RollerException {
+        if (me == null) {
+            log.debug("Instantiating HibernatePlanetImpl");
+            me = new HibernatePlanetImpl();
+        }
+        
+        return me;
+    }   
+}

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=541344&r1=541343&r2=541344
==============================================================================
Binary files - no diff available.

Modified: roller/trunk/web/WEB-INF/classes/planet-hibernate.cfg.xml
URL: 
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/classes/planet-hibernate.cfg.xml?view=diff&rev=541344&r1=541343&r2=541344
==============================================================================
--- roller/trunk/web/WEB-INF/classes/planet-hibernate.cfg.xml (original)
+++ roller/trunk/web/WEB-INF/classes/planet-hibernate.cfg.xml Thu May 24 
09:05:53 2007
@@ -22,11 +22,10 @@
 <hibernate-configuration>
     <session-factory>
         
-        <!-- You can override this via the jdbc.XXX properties in 
roller-custom.properties -->
-        <property 
name="connection.datasource">java:comp/env/jdbc/rollerdb</property>
-                        
-        <!-- You can override this via the hibernate.dialect property in 
roller-custom.properties -->
-        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
+        <!-- 
+            Specify your Roller database configuration parameters
+            in your roller-custom.properties override file, not here.
+         -->
                        
         <property name="show_sql">false</property>
 

Modified: roller/trunk/web/WEB-INF/classes/planet.properties
URL: 
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/classes/planet.properties?view=diff&rev=541344&r1=541343&r2=541344
==============================================================================
--- roller/trunk/web/WEB-INF/classes/planet.properties (original)
+++ roller/trunk/web/WEB-INF/classes/planet.properties Thu May 24 09:05:53 2007
@@ -40,7 +40,7 @@
 # properties in this file are accessed like this ...
 #    PlanetConfig.getProperty("propname");
 
-persistence.planet.classname=org.apache.roller.planet.business.hibernate.HibernatePlanetImpl
+persistence.planet.classname=org.apache.roller.planet.business.hibernate.HibernateRollerPlanetImpl
 
 # You MUST override and set these three properties correctly:
 cache.dir=/var/planet/cache
@@ -54,19 +54,4 @@
 feedfetcher.classname=\
 org.apache.roller.planet.business.RollerRomeFeedFetcher
 
-# How the hibernate config is built
-hibernate.dialect=org.hibernate.dialect.MySQLDialect
 
-# Hibernate config for Roller Planet (a classpath-based path)
-# NO NEED TO OVERRIDE this unless you are customizing Roller
-hibernate.configResource=/planet-hibernate.cfg.xml
-
-# JDBC configuration parameters for standalone tasks
-# Don't override these in the roller-custom.properties file you use with the 
-# Roller webapp, but for the standalone tasks that you run outside of Roller 
-# (e.g. refresh entries) you'll need to override these properties. Do it in a 
-# separate planet-custom.properties file.
-jdbc.driverClass=
-jdbc.connectionURL=
-jdbc.username=
-jdbc.password=


Reply via email to