roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r549324 [1/2] - in /roller/branches/roller_guice: ./ 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/business/jpa/ apps/...
Date Thu, 21 Jun 2007 01:55:20 GMT
Author: snoopdave
Date: Wed Jun 20 18:55:16 2007
New Revision: 549324

URL: http://svn.apache.org/viewvc?view=rev&rev=549324
Log:
Bringing back in sync with trunk, adding minimal support for bootstrap process to Planet

Added:
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/BootstrapException.java
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/DatabaseProvider.java
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/PlanetStartup.java
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/StartupException.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/BootstrapException.java
      - copied unchanged from r549150, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/BootstrapException.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/DatabaseProvider.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/InitializationException.java
      - copied unchanged from r549150, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/InitializationException.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/
      - copied from r549150, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java
      - copied unchanged from r549297, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
      - copied unchanged from r549297, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/DatabaseScriptProvider.java
      - copied unchanged from r549297, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/DatabaseScriptProvider.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java
      - copied unchanged from r549297, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/StartupException.java
      - copied unchanged from r549150, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/StartupException.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java
      - copied, changed from r549150, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/ClasspathDatabaseScriptProvider.java
      - copied unchanged from r549150, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/ClasspathDatabaseScriptProvider.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/DatabaseInstaller.java
      - copied unchanged from r549150, roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/DatabaseInstaller.java
Removed:
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/PlanetDatabaseProvider.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerDatabaseProvider.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/DatabaseCreator.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/DatabaseUpgrader.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/CreateDatabase.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/DatabaseError.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/ServletContextDatabaseScriptProvider.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/UpgradeDatabase.java
    roller/branches/roller_guice/components/core/src/java/org/apache/roller/util/DatabaseProvider.java
    roller/branches/roller_guice/components/core/src/java/org/apache/roller/util/DatabaseProviderException.java
Modified:
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/PlanetFactory.java
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernateConnectionProvider.java
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/hibernate/PlanetModule.java
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPersistenceStrategy.java
    roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/jpa/PlanetModule.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/TestUtils.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/EntryBasicTests.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/GroupBasicTests.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/GroupFunctionalTests.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PlanetBasicTests.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PlanetFunctionalTests.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PropertiesTest.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/RomeFeedFetcherTest.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionBasicTests.java
    roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionFunctionalTests.java
    roller/branches/roller_guice/apps/weblogger/properties.xmlf
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/MailProvider.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/PropertiesManager.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/Roller.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerFactory.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerImpl.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateConnectionProvider.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernatePropertiesManagerImpl.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/RollerModule.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPropertiesManagerImpl.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/RollerModule.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/runnable/ThreadManager.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/runnable/ThreadManagerImpl.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/IndexManager.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/ThemeManager.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/DatabaseScriptProvider.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/SQLScriptRunner.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/planet/business/hibernate/RollerPlanetModule.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/planet/business/jpa/JPARollerPlanetPersistenceStrategy.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/planet/business/jpa/RollerPlanetModule.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerContext.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/filters/BootstrapFilter.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/filters/PersistenceSessionFilter.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Install.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryBean.java
    roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/util/MailUtil.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/BookmarkTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/CommentTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogPlatformTestSuite.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/FileManagerTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/FolderCRUDTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/FolderFunctionalityTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/FolderParentDeletesTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/HitCountTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/PermissionTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/PingsTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/PropertiesTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/RefererTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/SQLScriptRunnerTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/TaskLockTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogCategoryParentDeletesTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogEntryTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogPageTest.java
    roller/branches/roller_guice/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogTest.java
    roller/branches/roller_guice/apps/weblogger/web/WEB-INF/classes/struts.xml
    roller/branches/roller_guice/apps/weblogger/web/WEB-INF/jsps/core/CreateDatabase.jsp
    roller/branches/roller_guice/apps/weblogger/web/WEB-INF/jsps/core/DatabaseError.jsp
    roller/branches/roller_guice/apps/weblogger/web/WEB-INF/tiles.xml
    roller/branches/roller_guice/merges.txt
    roller/branches/roller_guice/tools/roller-core/roller-core.jar
    roller/branches/roller_guice/tools/roller-planet/roller-planet-business.jar

Added: roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/BootstrapException.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/BootstrapException.java?view=auto&rev=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/BootstrapException.java (added)
+++ roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/BootstrapException.java Wed Jun 20 18:55:16 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);
+    }
+    
+}

