geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r779332 - /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintEventDispatcher.java
Date Wed, 27 May 2009 21:48:16 GMT
Author: gnodet
Date: Wed May 27 21:48:15 2009
New Revision: 779332

URL: http://svn.apache.org/viewvc?rev=779332&view=rev
Log:
Better logging of blueprint events

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintEventDispatcher.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintEventDispatcher.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintEventDispatcher.java?rev=779332&r1=779331&r2=779332&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintEventDispatcher.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintEventDispatcher.java
Wed May 27 21:48:15 2009
@@ -21,6 +21,7 @@
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.Arrays;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -84,7 +85,9 @@
     }
 
     public void blueprintEvent(final BlueprintEvent event) {
-        LOGGER.debug("Sending blueprint container event {} for bundle {}", event, event.getBundle().getSymbolicName());
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("Sending blueprint container event {} for bundle {}", toString(event),
event.getBundle().getSymbolicName());
+        }
         states.put(event.getBundle(), event);
         executor.submit(new Runnable() {
             public void run() {
@@ -94,6 +97,34 @@
         });
     }
 
+    private String toString(BlueprintEvent event) {
+        return "BlueprintEvent[type=" + getEventType(event.getType())
+                        + (event.getDependencies() != null ? ", dependencies=" + Arrays.asList(event.getDependencies())
: "")
+                        + (event.getException() != null ? ", exception=" + event.getException().getMessage()
: "")
+                        + "]";
+    }
+
+    private String getEventType(int type) {
+        switch (type) {
+            case BlueprintEvent.CREATING:
+                return "CREATING";
+            case BlueprintEvent.CREATED:
+                return "CREATED";
+            case BlueprintEvent.DESTROYING:
+                return "DESTROYING";
+            case BlueprintEvent.DESTROYED:
+                return "DESTROYED";
+            case BlueprintEvent.FAILURE:
+                return "FAILURE";
+            case BlueprintEvent.GRACE_PERIOD:
+                return "GRACE_PERIOD";
+            case BlueprintEvent.WAITING:
+                return "WAITING";
+            default:
+                return "UNKNOWN";
+        }
+    }
+
     private void callListeners(BlueprintEvent event) {
         Object[] listeners = containerListenerTracker.getServices();
         if (listeners != null) {



Mime
View raw message