You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/03/16 08:12:09 UTC

svn commit: r923594 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/ main/java/org/apache/camel/management/ main/java/org/apache/camel/management/event/ main/java/org/apache/camel/spi/ main/java/org/apache/camel/util/ test/java/org/ap...

Author: davsclaus
Date: Tue Mar 16 07:12:09 2010
New Revision: 923594

URL: http://svn.apache.org/viewvc?rev=923594&view=rev
Log:
CAMEL-1588: More robust shutdown by catching Throwable instead of Exception. Polished messages being logged.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SharedProducerServicePool.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultEventFactory.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/CamelContextStartupFailureEvent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/CamelContextStopFailureEvent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ServiceStartupFailureEvent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ServiceStopFailureEvent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/EventFactory.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/EventHelper.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Tue Mar 16 07:12:09 2010
@@ -240,7 +240,7 @@ public class DefaultCamelContext extends
                         }
                     }
                 } catch (Exception e) {
-                    throw new RuntimeCamelException("Could not auto create component: " + name, e);
+                    throw new RuntimeCamelException("Cannot auto create component: " + name, e);
                 }
             }
             return component;
@@ -287,7 +287,7 @@ public class DefaultCamelContext extends
                     }
                 } catch (Exception e) {
                     throw new RuntimeCamelException("Factory failed to create the " + componentName
-                            + " component", e);
+                            + " component.", e);
                 }
             }
             return component;
@@ -968,7 +968,7 @@ public class DefaultCamelContext extends
         firstStartDone = true;
 
         if (doNotStart) {
-            LOG.info("Cannot start Apache Camel " + getVersion() + " (CamelContext:" + getName() + ") as it has been configured to not auto start");
+            LOG.info("Cannot start Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") as it has been configured to not auto start");
             return;
         }
 
@@ -1080,12 +1080,11 @@ public class DefaultCamelContext extends
             for (int i = 0; i < getRoutes().size(); i++) {
                 LOG.debug("Route " + i + ": " + getRoutes().get(i));
             }
-            LOG.debug("... Routes started");
         }
 
         LOG.info("Started " + getRoutes().size() + " routes");
 
-        LOG.info("Apache Camel " + getVersion() + " (CamelContext:" + getName() + ") started");
+        LOG.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") started");
         EventHelper.notifyCamelContextStarted(this);
     }
 
@@ -1093,7 +1092,7 @@ public class DefaultCamelContext extends
     // -----------------------------------------------------------------------
 
     protected synchronized void doStart() throws Exception {
-        LOG.info("Apache Camel " + getVersion() + " (CamelContext:" + getName() + ") is starting");
+        LOG.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") is starting");
 
         try {
             doStartCamel();
@@ -1106,12 +1105,10 @@ public class DefaultCamelContext extends
     }
 
     private void doStartCamel() throws Exception {
-        startServices(producerServicePool);
-
         if (isStreamCaching()) {
             // only add a new stream cache if not already configured
             if (StreamCaching.getStreamCaching(this) == null) {
-                LOG.info("StreamCaching is enabled on CamelContext" + getName());
+                LOG.info("StreamCaching is enabled on CamelContext: " + getName());
                 addInterceptStrategy(new StreamCaching());
             }
         }
@@ -1124,7 +1121,7 @@ public class DefaultCamelContext extends
         if (isHandleFault()) {
             // only add a new handle fault if not already configured
             if (HandleFault.getHandleFault(this) == null) {
-                LOG.info("HandleFault is enabled on CamelContext" + getName());
+                LOG.info("HandleFault is enabled on CamelContext: " + getName());
                 addInterceptStrategy(new HandleFault());
             }
         }
@@ -1133,7 +1130,7 @@ public class DefaultCamelContext extends
             // only add a new delayer if not already configured
             if (Delayer.getDelayer(this) == null) {
                 long millis = getDelayer();
-                LOG.info("Delayer is enabled with: " + millis + " ms. on CamelContext" + getName());
+                LOG.info("Delayer is enabled with: " + millis + " ms. on CamelContext: " + getName());
                 addInterceptStrategy(new Delayer(millis));
             }
         }