Added: roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/DatabaseProvider.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/DatabaseProvider.java?view=auto&rev=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/DatabaseProvider.java (added)
+++ roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/DatabaseProvider.java Wed Jun 20 18:55:16 2007
@@ -0,0 +1,206 @@
+/*
+ * 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.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.</p>
+ *
+ *
+ * <p>Reads configuration properties from RollerConfig:</p>
+ * <pre>
+ * # Specify database configuration type of 'jndi' or 'jdbc'
+ * database.configurationType=jndi
+ * 
+ * # For database configuration type 'jndi',this will be used
+ * database.jndi.name=jdbc/rollerdb
+ * 
+ * # For database configuration type of 'jdbc', you MUST override these
+ * database.jdbc.driverClass=
+ * database.jdbc.connectionURL=
+ * database.jdbc.username=
+ * database.jdbc.password=
+ * </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 DataSource dataSource = null;    
+    private String jndiName = null; 
+    
+    private String jdbcDriverClass = null;
+    private String jdbcConnectionURL = null;
+    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.
+     */ 
+    public DatabaseProvider() throws StartupException {
+        
+        String connectionTypeString = 
+                PlanetConfig.getProperty("database.configurationType"); 
+        if ("jdbc".equals(connectionTypeString)) {
+            type = ConfigurationType.JDBC_PROPERTIES;
+        }
+        jndiName =          PlanetConfig.getProperty("database.jndi.name");
+        jdbcDriverClass =   PlanetConfig.getProperty("database.jdbc.driverClass");
+        jdbcConnectionURL = PlanetConfig.getProperty("database.jdbc.connectionURL");
+        jdbcUsername =      PlanetConfig.getProperty("database.jdbc.username");
+        jdbcPassword =      PlanetConfig.getProperty("database.jdbc.password");
+        
+        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(getJdbcDriverClass());
+            } catch (ClassNotFoundException 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);
+            }
+            successMessage("SUCCESS: loaded JDBC driver class [" +getJdbcDriverClass()+ "]");
+            
+            if (getJdbcUsername() != null || getJdbcPassword() != null) {
+                props = new Properties();
+                if (getJdbcUsername() != null) props.put("user", getJdbcUsername());
+                if (getJdbcPassword() != null) props.put("password", getJdbcPassword());
+            }
+            
+        // 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) {
+                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) {
+            String errorMsg = 
+                "ERROR: unable to obtain database connection. "
+               +"Likely problem: bad connection parameters or database unavailable.";
+            errorMessage(errorMsg);
+            throw new StartupException(errorMsg, t, startupLog);
+        }
+    }
+    
+    
+    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 (getType() == ConfigurationType.JDBC_PROPERTIES) {
+            return DriverManager.getConnection(getJdbcConnectionURL(), props);
+        } else {
+            return dataSource.getConnection();
+        }
+    } 
+
+    public ConfigurationType getType() {
+        return type;
+    }
+
+    public String getJndiName() {
+        return jndiName;
+    }
+
+    public String getJdbcDriverClass() {
+        return jdbcDriverClass;
+    }
+
+    public String getJdbcConnectionURL() {
+        return jdbcConnectionURL;
+    }
+
+    public String getJdbcPassword() {
+        return jdbcPassword;
+    }
+
+    public String getJdbcUsername() {
+        return jdbcUsername;
+    }
+
+}

Modified: roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/PlanetFactory.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/PlanetFactory.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/PlanetFactory.java (original)
+++ roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/PlanetFactory.java Wed Jun 20 18:55:16 2007
@@ -23,6 +23,7 @@
 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; 
 
 /**
@@ -32,7 +33,11 @@
     private static Log log = LogFactory.getLog(PlanetFactory.class);
     private static Planet planetInstance = null;
     private static Injector injector = null;       
-            
+    
+    // have we been bootstrapped yet?
+    private static boolean bootstrapped = false;
+    
+    
     /**
      * Let's just be doubling certain this class cannot be instantiated.
      */
