incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1235739 - /sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/serversetup/ServerSetup.java
Date Wed, 25 Jan 2012 13:32:31 GMT
Author: bdelacretaz
Date: Wed Jan 25 13:32:31 2012
New Revision: 1235739

URL: http://svn.apache.org/viewvc?rev=1235739&view=rev
Log:
SLING-2368 - improved logging and detection of failed phases

Modified:
    sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/serversetup/ServerSetup.java

Modified: sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/serversetup/ServerSetup.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/serversetup/ServerSetup.java?rev=1235739&r1=1235738&r2=1235739&view=diff
==============================================================================
--- sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/serversetup/ServerSetup.java
(original)
+++ sling/trunk/testing/tools/src/main/java/org/apache/sling/testing/tools/serversetup/ServerSetup.java
Wed Jan 25 13:32:31 2012
@@ -125,9 +125,15 @@ public class ServerSetup {
      *  setup phases that have not run yet.
      */
     public synchronized void setupTestServer() throws Exception {
-        // If any phases failed, we're doomed
-        if(!failedPhases.isEmpty()) {
-            throw new SetupException("Some SetupPhases previously failed: " + failedPhases);
+        
+        // On the first call, list our available phases
+        if(donePhases.isEmpty()) {
+            if(log.isInfoEnabled()) {
+                final List<String> ids = new ArrayList<String>();
+                ids.addAll(phases.keySet());
+                Collections.sort(ids);
+                log.info("Will run SetupPhases {} out of {}", phasesToRun, ids);
+            }
         }
         
         // Run all startup phases that didn't run yet
@@ -151,8 +157,15 @@ public class ServerSetup {
     }
     
     /** Run phases that haven't run yet */
-    private void runRemainingPhases(boolean startup) throws Exception {
-        final String mode = startup ? "startup" : "shutdown";
+    private void runRemainingPhases(boolean isStartup) throws Exception {
+        final String mode = isStartup ? "startup" : "shutdown";
+        
+        // In startup mode, fail if any phases failed previously
+        // (in shutdown mode it's probably safer to try to run cleanup phases)
+        if(isStartup && !failedPhases.isEmpty()) {
+            throw new SetupException("Some SetupPhases previously failed: " + failedPhases);
+        }
+        
         for(String id : phasesToRun) {
             final SetupPhase p = phases.get(id);
             
@@ -167,9 +180,8 @@ public class ServerSetup {
                 continue;
             }
             
-            if(p.isStartupPhase() == startup) {
-                log.info("Executing ({}) {}:{}", 
-                        new Object [] { mode, p.getClass().getSimpleName(), p});
+            if(p.isStartupPhase() == isStartup) {
+                log.info("Executing {} phase: {}", mode, p); 
                 try {
                     p.run(this);
                 } catch(Exception e) {



Mime
View raw message