roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r550055 [1/4] - in /roller/trunk: apps/planet/ apps/planet/nbproject/ apps/planet/src/java/org/apache/roller/planet/business/ apps/planet/src/java/org/apache/roller/planet/business/hibernate/ apps/planet/src/java/org/apache/roller/planet/bu...
Date Sat, 23 Jun 2007 15:27:59 GMT
Author: snoopdave
Date: Sat Jun 23 08:27:55 2007
New Revision: 550055

URL: http://svn.apache.org/viewvc?view=rev&rev=550055
Log:
Merging branches/roller_guice work into trunk

Added:
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/BootstrapException.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/InitializationException.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/PlanetModule.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/PlanetModule.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/PlanetStartup.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/StartupException.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/RollerModule.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/RollerModule.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/planet/business/hibernate/HibernateRollerPlanetPersistenceStrategy.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/planet/business/hibernate/RollerPlanetModule.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/planet/business/jpa/JPARollerPlanetPersistenceStrategy.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/planet/business/jpa/RollerPlanetModule.java
Removed:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/planet/business/hibernate/HibernateRollerPlanetImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/planet/business/jpa/JPARollerPlanetImpl.java
Modified:
    roller/trunk/apps/planet/build.xml
    roller/trunk/apps/planet/nbproject/project.xml
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/DatabaseProvider.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/Planet.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetFactory.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernateConnectionProvider.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePersistenceStrategy.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetImpl.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePropertiesManagerImpl.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPersistenceStrategy.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPlanetImpl.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPropertiesManagerImpl.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/PlanetTask.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/core/PlanetContext.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/core/filters/PersistenceSessionFilter.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/TestUtils.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/EntryBasicTests.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/GroupBasicTests.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/GroupFunctionalTests.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/PlanetBasicTests.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/PlanetFunctionalTests.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/PropertiesTest.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/RomeFeedFetcherTest.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionBasicTests.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionFunctionalTests.java
    roller/trunk/apps/planet/testdata/planet-custom.properties
    roller/trunk/apps/planet/web/WEB-INF/classes/planet.properties
    roller/trunk/apps/weblogger/nbproject/project.xml
    roller/trunk/apps/weblogger/properties.xmlf
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerFactory.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateAutoPingManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateBookmarkManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernatePersistenceStrategy.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernatePingQueueManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernatePingTargetManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernatePropertiesManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateRefererManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateRollerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateThreadManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateUserManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateWeblogManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPingQueueManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPropertiesManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPARefererManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPARollerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAUserManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/referrers/ReferrerQueueManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/runnable/ThreadManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/IndexManager.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/operations/AddEntryOperation.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/operations/ReIndexEntryOperation.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/operations/RebuildWebsiteIndexOperation.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/operations/RemoveEntryOperation.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/operations/RemoveWebsiteIndexOperation.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/PingConfig.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerContext.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/filters/PersistenceSessionFilter.java
    roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/IndexManagerTest.java
    roller/trunk/apps/weblogger/testdata/roller-custom.properties
    roller/trunk/apps/weblogger/web/WEB-INF/classes/planet.properties
    roller/trunk/components/core/nbproject/   (props changed)

Modified: roller/trunk/apps/planet/build.xml
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/build.xml?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/build.xml (original)
+++ roller/trunk/apps/planet/build.xml Sat Jun 23 08:27:55 2007
@@ -54,6 +54,7 @@
         <include name="lib/commons-id-0.1-SNAPSHOT.jar"/>
         
         <!-- General dependencies -->
+        <include name="lib/guice-1.0.jar"/>
         <include name="lib/log4j-1.2.11.jar"/>
         <include name="lib/commons-codec-1.3.jar"/>
         <include name="lib/commons-collections-3.2.jar"/>
@@ -512,7 +513,8 @@
             <classpath>
                 <path refid="test.path"/>
                 <pathelement location="${build.compile.test}"/>
-                <pathelement location="${basedir}/testdata" />
+                <pathelement location="${basedir}/build/test/testcontext" />
+                <pathelement location="${basedir}/build/test/testcontext/WEB-INF/classes" />
                 <pathelement path="${test.db.cpath}" />
             </classpath>
         </java>
@@ -545,7 +547,8 @@
             <classpath>
                 <path refid="test.path"/>
                 <pathelement location="${build.compile.test}"/>
-                <pathelement location="${basedir}/testdata" />
+                <pathelement location="${basedir}/build/test/testcontext" />
+                <pathelement location="${basedir}/build/test/testcontext/WEB-INF/classes" />
                 <pathelement path="${test.db.cpath}" />
             </classpath>
         </java>

Modified: roller/trunk/apps/planet/nbproject/project.xml
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/nbproject/project.xml?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/nbproject/project.xml (original)
+++ roller/trunk/apps/planet/nbproject/project.xml Sat Jun 23 08:27:55 2007
@@ -10,11 +10,6 @@
             </properties>
             <folders>
                 <source-folder>
-                    <label>web</label>
-                    <type>doc_root</type>
-                    <location>web</location>
-                </source-folder>
-                <source-folder>
                     <label>src</label>
                     <type>java</type>
                     <location>src/java</location>
@@ -24,6 +19,11 @@
                     <type>java</type>
                     <location>test/java</location>
                 </source-folder>
+                <source-folder>
+                    <label>web</label>
+                    <type>doc_root</type>
+                    <location>web</location>
+                </source-folder>
             </folders>
             <ide-actions>
                 <action name="build">
@@ -98,18 +98,14 @@
         <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
             <compilation-unit>
                 <package-root>src/java</package-root>
-                <classpath mode="compile">../../tools/lib/activation.jar:../../tools/lib/log4j-1.2.11.jar:../../tools/lib/mail.jar:../../tools/lib/rome-0.9.jar:../../tools/lib/rome-fetcher-0.9.jar:../../tools/lib/commons-codec-1.3.jar:../../tools/lib/jdom.jar:../../tools/hibernate-3.1/hibernate3.jar:../../tools/hibernate-3.1/lib/asm-attrs.jar:../../tools/hibernate-3.1/lib/asm.jar:../../tools/hibernate-3.1/lib/cglib-2.1.3.jar:../../tools/hibernate-3.1/lib/dom4j-1.6.1.jar:../../tools/hibernate-3.1/lib/ehcache-1.1.jar:../../tools/hibernate-3.1/lib/jdbc2_0-stdext.jar:../../tools/hibernate-3.1/lib/jta.jar:../../tools/roller-core/roller-core.jar:../../tools/toplink-essentials-9.1/toplink-essentials.jar:../../tools/struts-2.0.6/lib/antlr-2.7.2.jar:../../tools/struts-2.0.6/lib/commons-beanutils-1.6.jar:../../tools/struts-2.0.6/lib/commons-chain-1.1.jar:../../tools/struts-2.0.6/lib/commons-fileupload-1.2.jar:../../tools/struts-2.0.6/lib/commons-io-1.3.1.jar:../../tools/struts-2.0.6/l
 ib/commons-validator-1.3.0.jar:../../tools/struts-2.0.6/lib/freemarker-2.3.8.jar:../../tools/struts-2.0.6/lib/ognl-2.6.11.jar:../../tools/struts-2.0.6/lib/oro-2.0.8.jar:../../tools/struts-2.0.6/lib/struts2-core-2.0.6.jar:../../tools/struts-2.0.6/lib/struts2-spring-plugin-2.0.6.jar:../../tools/struts-2.0.6/lib/struts2-tiles-plugin-2.0.6.jar:../../tools/struts-2.0.6/lib/tiles-api-2.0-20070207.130156-4.jar:../../tools/struts-2.0.6/lib/tiles-core-2.0-20070207.130156-4.jar:../../tools/struts-2.0.6/lib/xwork-2.0.1.jar:../../tools/lib/commons-codec-1.3.jar:../../tools/lib/commons-collections-3.2.jar:../../tools/lib/commons-id-0.1-SNAPSHOT.jar:../../tools/lib/commons-lang-2.1.jar:../../tools/lib/commons-logging-1.0.4.jar</classpath>