@@ -55,13 +60,52 @@
      * Static accessor for the instance of Roller
      */
     public static Planet getPlanet() {
-        return injector.getInstance(Planet.class);
+        if (planetInstance == null) {
+            throw new IllegalStateException("Roller Planet has not been bootstrapped yet");
+        }        
+        return planetInstance;
     }     
     
     /**
-     * TODO_GUICE: elimiate the need for PlanetFactory.getInjector()
+     * Access to Guice injector so that developers can add new injected objects
+     * to Roller, e.g. new managers that are not part of the Roller interface.
      */
     public static Injector getInjector() {
         return injector;
+    }
+    
+    /**
+     * 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/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernateConnectionProvider.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernateConnectionProvider.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernateConnectionProvider.java (original)
+++ roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernateConnectionProvider.java Wed Jun 20 18:55:16 2007
@@ -5,8 +5,7 @@
 import java.util.Properties;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.planet.business.PlanetFactory;
-import org.apache.roller.util.DatabaseProvider;
+import org.apache.roller.planet.business.startup.PlanetStartup;
 import org.hibernate.HibernateException;
 import org.hibernate.connection.ConnectionProvider;
 
@@ -19,16 +18,14 @@
  */
 public class HibernateConnectionProvider implements ConnectionProvider {
     private static Log log = LogFactory.getLog(HibernateConnectionProvider.class);
-    private DatabaseProvider databaseProvider = null;
     
     /** No-op: we get our configuration from Roller's DatabaseProvider */
     public void configure(Properties properties) throws HibernateException {
-        databaseProvider = PlanetFactory.getInjector().getInstance(DatabaseProvider.class);
     }
 
     /** Get connecetion from Roller's Database provider */
     public Connection getConnection() throws SQLException {
-        return databaseProvider.getConnection();
+        return PlanetStartup.getDatabaseProvider().getConnection();
     }
 
     /** Close connection by calling connection.close() */

Modified: roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/hibernate/PlanetModule.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/hibernate/PlanetModule.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/hibernate/PlanetModule.java (original)
+++ roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/hibernate/PlanetModule.java Wed Jun 20 18:55:16 2007
@@ -21,10 +21,8 @@
 import com.google.inject.Binder;
 import com.google.inject.Module;
 import org.apache.roller.planet.business.Planet;
-import org.apache.roller.planet.business.PlanetDatabaseProvider;
 import org.apache.roller.planet.business.PlanetManager;
 import org.apache.roller.planet.business.PropertiesManager;
-import org.apache.roller.util.DatabaseProvider;
 
 
 /**
@@ -34,8 +32,6 @@
 
     public void configure(Binder binder) {
         
-        binder.bind(DatabaseProvider.class).to(PlanetDatabaseProvider.class);
-
         binder.bind(Planet.class).to(HibernatePlanetImpl.class);
         
         binder.bind(HibernatePersistenceStrategy.class); 

Modified: roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPersistenceStrategy.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPersistenceStrategy.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPersistenceStrategy.java (original)
+++ roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/jpa/JPAPersistenceStrategy.java Wed Jun 20 18:55:16 2007
@@ -36,8 +36,9 @@
 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;
-import org.apache.roller.util.DatabaseProvider;
 
 
 /**
@@ -63,12 +64,10 @@
      * Construct by finding JPA EntityManagerFactory.
      * @throws org.apache.roller.PlanetException on any error
      */
-    @com.google.inject.Inject 
-    public JPAPersistenceStrategy(DatabaseProvider dbProvider) throws PlanetException { 
-       init(dbProvider);
-    }
-    
-    protected void init(DatabaseProvider dbProvider) throws PlanetException {
+    public JPAPersistenceStrategy() throws PlanetException { 
+
+        DatabaseProvider dbProvider = PlanetStartup.getDatabaseProvider();
+        
         // Pull in any properties defined in JMAEMF.properties config file
         Properties emfProps = loadPropertiesFromResourceName(
            "JPAEMF.properties", getContextClassLoader());

Modified: roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/jpa/PlanetModule.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/jpa/PlanetModule.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/jpa/PlanetModule.java (original)
+++ roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/jpa/PlanetModule.java Wed Jun 20 18:55:16 2007
@@ -21,11 +21,8 @@
 import com.google.inject.Binder;
 import com.google.inject.Module;
 import org.apache.roller.planet.business.Planet;
-import org.apache.roller.planet.business.PlanetDatabaseProvider;
 import org.apache.roller.planet.business.PlanetManager;
 import org.apache.roller.planet.business.PropertiesManager;
-import org.apache.roller.util.DatabaseProvider;
-
 
 /**
  * Guice module for configuring JPA as Roller-backend.
@@ -33,8 +30,6 @@
 public class PlanetModule implements Module {
 
     public void configure(Binder binder) {
-        
-        binder.bind(DatabaseProvider.class).to(PlanetDatabaseProvider.class);
 
         binder.bind(Planet.class).to(JPAPlanetImpl.class);
         

Added: roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/PlanetStartup.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/PlanetStartup.java?view=auto&rev=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/PlanetStartup.java (added)
+++ roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/PlanetStartup.java Wed Jun 20 18:55:16 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/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/StartupException.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/StartupException.java?view=auto&rev=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/StartupException.java (added)
+++ roller/branches/roller_guice/apps/planet/src/java/org/apache/roller/planet/business/startup/StartupException.java Wed Jun 20 18:55:16 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/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/TestUtils.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/TestUtils.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/TestUtils.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/TestUtils.java Wed Jun 20 18:55:16 2007
@@ -18,9 +18,9 @@
 
 package org.apache.roller.planet;
 
-import org.apache.roller.planet.PlanetException;
 import org.apache.roller.planet.business.PlanetFactory;
 import org.apache.roller.planet.business.PlanetManager;
+import org.apache.roller.planet.business.startup.PlanetStartup;
 import org.apache.roller.planet.pojos.PlanetData;
 import org.apache.roller.planet.pojos.PlanetEntryData;
 import org.apache.roller.planet.pojos.PlanetGroupData;
@@ -31,6 +31,30 @@
  * Utility class for unit test classes.
  */
 public final class TestUtils {
+    
+    
+    public static void setupPlanet() throws Exception {
+        
+        if(!PlanetFactory.isBootstrapped()) {
+            
+            // do core services preparation
+            PlanetStartup.prepare();
+            
+            // do application bootstrapping
+            PlanetFactory.bootstrap();
+            
+            // always initialize the properties manager and flush
+            //PlanetFactory.getPlanet().getPropertiesManager().initialize();
+            PlanetFactory.getPlanet().flush();
+        }
+    }
+    
+    
+    public static void shutdownPlanet() throws Exception {
+        
+        // trigger shutdown
+        PlanetFactory.getPlanet().shutdown();
+    }
     
     
     /**

Modified: roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/EntryBasicTests.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/EntryBasicTests.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/EntryBasicTests.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/EntryBasicTests.java Wed Jun 20 18:55:16 2007
@@ -32,6 +32,9 @@
     
     
     protected void setUp() throws Exception {
+        // setup planet
+        TestUtils.setupPlanet();
+        
         testSub = TestUtils.setupSubscription("entryBasicTest");
     }
     

Modified: roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java Wed Jun 20 18:55:16 2007
@@ -44,6 +44,9 @@
     
     
     protected void setUp() throws Exception {
+        // setup planet
+        TestUtils.setupPlanet();
+
         log.info("ENTERED");
         
         testPlanet = TestUtils.setupPlanet("entryFuncTestPlanet");

Modified: roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/GroupBasicTests.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/GroupBasicTests.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/GroupBasicTests.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/GroupBasicTests.java Wed Jun 20 18:55:16 2007
@@ -32,6 +32,9 @@
     
     
     protected void setUp() throws Exception {
+        // setup planet
+        TestUtils.setupPlanet();
+
         testPlanet = TestUtils.setupPlanet("groupBasicTest");
     }
     

Modified: roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/GroupFunctionalTests.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/GroupFunctionalTests.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/GroupFunctionalTests.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/GroupFunctionalTests.java Wed Jun 20 18:55:16 2007
@@ -34,6 +34,9 @@
     
     
     protected void setUp() throws Exception {
+        // setup planet
+        TestUtils.setupPlanet();
+
         testPlanet = TestUtils.setupPlanet("groupFuncTest");
         testGroup1 = TestUtils.setupGroup(testPlanet, "groupFuncTest1");
         testGroup2 = TestUtils.setupGroup(testPlanet, "groupFuncTest2");

Modified: roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PlanetBasicTests.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PlanetBasicTests.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PlanetBasicTests.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PlanetBasicTests.java Wed Jun 20 18:55:16 2007
@@ -34,6 +34,9 @@
     
     public void testPlanetCRUD() throws Exception {
         
+        // setup planet
+        TestUtils.setupPlanet();
+
         PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
         
         PlanetData testPlanet = new PlanetData("testPlanet", "testPlanet", "testPlanet");

Modified: roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PlanetFunctionalTests.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PlanetFunctionalTests.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PlanetFunctionalTests.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PlanetFunctionalTests.java Wed Jun 20 18:55:16 2007
@@ -35,6 +35,9 @@
     
     
     protected void setUp() throws Exception {
+        // setup planet
+        TestUtils.setupPlanet();
+
         testPlanet = TestUtils.setupPlanet("planetFuncTest");
     }
     

Modified: roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PropertiesTest.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PropertiesTest.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PropertiesTest.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/PropertiesTest.java Wed Jun 20 18:55:16 2007
@@ -38,7 +38,11 @@
     public static Log log = LogFactory.getLog(PropertiesTest.class);
     
     
-    public void setUp() throws Exception {}
+    public void setUp() throws Exception {
+        // setup planet
+        TestUtils.setupPlanet();
+
+    }
     
     public void tearDown() throws Exception {}
     

Modified: roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/RomeFeedFetcherTest.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/RomeFeedFetcherTest.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/RomeFeedFetcherTest.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/RomeFeedFetcherTest.java Wed Jun 20 18:55:16 2007
@@ -41,6 +41,9 @@
     
     
     protected void setUp() throws Exception {
+        // setup planet
+        TestUtils.setupPlanet();
+
         testPlanet = TestUtils.setupPlanet("fetcherTestPlanet");
         testGroup = TestUtils.setupGroup(testPlanet, "fetcherTestGroup");
         

Modified: roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionBasicTests.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionBasicTests.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionBasicTests.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionBasicTests.java Wed Jun 20 18:55:16 2007
@@ -29,6 +29,9 @@
     
     public void testSubscriptionCRUD() throws Exception {
         
+        // setup planet
+        TestUtils.setupPlanet();
+
         PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
         
         PlanetSubscriptionData testSub = new PlanetSubscriptionData();

Modified: roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionFunctionalTests.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionFunctionalTests.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionFunctionalTests.java (original)
+++ roller/branches/roller_guice/apps/planet/test/java/org/apache/roller/planet/business/SubscriptionFunctionalTests.java Wed Jun 20 18:55:16 2007
@@ -37,6 +37,9 @@
     
     
     protected void setUp() throws Exception {
+        // setup planet
+        TestUtils.setupPlanet();
+
         testPlanet = TestUtils.setupPlanet("subFuncTest");
         testGroup1 = TestUtils.setupGroup(testPlanet, "subFuncTest1");
         testGroup2 = TestUtils.setupGroup(testPlanet, "subFuncTest2");

Modified: roller/branches/roller_guice/apps/weblogger/properties.xmlf
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/properties.xmlf?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/properties.xmlf (original)
+++ roller/branches/roller_guice/apps/weblogger/properties.xmlf Wed Jun 20 18:55:16 2007
@@ -47,7 +47,7 @@
 <property name="build.dist.apache"   value="${build.dist}/apache"/>
 <property name="build.dist.binary"   value="${build.dist}/apache-roller-${ro.version}"/>
 <property name="build.dist.sources"  value="${build.dist}/apache-roller-src-${ro.version}"/>
-<property name="build.dbscripts"     value="${build.webapp}/WEB-INF/dbscripts"/>
+<property name="build.dbscripts"     value="${build.webapp}/WEB-INF/classes/dbscripts"/>
 <property name="build.tests"         value="${ro.build}/tests"/>
 <property name="build.reports"       value="${build.tests}/reports"/>
 <property name="build.docs"          value="${ro.build}/docs"/>

Added: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/DatabaseProvider.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/DatabaseProvider.java?view=auto&rev=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/DatabaseProvider.java (added)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/DatabaseProvider.java Wed Jun 20 18:55:16 2007
@@ -0,0 +1,207 @@
+/*
+ * 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.weblogger.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.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.startup.StartupException;
+import org.apache.roller.weblogger.config.RollerConfig;
+
+
+/**
+ * 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.</p>
+ *
+ *
+ * <p>Reads configuration properties from RollerConfig:</p>
+ * <pre>
+ * # Specify database configuration type of 'jndi' or 'jdbc'
+ * database.configurationType=jndi
+ * 
+ * # For database configuration type 'jndi',this will be used
+ * database.jndi.name=jdbc/rollerdb
+ * 
+ * # For database configuration type of 'jdbc', you MUST override these
+ * database.jdbc.driverClass=
+ * database.jdbc.connectionURL=
+ * database.jdbc.username=
+ * database.jdbc.password=
+ * </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 DataSource dataSource = null;    
+    private String jndiName = null; 
+    
+    private String jdbcDriverClass = null;
+    private String jdbcConnectionURL = null;
+    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.
+     */ 
+    public DatabaseProvider() throws StartupException {
+        
+        String connectionTypeString = 
+                RollerConfig.getProperty("database.configurationType"); 
+        if ("jdbc".equals(connectionTypeString)) {
+            type = ConfigurationType.JDBC_PROPERTIES;
+        }
+        jndiName =          RollerConfig.getProperty("database.jndi.name");
+        jdbcDriverClass =   RollerConfig.getProperty("database.jdbc.driverClass");
+        jdbcConnectionURL = RollerConfig.getProperty("database.jdbc.connectionURL");
+        jdbcUsername =      RollerConfig.getProperty("database.jdbc.username");
+        jdbcPassword =      RollerConfig.getProperty("database.jdbc.password");
+        
+        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(getJdbcDriverClass());
+            } catch (ClassNotFoundException 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);
+            }
+            successMessage("SUCCESS: loaded JDBC driver class [" +getJdbcDriverClass()+ "]");
+            
+            if (getJdbcUsername() != null || getJdbcPassword() != null) {
+                props = new Properties();
+                if (getJdbcUsername() != null) props.put("user", getJdbcUsername());
+                if (getJdbcPassword() != null) props.put("password", getJdbcPassword());
+            }
+            
+        // 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) {
+                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) {
+            String errorMsg = 
+                "ERROR: unable to obtain database connection. "
+               +"Likely problem: bad connection parameters or database unavailable.";
+            errorMessage(errorMsg);
+            throw new StartupException(errorMsg, t, startupLog);
+        }
+    }
+    
+    
+    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 (getType() == ConfigurationType.JDBC_PROPERTIES) {
+            return DriverManager.getConnection(getJdbcConnectionURL(), props);
+        } else {
+            return dataSource.getConnection();
+        }
+    } 
+
+    public ConfigurationType getType() {
+        return type;
+    }
+
+    public String getJndiName() {
+        return jndiName;
+    }
+
+    public String getJdbcDriverClass() {
+        return jdbcDriverClass;
+    }
+
+    public String getJdbcConnectionURL() {
+        return jdbcConnectionURL;
+    }
+
+    public String getJdbcPassword() {
+        return jdbcPassword;
+    }
+
+    public String getJdbcUsername() {
+        return jdbcUsername;
+    }
+
+}

Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/MailProvider.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/MailProvider.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/MailProvider.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/MailProvider.java Wed Jun 20 18:55:16 2007
@@ -28,7 +28,7 @@
 import javax.naming.NamingException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.startup.StartupException;
 import org.apache.roller.weblogger.config.RollerConfig;
 
 