@@ -1141,17 +1138,9 @@ public class DefaultCamelContext extends
         // start management strategy before lifecycles are started
         getManagementStrategy().start();
 
-        Iterator<LifecycleStrategy> it = lifecycleStrategies.iterator();
-        while (it.hasNext()) {
-            LifecycleStrategy strategy = it.next();
-            try {
-                strategy.onContextStart(this);
-            } catch (Exception e) {
-                // not all containers allow access to its MBeanServer (such as OC4j)
-                // so here we remove the troublesome strategy to be able to continue
-                LOG.warn("Cannot start lifecycle strategy: " + strategy + ". This strategy will be removed. Cause " + e.getMessage(), e);
-                it.remove();
-            }
+        // start lifecycle strategies
+        for (LifecycleStrategy strategy : lifecycleStrategies) {
+            strategy.onContextStart(this);
         }
 
         // must let some bootstrap service be started before we can notify the starting event
@@ -1159,6 +1148,7 @@ public class DefaultCamelContext extends
 
         forceLazyInitialization();
         addService(executorServiceStrategy);
+        addService(producerServicePool);
         addService(inflightRepository);
         addService(shutdownStrategy);
 
@@ -1192,61 +1182,46 @@ public class DefaultCamelContext extends
         shutdownServices(components.values());
         components.clear();
 
-        // special shutdown of a shared producer service pool as it should only be shutdown by camel context
-        if (producerServicePool instanceof SharedProducerServicePool) {
-            ((SharedProducerServicePool) producerServicePool).shutdown(this);
-        } else {
-            shutdownServices(producerServicePool);
-        }
-
-        shutdownServices(servicesToClose);
-        servicesToClose.clear();
-
         try {
             for (LifecycleStrategy strategy : lifecycleStrategies) {
                 strategy.onContextStop(this);
             }
-        } catch (Exception e) {
-            LOG.warn("Cannot stop lifecycle strategies: " + e.getMessage());
+        } catch (Throwable e) {
+            LOG.warn("Error occurred while stopping lifecycle strategies. This exception will be ignored.", e);
         }
 
+        // shutdown services as late as possible
+        shutdownServices(servicesToClose);
+        servicesToClose.clear();
+
         // must notify that we are stopped before stopping the management strategy
         EventHelper.notifyCamelContextStopped(this);
 
         // shutdown management as the last one
         shutdownServices(managementStrategy);
 
-        LOG.info("Apache Camel " + getVersion() + " (CamelContext:" + getName() + ") is shutdown");
+        LOG.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") is shutdown");
     }
 