-                <source-level>1.5</source-level>
-            </compilation-unit>
-            <compilation-unit>
                 <package-root>test/java</package-root>
+                <classpath mode="compile">../../tools/lib/activation.jar:../../tools/lib/log4j-1.2.11.jar:../../tools/lib/mail.jar:../../tools/lib/rome-0.9.jar:../../tools/lib/rome-fetcher-0.9.jar:../../tools/lib/commons-codec-1.3.jar:../../tools/lib/jdom.jar:../../tools/hibernate-3.1/hibernate3.jar:../../tools/hibernate-3.1/lib/asm-attrs.jar:../../tools/hibernate-3.1/lib/asm.jar:../../tools/hibernate-3.1/lib/cglib-2.1.3.jar:../../tools/hibernate-3.1/lib/dom4j-1.6.1.jar:../../tools/hibernate-3.1/lib/ehcache-1.1.jar:../../tools/hibernate-3.1/lib/jdbc2_0-stdext.jar:../../tools/hibernate-3.1/lib/jta.jar:../../tools/roller-core/roller-core.jar:../../tools/struts-2.0.6/lib/antlr-2.7.2.jar:../../tools/struts-2.0.6/lib/commons-beanutils-1.6.jar:../../tools/struts-2.0.6/lib/commons-chain-1.1.jar:../../tools/struts-2.0.6/lib/commons-fileupload-1.2.jar:../../tools/struts-2.0.6/lib/commons-io-1.3.1.jar:../../tools/struts-2.0.6/lib/commons-validator-1.3.0.jar:../../tools/struts-2.0.6/li
 b/freemarker-2.3.8.jar:../../tools/struts-2.0.6/lib/ognl-2.6.11.jar:../../tools/struts-2.0.6/lib/oro-2.0.8.jar:../../tools/struts-2.0.6/lib/struts2-core-2.0.6.jar:../../tools/struts-2.0.6/lib/struts2-spring-plugin-2.0.6.jar:../../tools/struts-2.0.6/lib/struts2-tiles-plugin-2.0.6.jar:../../tools/struts-2.0.6/lib/tiles-api-2.0-20070207.130156-4.jar:../../tools/struts-2.0.6/lib/tiles-core-2.0-20070207.130156-4.jar:../../tools/struts-2.0.6/lib/xwork-2.0.1.jar:../../tools/lib/commons-collections-3.2.jar:../../tools/lib/commons-id-0.1-SNAPSHOT.jar:../../tools/lib/commons-lang-2.1.jar:../../tools/lib/commons-logging-1.0.4.jar:../../tools/lib/guice-1.0.jar:../../tools/openjpa-0.9.7/geronimo-jpa_3.0_spec-1.0.jar</classpath>
                 <source-level>1.5</source-level>
             </compilation-unit>
         </java-data>
         <web-data xmlns="http://www.netbeans.org/ns/freeform-project-web/1">
             <web-module>
                 <doc-root>web</doc-root>
-                <classpath/>
                 <context-path>/planet</context-path>
                 <j2ee-spec-level>1.5</j2ee-spec-level>
             </web-module>