@@ -41,8 +41,6 @@
     
     private enum ConfigurationType {JNDI_NAME, MAIL_PROPERTIES; }
     
-    private static MailProvider singletonInstance = null;
-    
     private Session session = null;
     
     private ConfigurationType type = ConfigurationType.JNDI_NAME;
@@ -53,9 +51,9 @@
     private String mailUsername = null;
     private String mailPassword = null;
 
+    
+    public MailProvider() throws StartupException {
         
-    /** Creates a new instance of MailProvider */
-    public MailProvider() throws WebloggerException {
         String connectionTypeString = RollerConfig.getProperty("mail.configurationType"); 
         if ("properties".equals(connectionTypeString)) {
             type = ConfigurationType.MAIL_PROPERTIES;
@@ -77,7 +75,7 @@
                 Context ctx = (Context) new InitialContext();
                 session = (Session) ctx.lookup(name);
             } catch (NamingException ex) {
-                throw new WebloggerException("ERROR looking up mail-session with JNDI name: " + name);
+                throw new StartupException("ERROR looking up mail-session with JNDI name: " + name);
             }
         } else {
             Properties props = new Properties();
@@ -86,35 +84,32 @@
             if (mailPort != -1) props.put("mail.smtp.port", ""+mailPort);
             session = Session.getDefaultInstance(props, null);
         }
+        
         try {
             Transport transport = getTransport();
             transport.close();
         } catch (Throwable t) {
-            throw new WebloggerException("ERROR connecting to mail server", t);
+            throw new StartupException("ERROR connecting to mail server", t);
         }
         
     }
     
