Re: [easybeans-commits] [4658] trunk/easybeans/modules/core/src/main/java/org/ow2/easybeans/ component/ComponentManager.java: Added debug information.

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: [easybeans-commits] [4658] trunk/easybeans/modules/core/src/main/java/org/ow2/easybeans/ component/ComponentManager.java: Added debug information.

by Florent BENOIT-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
    Hi Vincent,

I have some remarks about this commit :

 - In general, we avoid to do a try {} catch (Exception e) {} on the whole method. We do try /catch on a limited set of lines
so I think we shouldn't add this try {} catch() as it's done in this commit. I assume the exception can only come from the start() method ?


} catch (EZBComponentException ex) {
 logger.error("Component \"" + name + "\" failed to start.");
 throw new EZBComponentException();
}

- I have also a problem on the exception that is thrown again. the root cause is ignored
I assume we should have
     throw new EZBComponentException("Component \"" + name + "\" failed to start.", e);
So we add an additional message without losing the root cause. Else, it's very hard to know from which line we have the error
And we shouldn't log the error here, we should only complete the exception at this step.

Else, we will have the exception printed twice (where you've added the logger.error() and in the class that's calling Embedded.start() class) and I think and this is not a good idea

PS:
On the logger, you can also use the folllowing syntax:
logger.error("Component ''{0}'' failed to start.", componentName);


Regards,

Florent

v.michaud@... wrote:
[4658] trunk/easybeans/modules/core/src/main/java/org/ow2/easybeans/component/ComponentManager.java: Added debug information.
Revision
4658
Author
vmichaud
Date
2009-02-20 01:48:50 +0100 (Fri, 20 Feb 2009)

Log Message

Added debug information.

Modified Paths

Diff

Modified: trunk/easybeans/modules/core/src/main/java/org/ow2/easybeans/component/ComponentManager.java (4657 => 4658)


--- trunk/easybeans/modules/core/src/main/java/org/ow2/easybeans/component/ComponentManager.java	2009-02-20 00:14:25 UTC (rev 4657)
+++ trunk/easybeans/modules/core/src/main/java/org/ow2/easybeans/component/ComponentManager.java	2009-02-20 00:48:50 UTC (rev 4658)
@@ -190,22 +190,29 @@
      */
     public void startComponents() throws EZBComponentException {
 
+        String name = null;
         StringBuilder sb = new StringBuilder();
         sb.append("[ Component(s) started : ");
 
-        // Call init method if any on each component
-        for (String componentName : componentNames) {
-            EZBComponent component = componentRegistry.getComponent(componentName);
-            component.start();
+        try {
+            // Call init method if any on each component
+            for (String componentName : componentNames) {
+                name = componentName;
+                EZBComponent component = componentRegistry.getComponent(componentName);
+                component.start();
 
-            // append the component name
-            String name = component.getClass().getSimpleName();
-            // remove "Component" substring if any
-            if (name.endsWith(COMPONENT_STR)) {
-                name = name.substring(0, name.lastIndexOf(COMPONENT_STR));
+                // append the component name
+                String name = component.getClass().getSimpleName();
+                // remove "Component" substring if any
+                if (name.endsWith(COMPONENT_STR)) {
+                    name = name.substring(0, name.lastIndexOf(COMPONENT_STR));
+                }
+                sb.append(name);
+                sb.append(" ");
             }
-            sb.append(name);
-            sb.append(" ");
+        } catch (EZBComponentException ex) {
+            logger.error("Component \"" + name + "\" failed to start.");
+            throw new EZBComponentException();
         }
 
         sb.append("]");