Added: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/BootstrapException.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/BootstrapException.java?view=auto&rev=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/BootstrapException.java (added)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/BootstrapException.java Sat Jun 23 08:27:55 2007
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+import org.apache.roller.planet.PlanetException;
+
+
+/**
+ * Exception generated from Weblogger bootstrapping process.
+ */
+public class BootstrapException extends PlanetException {
+    
+    public BootstrapException(String msg) {
+        super(msg);
+    }
+    
+    public BootstrapException(String msg, Throwable t) {
+        super(msg, t);
+    }
+    
+}

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/DatabaseProvider.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/DatabaseProvider.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/DatabaseProvider.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/DatabaseProvider.java Sat Jun 23 08:27:55 2007
@@ -1,20 +1,48 @@
+/*
+ * 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;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Properties;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.sql.DataSource;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.planet.PlanetException;
+import org.apache.roller.planet.business.startup.StartupException;
 import org.apache.roller.planet.config.PlanetConfig;
 
+
 /**
  * Encapsulates Roller database configuration via JDBC properties or JNDI.
  *
+ * <p>To keep the logs from filling up with DB connection errors, will only 
+ * attempt to connect once.</p>
+ * 
+ * <p>Keeps startup exception and log so we can present useful debugging
+ * information to whoever is installing Roller Planet.</p>
+ *
+ *
  * <p>Reads configuration properties from PlanetConfig:</p>
  * <pre>
  * # Specify database configuration type of 'jndi' or 'jdbc'
@@ -31,15 +59,14 @@
  * </pre>
  */
 public class DatabaseProvider  {
+    
     private static Log log = LogFactory.getLog(DatabaseProvider.class);
+
     public enum ConfigurationType {JNDI_NAME, JDBC_PROPERTIES;}
+    private ConfigurationType type = ConfigurationType.JNDI_NAME;
+    private List<String> startupLog = new ArrayList<String>();
     
-    private static DatabaseProvider singletonInstance = null;
-    
-    private DataSource dataSource = null;
-    
-    private ConfigurationType type = ConfigurationType.JNDI_NAME; 
-    
+    private DataSource dataSource = null;    
     private String jndiName = null; 
     
     private String jdbcDriverClass = null;
@@ -47,12 +74,14 @@
     private String jdbcPassword = null;
     private String jdbcUsername = null;
     private Properties props = null;
-   
+    
+    
     /**
      * Reads configuraiton, loads driver or locates data-source and attempts
      * to get test connecton so that we can fail early.
      */ 
-    private DatabaseProvider() throws PlanetException {
+    public DatabaseProvider() throws StartupException {
+        
         String connectionTypeString = 
                 PlanetConfig.getProperty("database.configurationType"); 
         if ("jdbc".equals(connectionTypeString)) {
@@ -64,61 +93,92 @@
         jdbcUsername =      PlanetConfig.getProperty("database.jdbc.username");
         jdbcPassword =      PlanetConfig.getProperty("database.jdbc.password");
         
-        // init now so we fail early
-        if (type == ConfigurationType.JDBC_PROPERTIES) {
-            log.info("Using 'jdbc' properties based configuration");
+        successMessage("SUCCESS: Got parameters. Using configuration type " + type);
+
+        // If we're doing JDBC then attempt to load JDBC driver class
+        if (getType() == ConfigurationType.JDBC_PROPERTIES) {
+            successMessage("-- Using JDBC driver class: "   + jdbcDriverClass);
+            successMessage("-- Using JDBC connection URL: " + jdbcConnectionURL);
+            successMessage("-- Using JDBC username: "       + jdbcUsername);
+            successMessage("-- Using JDBC password: [hidden]");
             try {
-                Class.forName(jdbcDriverClass);
+                Class.forName(getJdbcDriverClass());
             } catch (ClassNotFoundException ex) {
-                throw new PlanetException(
-                   "Cannot load specified JDBC driver class [" +jdbcDriverClass+ "]", ex);
+                String errorMsg = 
+                     "ERROR: cannot load JDBC driver class [" + getJdbcDriverClass()+ "]. "
+                    +"Likely problem: JDBC driver jar missing from server classpath.";
+                errorMessage(errorMsg);
+                throw new StartupException(errorMsg, ex, startupLog);
             }
-            if (jdbcUsername != null || jdbcPassword != null) {
+            successMessage("SUCCESS: loaded JDBC driver class [" +getJdbcDriverClass()+ "]");
+            
+            if (getJdbcUsername() != null || getJdbcPassword() != null) {
                 props = new Properties();
-                if (jdbcUsername != null) props.put("user", jdbcUsername);
-                if (jdbcPassword != null) props.put("password", jdbcPassword);
+                if (getJdbcUsername() != null) props.put("user", getJdbcUsername());
+                if (getJdbcPassword() != null) props.put("password", getJdbcPassword());
             }
-        } else {
-            log.info("Using 'jndi' based configuration");
-            String name = "java:comp/env/" + jndiName;
+            
+        // Else attempt to locate JNDI datasource
+        } else { 
+            String name = "java:comp/env/" + getJndiName();
+            successMessage("-- Using JNDI datasource name: " + name);
             try {
                 InitialContext ic = new InitialContext();
                 dataSource = (DataSource)ic.lookup(name);
             } catch (NamingException ex) {
-                throw new PlanetException(
-                    "ERROR looking up data-source with JNDI name: " + name, ex);
+                String errorMsg = 
+                    "ERROR: cannot locate JNDI DataSource [" +name+ "]. "
+                   +"Likely problem: no DataSource or datasource is misconfigured.";
+                errorMessage(errorMsg);
+                throw new StartupException(errorMsg, ex, startupLog);
             }            
+            successMessage("SUCCESS: located JNDI DataSource [" +name+ "]");
         }
+        
+        // So far so good. Now, can we get a connection?
         try { 
             Connection testcon = getConnection();
             testcon.close();
         } catch (Throwable t) {
-            throw new PlanetException("ERROR unable to obtain connection", t);
+            String errorMsg = 
+                "ERROR: unable to obtain database connection. "
+               +"Likely problem: bad connection parameters or database unavailable.";
+            errorMessage(errorMsg);
+            throw new StartupException(errorMsg, t, startupLog);
         }
     }
     
-    /**
-     * Get global database provider singlton, instantiating if necessary.
-     */
-    public static DatabaseProvider getDatabaseProvider() throws PlanetException {
-        if (singletonInstance == null) {
-            singletonInstance = new DatabaseProvider();
-        }
-        return singletonInstance;
+    
+    private void successMessage(String msg) {
+        startupLog.add(msg);
+        log.info(msg);
+    }
+    
+    private void errorMessage(String msg) {
+        startupLog.add(msg);
+        log.error(msg);
     }
     
+
+    /** 
+     * List of success and error messages when class was first instantiated.
+     **/
+    public List<String> getStartupLog() {
+        return startupLog;
+    }
+
     /**
      * Get database connection from data-source or driver manager, depending 
      * on which is configured.
      */
     public Connection getConnection() throws SQLException {
-        if (type == ConfigurationType.JDBC_PROPERTIES) {
-            return DriverManager.getConnection(jdbcConnectionURL, props);
+        if (getType() == ConfigurationType.JDBC_PROPERTIES) {
+            return DriverManager.getConnection(getJdbcConnectionURL(), props);
         } else {
             return dataSource.getConnection();
         }
-    }
-    
+    } 
+
     public ConfigurationType getType() {
         return type;
     }
@@ -142,4 +202,5 @@
     public String getJdbcUsername() {
         return jdbcUsername;
     }
+
 }

Added: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/InitializationException.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/InitializationException.java?view=auto&rev=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/InitializationException.java (added)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/InitializationException.java Sat Jun 23 08:27:55 2007
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+import org.apache.roller.planet.PlanetException;
+
+
+/**
+ * Exception generated from Weblogger initialization process.
+ */
+public class InitializationException extends PlanetException {
+    
+    public InitializationException(String msg) {
+        super(msg);
+    }
+    
+    public InitializationException(String msg, Throwable t) {
+        super(msg, t);
+    }
+    
+}

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/Planet.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/Planet.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/Planet.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/Planet.java Sat Jun 23 08:27:55 2007
@@ -46,29 +46,23 @@
     
     
     /**
-     * Set the configured URLStrategy.
-     */
-    public void setURLStrategy(URLStrategy urlStrategy);
-    
-    
-    /**
      * Get the configured FeedFetcher.
      */
     public FeedFetcher getFeedFetcher();
     
-    
+        
     /**
-     * Set the configured FeedFetcher.
+     * Flush object states.
      */
-    public void setFeedFetcher(FeedFetcher feedFetcher);
+    public void flush() throws PlanetException;
     
     
     /**
-     * Flush object states.
+     * Initialize any resources necessary for this instance of Roller.
      */
-    public void flush() throws PlanetException;
-    
+    public void initialize() throws InitializationException;
     
+
     /**
      * Release any resources associated with a session.
      */

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetFactory.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetFactory.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetFactory.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetFactory.java Sat Jun 23 08:27:55 2007
@@ -18,89 +18,93 @@
 
 package org.apache.roller.planet.business;
 
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.roller.planet.business.startup.PlanetStartup;
 import org.apache.roller.planet.config.PlanetConfig; 
-import org.apache.commons.lang.StringUtils;
-
 
 /**
- * Instantiates planet implementation.
+ * Provides access to the Planet instance.
  */
-public abstract class PlanetFactory {
-    
-    private static final String DEFAULT_IMPL =
-        "org.apache.roller.planet.business.jpa.JPAPlanetImpl";
-        //"org.apache.roller.planet.business.hibernate.HibernatePlanetImpl";
-        //"org.apache.roller.planet.business.datamapper.jpa.JPAPlanetImpl";
-    
+public abstract class PlanetFactory {    
+    private static Log log = LogFactory.getLog(PlanetFactory.class);
     private static Planet planetInstance = null;
+    private static Injector injector = null;       
     
-    private static Log log = LogFactory.getLog(PlanetFactory.class);
+    // have we been bootstrapped yet?
+    private static boolean bootstrapped = false;
     
     
     /**
-     * We instantiate the Planet implementation statically at class loading time
-     * to make absolutely sure that there is no way for our singleton to get
-     * instantiated twice.
+     * Let's just be doubling certain this class cannot be instantiated.
      */
-    static {
-        // lookup value for the roller classname to use
-        String planet_classname =
-                PlanetConfig.getProperty("persistence.planet.classname");
-        if(planet_classname == null || planet_classname.trim().length() < 1)
-            planet_classname = DEFAULT_IMPL;
+    private PlanetFactory() {} // hello planetary citizens
         
+    static { 
+
+        String moduleClassname = PlanetConfig.getProperty("guice.backend.module");
         try {
-            Class planetClass = Class.forName(planet_classname);
-            java.lang.reflect.Method instanceMethod =
-                    planetClass.getMethod("instantiate", (Class[])null);
-            
-            // do the invocation
-            planetInstance = (Planet) instanceMethod.invoke(planetClass, (Object[])null);
-            
-            log.info("Using Planet Impl: " + planet_classname);
-            
-        } catch (Throwable e) {
-            
-            // uh oh
-            log.error("Error instantiating " + planet_classname, e);
-            
-            try {
-                // if we didn't already try DEFAULT_IMPL then try it now
-                if( ! DEFAULT_IMPL.equals(planet_classname)) {
-                    
-                    log.info("** Trying DEFAULT_IMPL "+DEFAULT_IMPL+" **");
-                    
-                    Class rollerClass = Class.forName(DEFAULT_IMPL);
-                    java.lang.reflect.Method instanceMethod =
-                            rollerClass.getMethod("instantiate", (Class[])null);
-                    
-                    // do the invocation
-                    planetInstance = (Planet) instanceMethod.invoke(rollerClass, (Object[])null);
-                } else {
-                    // we just do this so that the logger gets the message
-                    throw new Exception("Doh! Couldn't instantiate a planet class");
-                }
-                
-            } catch (Exception re) {
-                log.fatal("Failed to instantiate fallback planet impl", re);
-            }
+            Class moduleClass = Class.forName(moduleClassname);
+            Module module = (Module)moduleClass.newInstance();
+            injector = Guice.createInjector(module);
+        } catch (Throwable e) {                
+            // Fatal misconfiguration, cannot recover
+            throw new RuntimeException("Error instantiating backend module" + moduleClassname, e);
         }
     }
-    
+            
+    /**
+     * Static accessor for the instance of Roller
+     */
+    public static Planet getPlanet() {
+        if (planetInstance == null) {
+            throw new IllegalStateException("Roller Planet has not been bootstrapped yet");
+        }        
+        return planetInstance;
+    }     
     
     /**
-     * Let's just be doubling certain this class cannot be instantiated.
-     * @see java.lang.Object#Object()
+     * Access to Guice injector so that developers can add new injected objects.
      */
-    private PlanetFactory() {
-        // hello planetary citizens
+    public static Injector getInjector() {
+        return injector;
     }
     
-    
-    public static Planet getPlanet() {
-        return planetInstance;
+    /**
+     * True if bootstrap process was completed, False otherwise.
+     */
+    public static boolean isBootstrapped() {
+        return bootstrapped;
     }
     
+    /**
+     * Bootstrap the Roller Planet business tier.
+     *
+     * Bootstrapping the application effectively instantiates all the necessary
+     * pieces of the business tier and wires them together so that the app is 
+     * ready to run.
+     *
+     * @throws IllegalStateException If the app has not been properly prepared yet.
+     * @throws BootstrapException If an error happens during the bootstrap process.
+     */
+    public static final void bootstrap() throws BootstrapException {
+        
+        // if the app hasn't been properly started so far then bail
+        if (!PlanetStartup.isPrepared()) {
+            throw new IllegalStateException("Cannot bootstrap until application has been properly prepared");
+        }
+        
+        log.info("Bootstrapping Roller Planet business tier");
+        
+        // bootstrap Roller Weblogger business tier
+        planetInstance =  injector.getInstance(Planet.class);
+
+        // note that we've now been bootstrapped
+        bootstrapped = true;            
+        
+        log.info("Roller Planet business tier successfully bootstrapped");
+    }
 }

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernateConnectionProvider.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernateConnectionProvider.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernateConnectionProvider.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernateConnectionProvider.java Sat Jun 23 08:27:55 2007
@@ -5,13 +5,12 @@
 import java.util.Properties;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.planet.PlanetException;
-import org.apache.roller.planet.business.DatabaseProvider;
+import org.apache.roller.planet.business.startup.PlanetStartup;
 import org.hibernate.HibernateException;
 import org.hibernate.connection.ConnectionProvider;
 
 /**
- * Allows use to provide Hibernate with database connections via Roller's
+ * Allows user to provide Hibernate with database connections via Roller's
  * DatabaseProvider class. By default HibernatePersistenceStrategy adds this 
  * class to Hibernate's configuration. If you'd like to provide your own
  * ConnctionProvider implementation you can do so by overriding Roller's 
@@ -22,18 +21,11 @@
     
     /** No-op: we get our configuration from Roller's DatabaseProvider */
     public void configure(Properties properties) throws HibernateException {
-        // no-op
     }
 
     /** Get connecetion from Roller's Database provider */
     public Connection getConnection() throws SQLException {
-        try {
-            return DatabaseProvider.getDatabaseProvider().getConnection();
-        } catch (PlanetException ex) {
-            // The DatabaseProvider should have been constructed long before 
-            // we get to this point, so this should never ever happen
-            throw new RuntimeException("ERROR getting database provider", ex);
-        }
+        return PlanetStartup.getDatabaseProvider().getConnection();
     }
 
     /** Close connection by calling connection.close() */

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=550055&r1=550054&r2=550055
==============================================================================
--- 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 Sat Jun 23 08:27:55 2007
@@ -27,6 +27,7 @@
 import org.hibernate.SessionFactory;
 import org.hibernate.Transaction;
 import org.hibernate.cfg.Configuration;
+import org.apache.roller.planet.config.PlanetConfig;
 import org.hibernate.cfg.Environment;
 
 
@@ -37,14 +38,10 @@
  * manager implementations by providing a set of basic persistence methods
  * that can be easily reused.
  */
+@com.google.inject.Singleton
 public class HibernatePersistenceStrategy {
-    
-    private static final long serialVersionUID = 2561090040518169098L;
-    
     private static final Log log = LogFactory.getLog(HibernatePersistenceStrategy.class);
-    
-    private final SessionFactory sessionFactory;
-    
+    private SessionFactory sessionFactory = null;
     
     /**
      * Persistence strategy configures itself by using Roller properties:
@@ -52,13 +49,18 @@
      * 'hibernate.dialect' - the classname of the Hibernate dialect to be used,
      * 'hibernate.connectionProvider - the classname of Roller's connnection provider impl.
      */
-    public HibernatePersistenceStrategy(String configResource, 
-                                        String dialect, 
-                                        String connectionProvider) {
-        
-        // Read Hibernate config file specified by Roller config
+    protected HibernatePersistenceStrategy() throws PlanetException {        
+        String dialect =  
+            PlanetConfig.getProperty("hibernate.dialect");
+        String connectionProvider = 
+            PlanetConfig.getProperty("hibernate.connectionProvider");        
+        String configuration = "hibernate.cfg.xml";
+        init(dialect, connectionProvider, configuration);
+    }   
+    
+    protected void init(String dialect, String connectionProvider, String configuration) {
         Configuration config = new Configuration();
-        config.configure(configResource);
+        config.configure(configuration);
 
         // Add dialect specified by Roller config and our connection provider
         Properties props = new Properties();

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetImpl.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetImpl.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetImpl.java Sat Jun 23 08:27:55 2007
@@ -33,6 +33,7 @@
 /**
  * A Hibernate specific implementation of the Roller Planet business layer.
  */
+@com.google.inject.Singleton
 public class HibernatePlanetImpl implements Planet {   
     
     private static Log log = LogFactory.getLog(HibernatePlanetImpl.class);
@@ -58,69 +59,32 @@
      * Create HibernatePlanetImpl using Hibernate XML config file or config
      * file plus JDBC overrides from planet-custom.properties.
      */
-    public HibernatePlanetImpl() throws PlanetException {
-        
-        strategy = getStrategy();
-        
-        try {
-            String feedFetchClass = PlanetConfig.getProperty("feedfetcher.classname");
-            if(feedFetchClass == null || feedFetchClass.trim().length() < 1) {
-                throw new PlanetException("No FeedFetcher configured!!!");
-            }
-            
-            Class fetchClass = Class.forName(feedFetchClass);
-            FeedFetcher feedFetcher = (FeedFetcher) fetchClass.newInstance();
-            
-            // plug it in
-            setFeedFetcher(feedFetcher);
-            
-        } catch (Exception e) {
-            throw new PlanetException("Error initializing feed fetcher", e);
-        }
+    @com.google.inject.Inject 
+    protected HibernatePlanetImpl(
+            HibernatePersistenceStrategy strategy, 
+            PlanetManager     planetManager, 
+            PropertiesManager propertiesManager,
+            URLStrategy       urlStrategy,
+            FeedFetcher       feedFetcher) throws PlanetException {
+        
+        this.strategy = strategy;
+        this.propertiesManager = propertiesManager;
+        this.planetManager = planetManager;
+        this.urlStrategy = urlStrategy;
     }
+       
     
-    protected HibernatePersistenceStrategy getStrategy() throws PlanetException {
-        try {
-            String dialect =  
-                PlanetConfig.getProperty("hibernate.dialect");
-            String connectionProvider = 
-                PlanetConfig.getProperty("hibernate.connectionProvider");
-            return new HibernatePersistenceStrategy(
-                "/hibernate.cfg.xml", dialect, connectionProvider);
-
-        } catch(Throwable t) {
-            // if this happens then we are screwed
-            log.fatal("Error initializing Hibernate", t);
-            throw new PlanetException(t);
-        }        
-    }
-    
-    
-    /**
-     * Instantiates and returns an instance of HibernatePlanetImpl.
-     */
-    public static Planet instantiate() throws PlanetException {
-        if (me == null) {
-            log.debug("Instantiating HibernatePlanetImpl");
-            me = new HibernatePlanetImpl();
-        }
-        
-        return me;
+    public void initialize() {
+        // no-op
     }
     
     
     public PlanetManager getPlanetManager() {
-        if ( planetManager == null ) {
-            planetManager = new HibernatePlanetManagerImpl(strategy);  
-        }
         return planetManager;
     }
     
     
     public PropertiesManager getPropertiesManager() {
-        if ( propertiesManager == null ) {
-            propertiesManager = new HibernatePropertiesManagerImpl(strategy);  
-        }
         return propertiesManager;
     }
     
@@ -129,21 +93,11 @@
         return this.urlStrategy;
     }
     
-    public void setURLStrategy(URLStrategy urlStrategy) {
-        this.urlStrategy = urlStrategy;
-        log.info("Using URLStrategy: " + urlStrategy.getClass().getName());
-    }
-    
     
     public FeedFetcher getFeedFetcher() {
         return this.feedFetcher;
     }
     
-    public void setFeedFetcher(FeedFetcher feedFetcher) {
-        this.feedFetcher = feedFetcher;
-        log.info("Using FeedFetcher: " + feedFetcher.getClass().getName());
-    }
-    
     
     public void flush() throws PlanetException {
         this.strategy.flush();
@@ -178,5 +132,4 @@
         // trigger the final release()
         this.release();
     }
-    
 }

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java Sat Jun 23 08:27:55 2007
@@ -41,15 +41,16 @@
 /**
  * Hibernate implementation of the PlanetManager.
  */
-public class HibernatePlanetManagerImpl extends AbstractManagerImpl
-        implements PlanetManager {
+@com.google.inject.Singleton
+public class HibernatePlanetManagerImpl extends AbstractManagerImpl implements PlanetManager {
     
     private static Log log = LogFactory.getLog(HibernatePlanetManagerImpl.class);
     
     private HibernatePersistenceStrategy strategy = null;
     
     
-    public HibernatePlanetManagerImpl(HibernatePersistenceStrategy strat) {        
+    @com.google.inject.Inject 
+    protected HibernatePlanetManagerImpl(HibernatePersistenceStrategy strat) {        
         this.strategy = strat;
     }
     

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePropertiesManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePropertiesManagerImpl.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePropertiesManagerImpl.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePropertiesManagerImpl.java Sat Jun 23 08:27:55 2007
@@ -42,6 +42,7 @@
 /**
  * Hibernate implementation of the PropertiesManager.
  */
+@com.google.inject.Singleton
 public class HibernatePropertiesManagerImpl extends AbstractManagerImpl
         implements PropertiesManager {
     
@@ -53,7 +54,8 @@
     /**
      * Creates a new instance of HibernatePropertiesManagerImpl
      */
-    public HibernatePropertiesManagerImpl(HibernatePersistenceStrategy strat) {
+    @com.google.inject.Inject 
+    protected HibernatePropertiesManagerImpl(HibernatePersistenceStrategy strat) {
         
         log.debug("Instantiating Hibernate Properties Manager");
         

Added: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/PlanetModule.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/PlanetModule.java?view=auto&rev=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/PlanetModule.java (added)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/PlanetModule.java Sat Jun 23 08:27:55 2007
@@ -0,0 +1,49 @@
+/*
+ * 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 com.google.inject.Binder;
+import com.google.inject.Module;
+import org.apache.roller.planet.business.FeedFetcher;
+import org.apache.roller.planet.business.MultiPlanetURLStrategy;
+import org.apache.roller.planet.business.Planet;
+import org.apache.roller.planet.business.PlanetManager;
+import org.apache.roller.planet.business.PropertiesManager;
+import org.apache.roller.planet.business.RomeFeedFetcher;
+import org.apache.roller.planet.business.URLStrategy;
+
+
+/**
+ * Guice module for configuring Hibernate as Roller-backend.
+ */
+public class PlanetModule implements Module {
+
+    public void configure(Binder binder) {
+        
+        binder.bind(Planet.class).to(HibernatePlanetImpl.class);
+        
+        binder.bind(HibernatePersistenceStrategy.class); 
+        
+        binder.bind(PlanetManager.class).to(     HibernatePlanetManagerImpl.class);   
+        binder.bind(PropertiesManager.class).to( HibernatePropertiesManagerImpl.class); 
+        binder.bind(URLStrategy.class).to(       MultiPlanetURLStrategy.class);
+        binder.bind(FeedFetcher.class).to(       RomeFeedFetcher.class);
+    }    
+}
+

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPersistenceStrategy.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPersistenceStrategy.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPersistenceStrategy.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPersistenceStrategy.java Sat Jun 23 08:27:55 2007
@@ -29,21 +29,25 @@
 import java.security.PrivilegedAction;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.planet.PlanetException;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.EntityManager;
 import javax.persistence.FlushModeType;
 import javax.persistence.Persistence;
 import javax.persistence.PersistenceException;
 import javax.persistence.Query;
+import org.apache.roller.planet.PlanetException;
+import org.apache.roller.planet.business.DatabaseProvider;
+import org.apache.roller.planet.business.startup.PlanetStartup;
+import org.apache.roller.planet.config.PlanetConfig;
 
 
 /**
- * JPAPersistenceStrategy is responsible for the lowest-level interaction with
- * the JPA API.
+ * Responsible for the lowest-level interaction with the JPA API.
  */
-// TODO handle PersistenceExceptions!
+@com.google.inject.Singleton
 public class JPAPersistenceStrategy {
+    private static Log logger = 
+        LogFactory.getFactory().getInstance(JPAPersistenceStrategy.class);
     
     /**
      * The thread local EntityManager.
@@ -53,104 +57,68 @@
     /**
      * The EntityManagerFactory for this Roller instance.
      */
-    private EntityManagerFactory emf = null;
+    protected EntityManagerFactory emf = null;
     
-    /**
-     * The logger instance for this class.
-     */
-    private static Log logger = LogFactory.getFactory().getInstance(
-            JPAPersistenceStrategy.class);
             
     /**
      * Construct by finding JPA EntityManagerFactory.
-     * @throws org.apache.roller.planet.PlanetException on any error
+     * @throws org.apache.roller.PlanetException on any error
      */
-    public JPAPersistenceStrategy(
-            String puName,             
-            String jndiName, 
-            Properties properties) throws PlanetException { 
-                
-        // set strategy used by Datamapper
-        // You can configure JPA completely via the JPAEMF.properties file
-        Properties emfProps = loadPropertiesFromResourceName(
-           "JPAEMF.properties", getContextClassLoader());
-                
-        // Add additional properties passed in 
-        Enumeration keys = properties.keys();
-        while (keys.hasMoreElements()) {
-            String key = (String)keys.nextElement();
-            String value = properties.getProperty(key);
-            logger.info(key + ": " + value);
-            emfProps.setProperty(key, value);
-        }
-        
-        emfProps.setProperty("openjpa.ConnectionFactoryName", jndiName);
+    protected JPAPersistenceStrategy() throws PlanetException { 
 
-        try {
-            this.emf = Persistence.createEntityManagerFactory(puName, emfProps);
-        } catch (PersistenceException pe) {
-            logger.error("ERROR: creating entity manager", pe);
-            throw new PlanetException(pe);
-        }
-    }    
-        
-    /**
-     * Construct by finding JPA EntityManagerFactory.
-     * @throws org.apache.roller.planet.PlanetException on any error
-     */
-    public JPAPersistenceStrategy(
-            String puName,            
-            String driverClass,
-            String connectonUrl,
-            String username,
-            String password,
-            Properties properties) throws PlanetException {   
+        DatabaseProvider dbProvider = PlanetStartup.getDatabaseProvider();
         
-        logger.info("driverClass:    " + driverClass);
-        logger.info("connectionURL:  " + connectonUrl);
-        logger.info("username:       " + username);         
-
-        // set strategy used by Datamapper
-        // You can configure JPA completely via the JPAEMF.properties file
+        // Pull in any properties defined in JMAEMF.properties config file
         Properties emfProps = loadPropertiesFromResourceName(
            "JPAEMF.properties", getContextClassLoader());
-        
-        // Add additional properties passed in 
-        Enumeration keys = properties.keys();
+                
+        // Add all OpenJPA and Toplinks properties found in RollerConfig
+        Enumeration keys = PlanetConfig.keys();
         while (keys.hasMoreElements()) {
             String key = (String)keys.nextElement();
-            String value = properties.getProperty(key);
-            logger.info(key + ": " + value);
-            emfProps.setProperty(key, value);
+            if (key.startsWith("openjpa.") || key.startsWith("toplink.")) {
+                String value = PlanetConfig.getProperty(key);
+                logger.info(key + ": " + value);
+                emfProps.setProperty(key, value);
+            }
         }
         
-        // Try to please all the players
-        emfProps.setProperty("openjpa.ConnectionDriverName",     driverClass);
-        emfProps.setProperty("openjpa.ConnectionURL",            connectonUrl);
-        emfProps.setProperty("openjpa.ConnectionUserName",       username);
-        emfProps.setProperty("openjpa.ConnectionPassword",       password); 
+        if (dbProvider.getType() == DatabaseProvider.ConfigurationType.JNDI_NAME) {
+            // We're doing JNDI, so set OpenJPA JNDI name property
+            String jndiName = "java:comp/env/" + dbProvider.getJndiName();
+            emfProps.setProperty("openjpa.ConnectionFactoryName", jndiName);
+            
+        } else {
+            // So set JDBD properties for OpenJPA
+            emfProps.setProperty("openjpa.ConnectionDriverName",     dbProvider.getJdbcDriverClass());
+            emfProps.setProperty("openjpa.ConnectionURL",            dbProvider.getJdbcConnectionURL());
+            emfProps.setProperty("openjpa.ConnectionUserName",       dbProvider.getJdbcUsername());
+            emfProps.setProperty("openjpa.ConnectionPassword",       dbProvider.getJdbcPassword()); 
 
-        emfProps.setProperty("toplink.jdbc.driver",              driverClass);
-        emfProps.setProperty("toplink.jdbc.url",                 connectonUrl);
-        emfProps.setProperty("toplink.jdbc.user",                username);
-        emfProps.setProperty("toplink.jdbc.password",            password);
+            // And Toplink JPA
+            emfProps.setProperty("toplink.jdbc.driver",              dbProvider.getJdbcDriverClass());
+            emfProps.setProperty("toplink.jdbc.url",                 dbProvider.getJdbcConnectionURL());
+            emfProps.setProperty("toplink.jdbc.user",                dbProvider.getJdbcUsername());
+            emfProps.setProperty("toplink.jdbc.password",            dbProvider.getJdbcPassword());
 
-        emfProps.setProperty("hibernate.connection.driver_class",driverClass);
-        emfProps.setProperty("hibernate.connection.url",         connectonUrl);
-        emfProps.setProperty("hibernate.connection.username",    username);
-        emfProps.setProperty("hibernate.connection.password",    password); 
+            // And Hibernate JPA
+            emfProps.setProperty("hibernate.connection.driver_class",dbProvider.getJdbcDriverClass());
+            emfProps.setProperty("hibernate.connection.url",         dbProvider.getJdbcConnectionURL());
+            emfProps.setProperty("hibernate.connection.username",    dbProvider.getJdbcUsername());
+            emfProps.setProperty("hibernate.connection.password",    dbProvider.getJdbcPassword()); 
+        }
         
         try {
-            this.emf = Persistence.createEntityManagerFactory(puName, emfProps);
+            this.emf = Persistence.createEntityManagerFactory("PlanetPU", emfProps);
         } catch (PersistenceException pe) {
             logger.error("ERROR: creating entity manager", pe);
             throw new PlanetException(pe);
         }
-    }    
-        
+    }
+                        
     /**
      * Flush changes to the datastore, commit transaction, release em.
-     * @throws org.apache.roller.planet.PlanetException on any error
+     * @throws org.apache.roller.PlanetException on any error
      */
     public void flush() throws PlanetException {
         try {
@@ -177,7 +145,7 @@
      * Store object using an existing transaction.
      * @param obj the object to persist
      * @return the object persisted
-     * @throws org.apache.roller.planet.PlanetException on any error
+     * @throws org.apache.roller.PlanetException on any error
      */
     public Object store(Object obj) throws PlanetException {
         EntityManager em = getEntityManager(true);
@@ -203,7 +171,7 @@
     /**
      * Remove object from persistence storage.
      * @param po the persistent object to remove
-     * @throws org.apache.roller.planet.PlanetException on any error
+     * @throws org.apache.roller.PlanetException on any error
      */
     public void remove(Object po) throws PlanetException {
         EntityManager em = getEntityManager(true);
@@ -213,7 +181,7 @@
     /**
      * Remove object from persistence storage.
      * @param pos the persistent objects to remove
-     * @throws org.apache.roller.planet.PlanetException on any error
+     * @throws org.apache.roller.PlanetException on any error
      */
     public void removeAll(Collection pos) throws PlanetException {
         EntityManager em = getEntityManager(true);
@@ -286,7 +254,7 @@
      * Get named query with FlushModeType.COMMIT
      * @param clazz the class of instances to find
      * @param queryName the name of the query
-     * @throws org.apache.roller.planet.PlanetException on any error
+     * @throws org.apache.roller.PlanetException on any error
      */
     public Query getNamedQuery(String queryName)
     throws PlanetException {
@@ -300,7 +268,7 @@
     /**
      * Create query from queryString with FlushModeType.COMMIT
      * @param queryString the quuery
-     * @throws org.apache.roller.planet.PlanetException on any error
+     * @throws org.apache.roller.PlanetException on any error
      */
     public Query getDynamicQuery(String queryString)
     throws PlanetException {
@@ -315,7 +283,7 @@
      * Get named update query with default flush mode
      * @param clazz the class of instances to find
      * @param queryName the name of the query
-     * @throws org.apache.roller.planet.PlanetException on any error
+     * @throws org.apache.roller.PlanetException on any error
      */
     public Query getNamedUpdate(String queryName)
     throws PlanetException {
@@ -331,7 +299,7 @@
      * @return A properties object
      * @throws PlanetException
      */
-    private static Properties loadPropertiesFromResourceName(
+    protected static Properties loadPropertiesFromResourceName(
             String resourceName, ClassLoader cl) throws PlanetException {
         Properties props = new Properties();
         InputStream in = null;
@@ -363,7 +331,7 @@
      * done in a doPrivileged block because it is a secure method.
      * @return the current thread's context class loader.
      */
-    private static ClassLoader getContextClassLoader() {
+    protected static ClassLoader getContextClassLoader() {
         return (ClassLoader) AccessController.doPrivileged(
                 new PrivilegedAction() {
             public Object run() {

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPlanetImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPlanetImpl.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPlanetImpl.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPlanetImpl.java Sat Jun 23 08:27:55 2007
@@ -18,16 +18,12 @@
 
 package org.apache.roller.planet.business.jpa;
 
-import java.util.Enumeration;
-import java.util.Properties;
-import org.apache.roller.planet.business.DatabaseProvider;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.planet.PlanetException;
 import org.apache.roller.planet.business.URLStrategy;
 import org.apache.roller.planet.business.Planet;
 import org.apache.roller.planet.business.PlanetManager;
-import org.apache.roller.planet.business.jpa.JPAPersistenceStrategy;
 import org.apache.roller.planet.business.FeedFetcher;
 import org.apache.roller.planet.business.PropertiesManager;
 import org.apache.roller.planet.config.PlanetConfig;
@@ -37,6 +33,7 @@
  * Implements Planet, the entry point interface for the Roller-Planet business 
  * tier APIs using the Java Persistence API (JPA).
  */
+@com.google.inject.Singleton
 public class JPAPlanetImpl implements Planet {   
     
     private static Log log = LogFactory.getLog(JPAPlanetImpl.class);
@@ -58,96 +55,42 @@
     protected FeedFetcher feedFetcher = null;
     
         
-    protected JPAPlanetImpl() throws PlanetException {
-        
-        strategy = getStrategy();
-        
-        try {
-            String feedFetchClass = PlanetConfig.getProperty("feedfetcher.classname");
-            if(feedFetchClass == null || feedFetchClass.trim().length() < 1) {
-                throw new PlanetException("No FeedFetcher configured!!!");
-            }
-            
-            Class fetchClass = Class.forName(feedFetchClass);
-            FeedFetcher feedFetcher = (FeedFetcher) fetchClass.newInstance();
-            
-            // plug it in
-            setFeedFetcher(feedFetcher); 
-            
-        } catch (Exception e) {
-            throw new PlanetException("Error initializing feed fetcher", e);
-        }
-        
+    @com.google.inject.Inject  
+    protected JPAPlanetImpl(
+            JPAPersistenceStrategy strategy, 
+            PlanetManager     planetManager, 
+            PropertiesManager propertiesManager,
+            URLStrategy       urlStrategy,
+            FeedFetcher       feedFetcher) throws PlanetException {
+        
+        this.strategy = strategy;
+        this.propertiesManager = propertiesManager;
+        this.planetManager = planetManager;
+        this.urlStrategy = urlStrategy;
+        this.feedFetcher = feedFetcher;
     }
     
-    protected JPAPersistenceStrategy getStrategy() throws PlanetException {
-        
-        // Add OpenJPA, Toplink and Hibernate properties to Roller config.
-        Properties props = new Properties();
-        Enumeration keys = PlanetConfig.keys();
-        while (keys.hasMoreElements()) {
-            String key = (String)keys.nextElement();
-            if (key.startsWith("openjpa.") || key.startsWith("toplink.")) {
-                String value = PlanetConfig.getProperty(key);
-                log.info(key + ": " + value);
-                props.setProperty(key, value);
-            }
-        }
-        
-        DatabaseProvider dbProvider = DatabaseProvider.getDatabaseProvider();
-        if (dbProvider.getType() == DatabaseProvider.ConfigurationType.JNDI_NAME) {
-            return new JPAPersistenceStrategy(
-                "PlanetPU", "java:comp/env/" + dbProvider.getJndiName(), props); 
-        } else {
-            return new JPAPersistenceStrategy(
-                "PlanetPU",  
-                dbProvider.getJdbcDriverClass(),
-                dbProvider.getJdbcConnectionURL(),
-                dbProvider.getJdbcUsername(),
-                dbProvider.getJdbcPassword(), 
-                props);
-        }
+
+    public void initialize() {
+        // no-op
     }
     
-    /**
-     * Instantiates and returns an instance of JPAPlanetImpl.
-     */
-    public static Planet instantiate() throws PlanetException {
-        if (me == null) {
-            log.debug("Instantiating JPAPlanetImpl");
-            me = new JPAPlanetImpl();
-        }
-        
-        return me;
-    }    
-
     public URLStrategy getURLStrategy() {
         return this.urlStrategy;
     }
     
-    public void setURLStrategy(URLStrategy urlStrategy) {
-        this.urlStrategy = urlStrategy;
-        log.info("Using URLStrategy: " + urlStrategy.getClass().getName());
-    }
     
-        public void flush() throws PlanetException {
+    public void flush() throws PlanetException {
         this.strategy.flush();
     }
 
     
     public void release() {
-
-        // release our own stuff first
-        //if (planetManager != null) planetManager.release();
-
-        // tell Datamapper to close down
         this.strategy.release();
     }
 
     
     public void shutdown() {
-
-        // do our own shutdown first
         this.release();
     }
     
@@ -155,40 +98,19 @@
      * @see org.apache.roller.business.Roller#getBookmarkManager()
      */
     public PlanetManager getPlanetManager() {
-        if ( planetManager == null ) {
-            planetManager = createPlanetManager(strategy);
-        }
         return planetManager;
     }
 
-    protected PlanetManager createPlanetManager(
-            JPAPersistenceStrategy strategy) {
-        return new JPAPlanetManagerImpl(strategy);
-    }    
-    
+     
     /**
      * @see org.apache.roller.business.Roller#getBookmarkManager()
      */
     public PropertiesManager getPropertiesManager() {
-        if ( propertiesManager == null ) {
-            propertiesManager = createPropertiesManager(strategy);
-        }
         return propertiesManager;
     }
-
-    protected PropertiesManager createPropertiesManager(
-            JPAPersistenceStrategy strategy) {
-        return new JPAPropertiesManagerImpl(strategy);
-    } 
+    
     
     public FeedFetcher getFeedFetcher() {
         return this.feedFetcher;
-    }
-    
-    public void setFeedFetcher(FeedFetcher feedFetcher) {
-        this.feedFetcher = feedFetcher;
-        log.info("Using FeedFetcher: " + feedFetcher.getClass().getName());
-    }
-    
-
+    }   
 }

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPlanetManagerImpl.java Sat Jun 23 08:27:55 2007
@@ -44,6 +44,7 @@
  *
  * @author Dave Johnson
  */
+@com.google.inject.Singleton
 public class JPAPlanetManagerImpl extends AbstractManagerImpl implements PlanetManager {
     
     private static Log log = LogFactory.getLog(JPAPlanetManagerImpl.class);
@@ -54,7 +55,8 @@
     protected Map lastUpdatedByGroup = new HashMap();
     protected static final String NO_GROUP = "zzz_nogroup_zzz";
     
-    public JPAPlanetManagerImpl(JPAPersistenceStrategy strategy) {
+    @com.google.inject.Inject  
+    protected JPAPlanetManagerImpl(JPAPersistenceStrategy strategy) {
         log.debug("Instantiating JPA Planet Manager");
         
         this.strategy = strategy;

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPropertiesManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPropertiesManagerImpl.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPropertiesManagerImpl.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPropertiesManagerImpl.java Sat Jun 23 08:27:55 2007
@@ -18,6 +18,7 @@
 
 package org.apache.roller.planet.business.jpa;
 
+import com.google.inject.Inject;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -39,6 +40,7 @@
 /**
  * Hibernate implementation of the PropertiesManager.
  */
+@com.google.inject.Singleton
 public class JPAPropertiesManagerImpl  extends AbstractManagerImpl implements PropertiesManager {
     
     private static Log log = LogFactory.getLog(JPAPropertiesManagerImpl.class);
@@ -49,7 +51,8 @@
     /**
      * Creates a new instance of JPAPropertiesManagerImpl
      */
-    public JPAPropertiesManagerImpl(JPAPersistenceStrategy strat) {
+    @com.google.inject.Inject
+    protected JPAPropertiesManagerImpl(JPAPersistenceStrategy strat) {
         
         log.debug("Instantiating JPA Properties Manager");
         

Added: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/PlanetModule.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/PlanetModule.java?view=auto&rev=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/PlanetModule.java (added)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/jpa/PlanetModule.java Sat Jun 23 08:27:55 2007
@@ -0,0 +1,48 @@
+/*
+ * 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.jpa;
+
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import org.apache.roller.planet.business.FeedFetcher;
+import org.apache.roller.planet.business.MultiPlanetURLStrategy;
+import org.apache.roller.planet.business.Planet;
+import org.apache.roller.planet.business.PlanetManager;
+import org.apache.roller.planet.business.PropertiesManager;
+import org.apache.roller.planet.business.RomeFeedFetcher;
+import org.apache.roller.planet.business.URLStrategy;
+
+/**
+ * Guice module for configuring JPA as Roller-backend.
+ */
+public class PlanetModule implements Module {
+
+    public void configure(Binder binder) {
+
+        binder.bind(Planet.class).to(JPAPlanetImpl.class);
+        
+        binder.bind(JPAPersistenceStrategy.class); 
+        
+        binder.bind(PlanetManager.class).to(     JPAPlanetManagerImpl.class);   
+        binder.bind(PropertiesManager.class).to( JPAPropertiesManagerImpl.class);   
+        binder.bind(URLStrategy.class).to(       MultiPlanetURLStrategy.class);
+        binder.bind(FeedFetcher.class).to(       RomeFeedFetcher.class);
+    }    
+}
+

Added: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/PlanetStartup.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/PlanetStartup.java?view=auto&rev=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/PlanetStartup.java (added)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/PlanetStartup.java Sat Jun 23 08:27:55 2007
@@ -0,0 +1,95 @@
+/*
+ * 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.startup;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.planet.business.DatabaseProvider;
+
+
+/**
+ * Manages Roller Planet startup process.
+ */
+public final class PlanetStartup {
+    
+    private static final Log log = LogFactory.getLog(PlanetStartup.class);
+    
+    private static boolean prepared = false;
+    
+    private static DatabaseProvider dbProvider = null;
+    private static StartupException dbProviderException = null;
+    
+    
+    // non-instantiable
+    private PlanetStartup() {}
+    
+    
+    /**
+     * Is the Roller Weblogger app properly prepared to be bootstrapped?
+     */
+    public static boolean isPrepared() {
+        return prepared;
+    }
+    
+    
+    /**
+     * Get a reference to the currently configured DatabaseProvider.
+     *
+     * @return DatabaseProvider The configured database provider.
+     * @throws IllegalStateException If the app has not been properly prepared yet.
+     */
+    public static DatabaseProvider getDatabaseProvider() {
+        if (dbProvider == null) {
+            throw new IllegalStateException("Roller Planet has not been prepared yet");
+        }
+        return dbProvider;
+    }
+    
+    
+    /**
+     * Get a reference to the exception thrown while instantiating the 
+     * database provider, if any.
+     *
+     * @return StartupException Exception from db provider, or null if no exception thrown.
+     */
+    public static StartupException getDatabaseProviderException() {
+        return dbProviderException;
+    }
+
+    
+    /**
+     * Run the Roller Weblogger preparation sequence.
+     *
+     * This sequence is what prepares the core services of the application such
+     * as setting up the database and mail providers.
+     */
+    public static void prepare() throws StartupException {
+        
+        // setup database provider
+        try {
+            dbProvider = new DatabaseProvider();
+        } catch(StartupException ex) { 
+            dbProviderException = ex;
+            throw ex;
+        }   
+        
+        prepared = true;
+    }
+    
+}

Added: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/StartupException.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/StartupException.java?view=auto&rev=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/StartupException.java (added)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/startup/StartupException.java Sat Jun 23 08:27:55 2007
@@ -0,0 +1,69 @@
+/*
+ * 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.startup;
+
+import java.util.Collections;
+import java.util.List;
+import org.apache.roller.planet.PlanetException;
+
+
+/**
+ * Exception generated from Weblogger startup process.
+ */
+public class StartupException extends PlanetException {
+    
+    private final List<String> startupLog;
+    
+    
+    public StartupException(String msg) {
+        super(msg);
+        this.startupLog = Collections.EMPTY_LIST;
+    }
+    
+    public StartupException(String msg, Throwable t) {
+        super(msg, t);
+        this.startupLog = Collections.EMPTY_LIST;
+    }
+    
+    public StartupException(String msg, List<String> log) {
+        super(msg);
+        
+        if(log != null) {
+            this.startupLog = log;
+        } else {
+            this.startupLog = Collections.EMPTY_LIST;
+        }
+    }
+    
+    public StartupException(String msg, Throwable t, List<String> log) {
+        super(msg, t);
+        
+        if(log != null) {
+            this.startupLog = log;
+        } else {
+            this.startupLog = Collections.EMPTY_LIST;
+        }
+    }
+    
+    
+    public List<String> getStartupLog() {
+        return startupLog;
+    }
+    
+}

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/PlanetTask.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/PlanetTask.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/PlanetTask.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/PlanetTask.java Sat Jun 23 08:27:55 2007
@@ -33,26 +33,5 @@
      * Initialize the task basically the same way the webapp would initialize.
      */
     public void initialize() throws Exception {
-        setupURLStrategy();
-    }
-    
-    
-    /**
-     * Lookup configured URLStrategy from config and plug it in.
-     *
-     * If no URLStrategy can be configured then we bail and spew errors.
-     */
-    protected void setupURLStrategy() throws Exception {
-        
-        String urlStratClass = PlanetConfig.getProperty("urlstrategy.classname");
-        if(urlStratClass == null || urlStratClass.trim().length() < 1) {
-            throw new Exception("No URLStrategy configured!!!");
-        }
-        
-        Class stratClass = Class.forName(urlStratClass);
-        URLStrategy urlStrategy = (URLStrategy) stratClass.newInstance();
-        
-        // plug it in
-        PlanetFactory.getPlanet().setURLStrategy(urlStrategy);
-    }        
+    }       
 }

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/core/PlanetContext.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/core/PlanetContext.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/core/PlanetContext.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/core/PlanetContext.java Sat Jun 23 08:27:55 2007
@@ -24,11 +24,10 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.planet.PlanetException;
-import org.apache.roller.planet.business.FeedFetcher;
-import org.apache.roller.planet.business.Planet;
+import org.apache.roller.planet.business.BootstrapException;
 import org.apache.roller.planet.business.PlanetFactory;
-import org.apache.roller.planet.business.URLStrategy;
-import org.apache.roller.planet.config.PlanetConfig;
+import org.apache.roller.planet.business.startup.PlanetStartup;
+import org.apache.roller.planet.business.startup.StartupException;
 import org.springframework.web.context.ContextLoaderListener;
 
 
@@ -75,22 +74,32 @@
         // because listeners don't initialize in the order specified in
         // 2.3 containers
         super.contextInitialized(sce);
-        
+                
+        // Now prepare the core services of the app so we can bootstrap
         try {
-            // always upgrade database first
-            upgradeDatabaseIfNeeded();
-            
-            Planet planet = PlanetFactory.getPlanet();
-            
-            setupRuntimeProperties();
-            setupURLStrategy();
-            
-            planet.flush();
-            planet.release();
-            
-        } catch (Throwable t) {
-            log.fatal("Roller Planet initialization failed", t);
-            throw new RuntimeException(t);
+            PlanetStartup.prepare();
+        } catch (StartupException ex) {
+            log.fatal("Roller Planet startup failed during app preparation", ex);
+            return;
+        }        
+        
+        // if preparation failed or is incomplete then we are done,
+        // otherwise try to bootstrap the business tier
+        if (!PlanetStartup.isPrepared()) {
+            log.info("Roller Planet startup requires interaction from user to continue");
+        } else {
+            try {
+                // trigger bootstrapping process
+                PlanetFactory.bootstrap();
+                
+                // trigger initialization process
+                PlanetFactory.getPlanet().initialize();
+                
+            } catch (BootstrapException ex) {
+                log.fatal("Roller PlanetFactory bootstrap failed", ex);
+            } catch (PlanetException ex) {
+                log.fatal("Roller PlanetFactory initialization failed", ex);
+            }
         }
         
         log.info("Roller Planet Initialization Complete");
@@ -103,44 +112,4 @@
     public void contextDestroyed(ServletContextEvent sce) {
         PlanetFactory.getPlanet().shutdown();
     }
-    
-    
-    private void setupRuntimeProperties() {
-        // init property manager by loading it
-        PlanetFactory.getPlanet().getPropertiesManager();
-    }
-    
-    
-    /**
-     * Lookup configured URLStrategy from config and plug it in.
-     *
-     * If no URLStrategy can be configured then we bail and spew errors.
-     */
-    private void setupURLStrategy() throws Exception {
-        
-        String urlStratClass = PlanetConfig.getProperty("urlstrategy.classname");
-        if(urlStratClass == null || urlStratClass.trim().length() < 1) {
-            throw new Exception("No URLStrategy configured!!!");
-        }
-        
-        Class stratClass = Class.forName(urlStratClass);
-        URLStrategy urlStrategy = (URLStrategy) stratClass.newInstance();
-        
-        // plug it in
-        PlanetFactory.getPlanet().setURLStrategy(urlStrategy);
-    }        
-    
-    private void upgradeDatabaseIfNeeded() throws PlanetException {
-        
-//        try {
-//            Connection con = // get connection somehow
-//            UpgradeDatabase.upgradeDatabase(con, RollerFactory.getRoller().getVersion());
-//            con.close();
-//        } catch (NamingException e) {
-//            log.warn("Unable to access DataSource", e);
-//        } catch (SQLException e) {
-//            log.warn(e);
-//        }
-    }
-
 }

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/core/filters/PersistenceSessionFilter.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/core/filters/PersistenceSessionFilter.java?view=diff&rev=550055&r1=550054&r2=550055
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/core/filters/PersistenceSessionFilter.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/core/filters/PersistenceSessionFilter.java Sat Jun 23 08:27:55 2007
@@ -58,7 +58,9 @@
             chain.doFilter(request, response);
         } finally {
             log.debug("Releasing Planet Session");
-            planet.release();
+            if (PlanetFactory.isBootstrapped()) {
+                PlanetFactory.getPlanet().release();
+            }
         }
         
         log.debug("Exiting PersistenceSessionFilter");



Mime
View raw message