-    public static MailProvider getMailProvider() throws WebloggerException {
-        if (singletonInstance == null) {
-            singletonInstance = new MailProvider();
-        }
-        return singletonInstance;
-    }   
-    
-    public static boolean isMailConfigured() {
-        return singletonInstance != null;
-    }
     
+    /**
+     * Get a mail Session.
+     */
     public Session getSession() {
         return session;
     }
     
+    
     /**
      * Create and connect to transport, caller is responsible for closing transport.
      */
     public Transport getTransport() throws NoSuchProviderException, MessagingException {
+        
         Transport transport = null;
+        
         if (type == ConfigurationType.MAIL_PROPERTIES) {
             // Configure transport ourselves using mail properties
             transport = session.getTransport("smtp"); 
@@ -128,6 +123,8 @@
             transport = session.getTransport(); 
             transport.connect();
         }
+        
         return transport;
     }
+    
 }

Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/PropertiesManager.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/PropertiesManager.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/PropertiesManager.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/PropertiesManager.java Wed Jun 20 18:55:16 2007
@@ -1,24 +1,19 @@
 /*
-* 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.
-*/
-/*
- * PropertiesManager.java
+ * 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
  *
- * Created on April 21, 2005, 10:34 AM
+ *     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.weblogger.business;
@@ -34,31 +29,39 @@
 public interface PropertiesManager {
     
     /**
+     * Initialize the properties manager.
+     *
+     * @throws InitializationException If there is a problem during initialization.
+     */
+    public void initialize() throws InitializationException;
+    
+    
+    /**
      * Release all resources associated with Roller session.
      */
     public void release();
     
     