-    private void stopServices(Object service) throws Exception {
-        // allow us to do custom work before delegating to service helper
-        try {
-            ServiceHelper.stopService(service);
-        } catch (Exception e) {
-            LOG.warn("Error occurred while stopping service: " + service + ". This exception will be ignored.");
-            // fire event
-            EventHelper.notifyServiceStopFailure(this, service, e);
-        }
-    }
+    private void shutdownServices(Object service) {
+        // do not rethrow exception as we want to keep shutting down in case of problems
 
-    private void shutdownServices(Object service) throws Exception {
         // allow us to do custom work before delegating to service helper
         try {
             ServiceHelper.stopAndShutdownService(service);
-        } catch (Exception e) {
-            LOG.warn("Error occurred while shutting down service: " + service + ". This exception will be ignored.");
+        } catch (Throwable e) {
+            LOG.warn("Error occurred while shutting down service: " + service + ". This exception will be ignored.", e);
             // fire event
             EventHelper.notifyServiceStopFailure(this, service, e);
         }
     }
 
-    private void shutdownServices(Collection<?> services) throws Exception {
+    private void shutdownServices(Collection<?> services) {
         // reverse stopping by default
         shutdownServices(services, true);
     }
 
-    private void shutdownServices(Collection<?> services, boolean reverse) throws Exception {
+    private void shutdownServices(Collection<?> services, boolean reverse) {
         Collection<Object> list = CastUtils.cast(services);
         if (reverse) {
             ArrayList<Object> reverseList = new ArrayList<Object>(services);
@@ -1263,6 +1238,18 @@ public class DefaultCamelContext extends
         ServiceHelper.startService(service);
     }
 
+    private void stopServices(Object service) throws Exception {
+        // allow us to do custom work before delegating to service helper
+        try {
+            ServiceHelper.stopService(service);
+        } catch (Exception e) {
+            // fire event
+            EventHelper.notifyServiceStopFailure(this, service, e);
+            // rethrow to signal error with stopping
+            throw e;
+        }
+    }
+
     protected void startRouteDefinitions(Collection<RouteDefinition> list) throws Exception {
         if (list != null) {
             for (RouteDefinition route : list) {
@@ -1575,7 +1562,7 @@ public class DefaultCamelContext extends
             answer = new DefaultManagementStrategy();
         } else {
             try {
-                LOG.info("JMX enabled. Using DefaultManagedLifecycleStrategy.");
+                LOG.info("JMX enabled. Using ManagedManagementStrategy.");
                 answer = new ManagedManagementStrategy(new DefaultManagementAgent(this));
                 // prefer to have it at first strategy
                 lifecycleStrategies.add(0, new DefaultManagementLifecycleStrategy(this));
@@ -1587,12 +1574,12 @@ public class DefaultCamelContext extends
                         + " (spring-jmx.jar using Spring 2.0.x)."
                         + " NoClassDefFoundError: " + e.getMessage());
             } catch (Exception e) {
-                LOG.warn("Could not create JMX lifecycle strategy, caused by: " + e.getMessage());
+                LOG.warn("Cannot create JMX lifecycle strategy. Will fallback to use non JMX and this exception will be ignored.", e);
             }
         }
 
         if (answer == null) {
-            LOG.warn("Cannot use JMX. Fallback to using DefaultManagementStrategy.");
+            LOG.warn("Cannot use JMX. Fallback to using DefaultManagementStrategy (non JMX).");
             answer = new DefaultManagementStrategy();
         }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceStrategy.java Tue Mar 16 07:12:09 2010
@@ -101,20 +101,30 @@ public class DefaultExecutorServiceStrat
         if (executorService.isShutdown()) {
             return;
         }
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Shutting down ExecutorService: " + executorService);
+            LOG.debug("Shutdown ExecutorService: " + executorService);
         }
         executorService.shutdown();
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Shutdown ExecutorService: " + executorService + " complete.");
+        }
     }
 
     public List<Runnable> shutdownNow(ExecutorService executorService) {
         if (executorService.isShutdown()) {
             return null;
         }
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Shutting down now ExecutorService: " + executorService);
+            LOG.debug("ShutdownNow ExecutorService: " + executorService);
         }
-        return executorService.shutdownNow();
+        List<Runnable> answer = executorService.shutdownNow();
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("ShutdownNow ExecutorService: " + executorService + " complete.");
+        }
+
+        return answer;
     }
 
     /**
@@ -146,7 +156,7 @@ public class DefaultExecutorServiceStrat
             // only log if something goes wrong as we want to shutdown them all
             try {
                 shutdownNow(executorService);
-            } catch (Exception e) {
+            } catch (Throwable e) {
                 LOG.warn("Error occurred during shutdown of ExecutorService: "
                         + executorService + ". This exception will be ignored.", e);
             }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SharedProducerServicePool.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SharedProducerServicePool.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SharedProducerServicePool.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SharedProducerServicePool.java Tue Mar 16 07:12:09 2010
@@ -16,10 +16,7 @@
  */
 package org.apache.camel.impl;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.util.EventHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.camel.ShutdownableService;
 
 /**
  * A shared {@link org.apache.camel.impl.DefaultProducerServicePool} which is used by
@@ -27,9 +24,7 @@ import org.apache.commons.logging.LogFac
  *
  * @version $Revision$
  */
