You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2014/10/21 06:52:29 UTC

git commit: a print utility method for LifeCycleStateManager

Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping 06e1e9ffb -> 9b31646b1


a print utility method for LifeCycleStateManager


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/9b31646b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/9b31646b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/9b31646b

Branch: refs/heads/4.0.0-grouping
Commit: 9b31646b176601edf8f78c3bac89597103cbb347
Parents: 06e1e9f
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Tue Oct 21 10:21:52 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Tue Oct 21 10:22:08 2014 +0530

----------------------------------------------------------------------
 .../lifecycle/LifeCycleStateManager.java        | 28 +++++++++++++-------
 1 file changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/9b31646b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java
index c52d7a2..0f627a8 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java
@@ -59,15 +59,7 @@ public class LifeCycleStateManager<T extends LifeCycleState> implements Serializ
      * @return true if transitioning for nextState from current state is valid, else false
      */
     public boolean isStateTransitionValid (T nextState) {
-        if (log.isDebugEnabled()) {
-            // print all transitions till now
-            StringBuilder stateTransitions = new StringBuilder("Transitioned States:  [ START --> ");
-            for (int i = 0 ; i < stateStack.size() ; i++) {
-                stateTransitions.append(stateStack.get(i) + " --> ");
-            }
-            stateTransitions.append(" END ]");
-            log.debug(stateTransitions);
-        }
+
         return stateStack.peek().getNextStates().contains(nextState);
     }
 
@@ -77,7 +69,11 @@ public class LifeCycleStateManager<T extends LifeCycleState> implements Serializ
      * @param nextState
      */
     public void changeState (T nextState)  {
+
         stateStack.push(nextState);
+        if (log.isDebugEnabled()) {
+            printStateTransitions(stateStack);
+        }
         log.info("Life Cycle State changed from [ " + getPreviousState() + " ] to [ " +
                 getCurrentState() + " ]");
     }
@@ -108,4 +104,18 @@ public class LifeCycleStateManager<T extends LifeCycleState> implements Serializ
     public T getPreviousState () {
         return stateStack.get(1);
     }
+
+    /**
+     * Print utility to print transitioned states
+     */
+    private static <T extends LifeCycleState> void printStateTransitions (Stack<T> stateStack) {
+
+        // print all transitions till now
+        StringBuilder stateTransitions = new StringBuilder("Transitioned States:  [ START --> ");
+        for (int i = 0 ; i < stateStack.size() ; i++) {
+            stateTransitions.append(stateStack.get(i) + " --> ");
+        }
+        stateTransitions.append(" END ]");
+        log.debug(stateTransitions);
+    }
 }