-    /** 
-     * Save a single property 
+    /**
+     * Save a single property
      */
     public void saveProperty(RuntimeConfigProperty property) throws WebloggerException;
     
     
-    /** 
-     * Save a list of properties 
+    /**
+     * Save a list of properties
      */
     public void saveProperties(Map properties) throws WebloggerException;
     
     
-    /** 
-     * Retrieve a single property by name 
+    /**
+     * Retrieve a single property by name
      */
     public RuntimeConfigProperty getProperty(String name) throws WebloggerException;
     
     
-    /** 
-     * Retrieve a list of all properties 
+    /**
+     * Retrieve a list of all properties
      */
     public Map getProperties() throws WebloggerException;
     

Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/Roller.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/Roller.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/Roller.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/Roller.java Wed Jun 20 18:55:16 2007
@@ -18,10 +18,8 @@
 
 package org.apache.roller.weblogger.business;
 
-import org.apache.roller.weblogger.business.plugins.PluginManager;
-import java.io.Serializable;
-import java.sql.Connection;
 import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.plugins.PluginManager;
 import org.apache.roller.weblogger.business.pings.AutoPingManager;
 import org.apache.roller.weblogger.business.pings.PingQueueManager;
 import org.apache.roller.weblogger.business.pings.PingTargetManager;
@@ -135,9 +133,16 @@
     
     
     /**
+     * Initialize any resources necessary for this instance of Roller.
+     */
+    public void initialize() throws InitializationException;
+    
+    
+    /**
      * Release all resources necessary for this instance of Roller.
      */
     public void shutdown();
+    
     
     /** Roller version */
     public String getVersion();    

Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerFactory.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerFactory.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerFactory.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerFactory.java Wed Jun 20 18:55:16 2007
@@ -24,22 +24,22 @@
 import com.google.inject.Module;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.weblogger.WebloggerException;
-import org.apache.roller.weblogger.business.utils.DatabaseCreator;
-import org.apache.roller.weblogger.business.utils.DatabaseUpgrader;
-import org.apache.roller.weblogger.config.PingConfig;
+import org.apache.roller.weblogger.business.startup.WebloggerStartup;
 import org.apache.roller.weblogger.config.RollerConfig;
 
 
 /**
  * Provides access to the Roller instance.
  */