-public class SharedProducerServicePool extends DefaultProducerServicePool {
-
-    private static final transient Log LOG = LogFactory.getLog(SharedProducerServicePool.class);
+public class SharedProducerServicePool extends DefaultProducerServicePool implements ShutdownableService {
 
     public SharedProducerServicePool(int capacity) {
         super(capacity);
@@ -41,14 +36,10 @@ public class SharedProducerServicePool e
         // only be stopped when CamelContext stops
     }
 
-    void shutdown(CamelContext context) throws Exception {
-        try {
-            super.doStop();
-        } catch (Exception e) {
-            LOG.warn("Error occurred while stopping service: " + this + ". This exception will be ignored.");
-            // fire event
-            EventHelper.notifyServiceStopFailure(context, this, e);
-        }
+    @Override
+    protected void doShutdown() throws Exception {
+        // now we are shutting down then stop it, which properly stops the pool
+        super.doStop();
     }
 
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultEventFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultEventFactory.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultEventFactory.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultEventFactory.java Tue Mar 16 07:12:09 2010
@@ -61,19 +61,19 @@ public class DefaultEventFactory impleme
         return new CamelContextStoppedEvent(context);
     }
 
-    public EventObject createCamelContextStartupFailureEvent(CamelContext context, Exception cause) {
+    public EventObject createCamelContextStartupFailureEvent(CamelContext context, Throwable cause) {
         return new CamelContextStartupFailureEvent(context, cause);
     }
 
-    public EventObject createCamelContextStopFailureEvent(CamelContext context, Exception cause) {
+    public EventObject createCamelContextStopFailureEvent(CamelContext context, Throwable cause) {
         return new CamelContextStopFailureEvent(context, cause);
     }
 
-    public EventObject createServiceStartupFailureEvent(CamelContext context, Object service, Exception cause) {
+    public EventObject createServiceStartupFailureEvent(CamelContext context, Object service, Throwable cause) {
         return new ServiceStartupFailureEvent(context, service, cause);
     }
 
-    public EventObject createServiceStopFailureEvent(CamelContext context, Object service, Exception cause) {
+    public EventObject createServiceStopFailureEvent(CamelContext context, Object service, Throwable cause) {
         return new ServiceStopFailureEvent(context, service, cause);
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/CamelContextStartupFailureEvent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/CamelContextStartupFailureEvent.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/CamelContextStartupFailureEvent.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/CamelContextStartupFailureEvent.java Tue Mar 16 07:12:09 2010
@@ -27,9 +27,9 @@ public class CamelContextStartupFailureE
     private static final long serialVersionUID = -4271899927507894567L;
 
     private CamelContext context;
-    private Exception cause;
+    private Throwable cause;
 
-    public CamelContextStartupFailureEvent(CamelContext context, Exception cause) {
+    public CamelContextStartupFailureEvent(CamelContext context, Throwable cause) {
         super(context);
         this.context = context;
         this.cause = cause;
@@ -39,7 +39,7 @@ public class CamelContextStartupFailureE
         return context;
     }
 
-    public Exception getCause() {
+    public Throwable getCause() {
         return cause;
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/CamelContextStopFailureEvent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/CamelContextStopFailureEvent.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/CamelContextStopFailureEvent.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/CamelContextStopFailureEvent.java Tue Mar 16 07:12:09 2010
@@ -27,9 +27,9 @@ public class CamelContextStopFailureEven
     private static final long serialVersionUID = -802046840118188292L;
 
     private CamelContext context;
-    private Exception cause;
+    private Throwable cause;
 
-    public CamelContextStopFailureEvent(CamelContext context, Exception cause) {
+    public CamelContextStopFailureEvent(CamelContext context, Throwable cause) {
         super(context);
         this.context = context;
         this.cause = cause;
@@ -39,7 +39,7 @@ public class CamelContextStopFailureEven
         return context;
     }
 
-    public Exception getCause() {
+    public Throwable getCause() {
         return cause;
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ServiceStartupFailureEvent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ServiceStartupFailureEvent.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ServiceStartupFailureEvent.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ServiceStartupFailureEvent.java Tue Mar 16 07:12:09 2010
@@ -28,9 +28,9 @@ public class ServiceStartupFailureEvent 
 
     private CamelContext context;
     private Object service;
-    private Exception cause;
+    private Throwable cause;
 
-    public ServiceStartupFailureEvent(CamelContext context, Object service, Exception cause) {
+    public ServiceStartupFailureEvent(CamelContext context, Object service, Throwable cause) {
         super(service);
         this.context = context;
         this.service = service;
@@ -45,7 +45,7 @@ public class ServiceStartupFailureEvent 
         return service;
     }
 
-    public Exception getCause() {
+    public Throwable getCause() {
         return cause;
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ServiceStopFailureEvent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ServiceStopFailureEvent.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ServiceStopFailureEvent.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ServiceStopFailureEvent.java Tue Mar 16 07:12:09 2010
@@ -28,9 +28,9 @@ public class ServiceStopFailureEvent ext
 
     private CamelContext context;
     private Object service;
-    private Exception cause;
+    private Throwable cause;
 
-    public ServiceStopFailureEvent(CamelContext context, Object service, Exception cause) {
+    public ServiceStopFailureEvent(CamelContext context, Object service, Throwable cause) {
         super(service);
         this.context = context;
         this.service = service;
@@ -45,7 +45,7 @@ public class ServiceStopFailureEvent ext
         return service;
     }
 
-    public Exception getCause() {
+    public Throwable getCause() {
         return cause;
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/EventFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/EventFactory.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/EventFactory.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/EventFactory.java Tue Mar 16 07:12:09 2010
@@ -56,7 +56,7 @@ public interface EventFactory {
      * @param cause the cause exception
      * @return the created event
      */
-    EventObject createCamelContextStartupFailureEvent(CamelContext context, Exception cause);
+    EventObject createCamelContextStartupFailureEvent(CamelContext context, Throwable cause);
 
     /**
      * Creates an {@link EventObject} for Camel failing to stop cleanly
@@ -65,7 +65,7 @@ public interface EventFactory {
      * @param cause the cause exception
      * @return the created event
      */
-    EventObject createCamelContextStopFailureEvent(CamelContext context, Exception cause);
+    EventObject createCamelContextStopFailureEvent(CamelContext context, Throwable cause);
 
     /**
      * Creates an {@link EventObject} for Camel is stopping.
@@ -91,7 +91,7 @@ public interface EventFactory {
      * @param cause the cause exception
      * @return the created event
      */
-    EventObject createServiceStartupFailureEvent(CamelContext context, Object service, Exception cause);
+    EventObject createServiceStartupFailureEvent(CamelContext context, Object service, Throwable cause);
 
     /**
      * Creates an {@link EventObject} for a Service failed to stop cleanly
@@ -101,7 +101,7 @@ public interface EventFactory {
      * @param cause the cause exception
      * @return the created event
      */
-    EventObject createServiceStopFailureEvent(CamelContext context, Object service, Exception cause);
+    EventObject createServiceStopFailureEvent(CamelContext context, Object service, Throwable cause);
 
     /**
      * Creates an {@link EventObject} for {@link Route} has been started successfully.

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/EventHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/EventHelper.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/EventHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/EventHelper.java Tue Mar 16 07:12:09 2010
@@ -88,7 +88,7 @@ public final class EventHelper {
         }
     }
 
-    public static void notifyCamelContextStartupFailed(CamelContext context, Exception cause) {
+    public static void notifyCamelContextStartupFailed(CamelContext context, Throwable cause) {
         List<EventNotifier> notifiers = context.getManagementStrategy().getEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return;
@@ -157,7 +157,7 @@ public final class EventHelper {
         }
     }
 
-    public static void notifyCamelContextStopFailed(CamelContext context, Exception cause) {
+    public static void notifyCamelContextStopFailed(CamelContext context, Throwable cause) {
         List<EventNotifier> notifiers = context.getManagementStrategy().getEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return;
@@ -180,7 +180,7 @@ public final class EventHelper {
         }
     }
 
-    public static void notifyServiceStopFailure(CamelContext context, Object service, Exception cause) {
+    public static void notifyServiceStopFailure(CamelContext context, Object service, Throwable cause) {
         List<EventNotifier> notifiers = context.getManagementStrategy().getEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return;
@@ -203,7 +203,7 @@ public final class EventHelper {
         }
     }
 
-    public static void notifyServiceStartupFailure(CamelContext context, Object service, Exception cause) {
+    public static void notifyServiceStartupFailure(CamelContext context, Object service, Throwable cause) {
         List<EventNotifier> notifiers = context.getManagementStrategy().getEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return;
@@ -410,7 +410,7 @@ public final class EventHelper {
 
         try {
             notifier.notify(event);
-        } catch (Exception e) {
+        } catch (Throwable e) {
             LOG.warn("Error notifying event " + event + ". This exception will be ignored. ", e);
         }
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java?rev=923594&r1=923593&r2=923594&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MultipleLifecycleStrategyTest.java Tue Mar 16 07:12:09 2010
@@ -50,8 +50,8 @@ public class MultipleLifecycleStrategyTe
 
         context.stop();
 
-        assertEquals(9, dummy1.getEvents().size());
-        assertEquals(9, dummy2.getEvents().size());
+        assertEquals(10, dummy1.getEvents().size());
+        assertEquals(10, dummy2.getEvents().size());
 
         assertEquals("onContextStart", dummy1.getEvents().get(0));
         assertEquals("onContextStart", dummy2.getEvents().get(0));
@@ -63,14 +63,16 @@ public class MultipleLifecycleStrategyTe
         assertEquals("onServiceAdd", dummy2.getEvents().get(3));
         assertEquals("onServiceAdd", dummy1.getEvents().get(4));
         assertEquals("onServiceAdd", dummy2.getEvents().get(4));
-        assertEquals("onComponentAdd", dummy1.getEvents().get(5));
-        assertEquals("onComponentAdd", dummy2.getEvents().get(5));
-        assertEquals("onEndpointAdd", dummy1.getEvents().get(6));
-        assertEquals("onEndpointAdd", dummy2.getEvents().get(6));
-        assertEquals("onComponentRemove", dummy1.getEvents().get(7));
-        assertEquals("onComponentRemove", dummy2.getEvents().get(7));
-        assertEquals("onContextStop", dummy1.getEvents().get(8));
-        assertEquals("onContextStop", dummy2.getEvents().get(8));
+        assertEquals("onServiceAdd", dummy1.getEvents().get(5));
+        assertEquals("onServiceAdd", dummy2.getEvents().get(5));
+        assertEquals("onComponentAdd", dummy1.getEvents().get(6));
+        assertEquals("onComponentAdd", dummy2.getEvents().get(6));
+        assertEquals("onEndpointAdd", dummy1.getEvents().get(7));
+        assertEquals("onEndpointAdd", dummy2.getEvents().get(7));
+        assertEquals("onComponentRemove", dummy1.getEvents().get(8));
+        assertEquals("onComponentRemove", dummy2.getEvents().get(8));
+        assertEquals("onContextStop", dummy1.getEvents().get(9));
+        assertEquals("onContextStop", dummy2.getEvents().get(9));
     }
 
 }