-public abstract class RollerFactory implements Module {
-    private static Log log = LogFactory.getLog(RollerFactory.class);
-    private static Injector injector = null;
+public final class RollerFactory {
+    
+    private static final Log log = LogFactory.getLog(RollerFactory.class);
+    
+    // a reference to the bootstrapped Roller instance
     private static Roller rollerInstance = null;
-    private static boolean bootstrapped = false;
     
+    private static Injector injector = null;
+  
     
     static {
         String moduleClassname = RollerConfig.getProperty("guice.backend.module");
@@ -51,16 +51,37 @@
             // Fatal misconfiguration, cannot recover
             throw new RuntimeException("Error instantiating backend module" + moduleClassname, e);
         }
+    } 
+    
+    
+    // non-instantiable
+    private RollerFactory() {
+        // hello all you beautiful people
     }
     
     
     /**
-     * True if bootstrap process was completed
+     * True if bootstrap process was completed, False otherwise.
      */
     public static boolean isBootstrapped() {
-        return bootstrapped;
+        return (rollerInstance != null);
+    }
+    
+    
+    /**
+     * Accessor to the Roller Weblogger business tier.
+     *
+     * @return Roller An instance of Roller.
+     * @throws IllegalStateException If the app has not been properly bootstrapped yet.
+     */
+    public static final Roller getRoller() {
+        if(rollerInstance == null) {
+            throw new IllegalStateException("Roller Weblogger has not been bootstrapped yet");
+        }        
+        return rollerInstance;
     }
     
+    
     /**
      * Access to Guice injector so that developers can add new injected objects
      * to Roller, e.g. new managers that are not part of the Roller interface.
@@ -72,62 +93,27 @@
     
     /**
      * Bootstrap the Roller Weblogger 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 WebloggerException {
+    public static final void bootstrap() throws BootstrapException {
         
-        if ("manual".equals(RollerConfig.getProperty("installation.type"))) {
-            if (DatabaseCreator.isCreationRequired()
-            || DatabaseUpgrader.isUpgradeRequired()) {
-                return;
-            }
+        // if the app hasn't been properly started so far then bail
+        if (!WebloggerStartup.isPrepared()) {
+            throw new IllegalStateException("Cannot bootstrap until application has been properly prepared");
         }
         
-        // This will cause instantiation and initialziation of Roller impl
-        Roller roller = getRoller();
-        
-        // TODO: this initialization process should probably be controlled by
-        // a more generalized application lifecycle event framework
-        
-        // Now that Roller has been instantiated, initialize individual managers
-        roller.getPropertiesManager();
-        roller.getIndexManager();
-        roller.getThemeManager();
-        
-        // And this will schedule all configured tasks
-        roller.getThreadManager().startTasks();
-        
-        // Initialize ping systems
-        try {
-            // Initialize common targets from the configuration
-            PingConfig.initializeCommonTargets();
-            
-            // Initialize ping variants
-            PingConfig.initializePingVariants();
-            
-            // Remove custom ping targets if they have been disallowed
-            if (PingConfig.getDisallowCustomTargets()) {
-                log.info("Custom ping targets have been disallowed.  Removing any existing custom targets.");
-                RollerFactory.getRoller().getPingTargetManager().removeAllCustomPingTargets();
-            }
-            
-            // Remove all autoping configurations if ping usage has been disabled.
-            if (PingConfig.getDisablePingUsage()) {
-                log.info("Ping usage has been disabled.  Removing any existing auto ping configurations.");
-                RollerFactory.getRoller().getAutopingManager().removeAllAutoPings();
-            }
-            
-            RollerFactory.getRoller().getIndexManager().bootstrap();
+        log.info("Bootstrapping Roller Weblogger business tier");
             
-        } catch (WebloggerException e) {
-            log.error("ERROR configing ping managers", e);
-        }
-        
-        bootstrapped = true;
-    }
-    
-    public static Roller getRoller() {
-        return injector.getInstance(Roller.class);
+        // do the invocation
+        rollerInstance = injector.getInstance(Roller.class);
+                   
+        log.info("Roller Weblogger business tier successfully bootstrapped");
     }
-    
-}
 
+}

Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerImpl.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerImpl.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/RollerImpl.java Wed Jun 20 18:55:16 2007
@@ -34,6 +34,7 @@
 import org.apache.roller.weblogger.business.search.IndexManager;
 import org.apache.roller.weblogger.business.runnable.ThreadManager;
 import org.apache.roller.weblogger.business.themes.ThemeManager;
+import org.apache.roller.weblogger.config.PingConfig;
 
 /**
  * The abstract version of the Roller implementation.
@@ -236,6 +237,57 @@
         } catch(Throwable e) {
             mLogger.error("Error calling Roller.release()", e);
         }
+    }
+    
+    
+    /**
+     * @inheritDoc
+     */
+    public void initialize() throws InitializationException {
+        
+        mLogger.info("Initializing Roller Weblogger business tier");
+        
+        // TODO: this should probably be done in a more uniform fashion, possibly
+        // using annotations?  biggest issue is controlling ordering
+        getPropertiesManager().initialize();
+        getThemeManager().initialize();
+        getThreadManager().initialize();
+        getIndexManager().initialize();
+        
+        try {
+            // Initialize ping systems
+            // TODO: this should probably be moving inside ping manager initialize() methods?
+            
+            // Initialize common targets from the configuration
+            PingConfig.initializeCommonTargets();
+            
+            // Initialize ping variants
+            PingConfig.initializePingVariants();
+            
+            // Remove custom ping targets if they have been disallowed
+            if (PingConfig.getDisallowCustomTargets()) {
+                mLogger.info("Custom ping targets have been disallowed.  Removing any existing custom targets.");
+                RollerFactory.getRoller().getPingTargetManager().removeAllCustomPingTargets();
+            }
+            
+            // Remove all autoping configurations if ping usage has been disabled.
+            if (PingConfig.getDisablePingUsage()) {
+                mLogger.info("Ping usage has been disabled.  Removing any existing auto ping configurations.");
+                RollerFactory.getRoller().getAutopingManager().removeAllAutoPings();
+            }
+        } catch (Throwable t) {
+            throw new InitializationException("Error initializing ping systems", t);
+        }
+        
+        // we always need to do a flush after initialization because it's
+        // possible that some changes need to be persisted
+        try {
+            flush();
+        } catch(WebloggerException ex) {
+            throw new InitializationException("Error flushing after initialization", ex);
+        }
+        
+        mLogger.info("Roller Weblogger business tier successfully initialized");
     }
     
     

Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateConnectionProvider.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateConnectionProvider.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateConnectionProvider.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateConnectionProvider.java Wed Jun 20 18:55:16 2007
@@ -5,8 +5,7 @@
 import java.util.Properties;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.util.DatabaseProvider;
-import org.apache.roller.weblogger.business.RollerFactory;
+import org.apache.roller.weblogger.business.startup.WebloggerStartup;
 import org.hibernate.HibernateException;
 import org.hibernate.connection.ConnectionProvider;
 
@@ -19,17 +18,14 @@
  */
 public class HibernateConnectionProvider implements ConnectionProvider {
     private static Log log = LogFactory.getLog(HibernateConnectionProvider.class);
-    private DatabaseProvider databaseProvider = null;
     
     /** No-op: we get our configuration from Roller's DatabaseProvider */
     public void configure(Properties properties) throws HibernateException {
-        // This class is created by Hibermate, so we do self-injection here
-        databaseProvider = RollerFactory.getInjector().getInstance(DatabaseProvider.class);
     }
 
     /** Get connecetion from Roller's Database provider */
     public Connection getConnection() throws SQLException {
-        return databaseProvider.getConnection();
+        return WebloggerStartup.getDatabaseProvider().getConnection();
     }
 
     /** Close connection by calling connection.close() */

Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernatePropertiesManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernatePropertiesManagerImpl.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernatePropertiesManagerImpl.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernatePropertiesManagerImpl.java Wed Jun 20 18:55:16 2007
@@ -28,6 +28,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.InitializationException;
 import org.apache.roller.weblogger.config.RollerRuntimeConfig;
 import org.apache.roller.weblogger.config.runtime.ConfigDef;
 import org.apache.roller.weblogger.config.runtime.DisplayGroup;
@@ -61,9 +62,29 @@
         log.debug("Instantiating Hibernate Properties Manager");
         this.roller = roller;        
         this.strategy = strat;
+    }
+    
+    
+    /**
+     * @inheritDoc
+     */
+    public void initialize() throws InitializationException {
+        
+        Map props = null;
+        try {
+            props = this.getProperties();
+            
+            // check for new props
+            props = initializeMissingProps(props);
+            
+            // save our changes
+            this.saveProperties(props);
+        } catch (Exception e) {
+            log.fatal("Failed to initialize runtime configuration properties."+
+                    "Please check that the database has been upgraded!", e);
+            throw new RuntimeException(e);
+        }
         
-        // TODO: and new method initialize(props)
-        init();
     }
     
     
@@ -135,25 +156,6 @@
         while (props.hasNext()) {
             this.strategy.store((RuntimeConfigProperty) props.next());
         }
-    }
-
-    
-    private void init() {
-        Map props = null;
-        try {
-            props = this.getProperties();
-            
-            // check for new props
-            props = initializeMissingProps(props);
-            
-            // save our changes
-            this.saveProperties(props);
-        } catch (Exception e) {
-            log.fatal("Failed to initialize runtime configuration properties."+
-                    "Please check that the database has been upgraded!", e);
-            throw new RuntimeException(e);
-        }
-        
     }
     
     

Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/RollerModule.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/RollerModule.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/RollerModule.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/RollerModule.java Wed Jun 20 18:55:16 2007
@@ -20,13 +20,11 @@
 
 import com.google.inject.Binder;
 import com.google.inject.Module;
-import org.apache.roller.util.DatabaseProvider;
 import org.apache.roller.weblogger.business.BookmarkManager;
 import org.apache.roller.weblogger.business.FileManager;
 import org.apache.roller.weblogger.business.FileManagerImpl;
 import org.apache.roller.weblogger.business.PropertiesManager;
 import org.apache.roller.weblogger.business.Roller;
-import org.apache.roller.weblogger.business.RollerDatabaseProvider;
 import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.weblogger.business.pings.AutoPingManager;
@@ -50,8 +48,6 @@
 public class RollerModule implements Module {
     
     public void configure(Binder binder) {
-        
-        binder.bind(DatabaseProvider.class).to(RollerDatabaseProvider.class);
         
         binder.bind(Roller.class).to(HibernateRollerImpl.class);
         

Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.java?view=diff&rev=549324&r1=549323&r2=549324
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.java Wed Jun 20 18:55:16 2007
@@ -30,13 +30,13 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.config.RollerConfig;
-import org.apache.roller.util.DatabaseProvider;
 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.weblogger.business.DatabaseProvider;
 
 
 /**



Mime
View raw message