camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r897885 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/management/ camel-core/src/main/java/org/apache/camel/management/event/ camel-core/src/main/java/org/apache/camel/spi/ came...
Date Mon, 11 Jan 2010 14:50:56 GMT
Author: davsclaus
Date: Mon Jan 11 14:50:55 2010
New Revision: 897885

URL: http://svn.apache.org/viewvc?rev=897885&view=rev
Log:
CAMEL-2348: Improved EventNotifier to ignore categories of events. Renamed DefaultEventNotifer
to LoggingEventNotifier and let EventNotifierSupport be a class to extend for custom impls

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/EventNotifierSupport.java
  (with props)
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/LoggingEventNotifier.java
  (contents, props changed)
      - copied, changed from r897848, camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultEventNotifier.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/LoggingEventNotifierTest.java
      - copied, changed from r897848, camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.java
      - copied, changed from r897848, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedErrorHandlerTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.xml
      - copied, changed from r897848, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedErrorHandlerTest.xml
Removed:
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultEventNotifier.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCompletedEvent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCreatedEvent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureEvent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureHandledEvent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/EventNotifier.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/EventHelper.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierFailreHandledEventsTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierServiceStoppingFailedEventTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/MyEventNotifier.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java Mon Jan
11 14:50:55 2010
@@ -33,8 +33,6 @@
  */
 public abstract class ServiceSupport implements Service {
 
-    // TODO: refactor and move me to org.apache.camel.util package
-
     private final AtomicBoolean started = new AtomicBoolean(false);
     private final AtomicBoolean starting = new AtomicBoolean(false);
     private final AtomicBoolean stopping = new AtomicBoolean(false);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
Mon Jan 11 14:50:55 2010
@@ -25,6 +25,7 @@
 import org.apache.camel.spi.ManagementAgent;
 import org.apache.camel.spi.ManagementNamingStrategy;
 import org.apache.camel.spi.ManagementStrategy;
+import org.apache.camel.util.ServiceHelper;
 import org.fusesource.commons.management.Statistic;
 
 /**
@@ -42,7 +43,7 @@
  */
 public class DefaultManagementStrategy implements ManagementStrategy {
 
-    private EventNotifier eventNotifier = new DefaultEventNotifier();
+    private EventNotifier eventNotifier;
     private EventFactory eventFactory = new DefaultEventFactory();
     private ManagementNamingStrategy managementNamingStrategy;
     private boolean onlyManageProcessorWithCustomId;
@@ -142,6 +143,9 @@
     }
 
     public void start() throws Exception {
+        if (eventNotifier != null) {
+            ServiceHelper.startService(eventNotifier);
+        }
         if (managementAgent != null) {
             managementAgent.start();
             // set the naming strategy using the domain name from the agent
@@ -155,5 +159,9 @@
         if (managementAgent != null) {
             managementAgent.stop();
         }
+        if (eventNotifier != null) {
+            ServiceHelper.stopService(eventNotifier);
+        }
     }
+
 }

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/management/EventNotifierSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/EventNotifierSupport.java?rev=897885&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/EventNotifierSupport.java
(added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/EventNotifierSupport.java
Mon Jan 11 14:50:55 2010
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.management;
+
+import org.apache.camel.impl.ServiceSupport;
+import org.apache.camel.spi.EventNotifier;
+
+/**
+ * Base class to extend for custom {@link EventNotifier} implementations.
+ *
+ * @version $Revision$
+ */
+public abstract class EventNotifierSupport extends ServiceSupport implements EventNotifier
{
+    boolean ignoreCamelContextEvents;
+    boolean ignoreRouteEvents;
+    boolean ignoreServiceEvents;
+    boolean ignoreExchangeEvents;
+    boolean ignoreExchangeCreatedEvent;
+    boolean ignoreExchangeCompletedEvent;
+    boolean ignoreExchangeFailureEvents;
+
+    public boolean isIgnoreCamelContextEvents() {
+        return ignoreCamelContextEvents;
+    }
+
+    public void setIgnoreCamelContextEvents(boolean ignoreCamelContextEvents) {
+        this.ignoreCamelContextEvents = ignoreCamelContextEvents;
+    }
+
+    public boolean isIgnoreRouteEvents() {
+        return ignoreRouteEvents;
+    }
+
+    public void setIgnoreRouteEvents(boolean ignoreRouteEvents) {
+        this.ignoreRouteEvents = ignoreRouteEvents;
+    }
+
+    public boolean isIgnoreServiceEvents() {
+        return ignoreServiceEvents;
+    }
+
+    public void setIgnoreServiceEvents(boolean ignoreServiceEvents) {
+        this.ignoreServiceEvents = ignoreServiceEvents;
+    }
+
+    public boolean isIgnoreExchangeEvents() {
+        return ignoreExchangeEvents;
+    }
+
+    public void setIgnoreExchangeEvents(boolean ignoreExchangeEvents) {
+        this.ignoreExchangeEvents = ignoreExchangeEvents;
+    }
+
+    public boolean isIgnoreExchangeCreatedEvent() {
+        return ignoreExchangeCreatedEvent;
+    }
+
+    public void setIgnoreExchangeCreatedEvent(boolean ignoreExchangeCreatedEvent) {
+        this.ignoreExchangeCreatedEvent = ignoreExchangeCreatedEvent;
+    }
+
+    public boolean isIgnoreExchangeCompletedEvent() {
+        return ignoreExchangeCompletedEvent;
+    }
+
+    public void setIgnoreExchangeCompletedEvent(boolean ignoreExchangeCompletedEvent) {
+        this.ignoreExchangeCompletedEvent = ignoreExchangeCompletedEvent;
+    }
+
+    public boolean isIgnoreExchangeFailureEvents() {
+        return ignoreExchangeFailureEvents;
+    }
+
+    public void setIgnoreExchangeFailureEvents(boolean ignoreExchangeFailureEvents) {
+        this.ignoreExchangeFailureEvents = ignoreExchangeFailureEvents;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/management/EventNotifierSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/management/EventNotifierSupport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/camel-core/src/main/java/org/apache/camel/management/LoggingEventNotifier.java
(from r897848, camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultEventNotifier.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/LoggingEventNotifier.java?p2=camel/trunk/camel-core/src/main/java/org/apache/camel/management/LoggingEventNotifier.java&p1=camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultEventNotifier.java&r1=897848&r2=897885&rev=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultEventNotifier.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/LoggingEventNotifier.java
Mon Jan 11 14:50:55 2010
@@ -18,26 +18,47 @@
 
 import java.util.EventObject;
 
-import org.apache.camel.spi.EventNotifier;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 /**
- * Default event notifier that only notifies if <tt>TRACE</tt> log level has
+ * Logging event notifier that only notifies if <tt>INFO</tt> log level has
  * been configured for its logger.
  *
  * @version $Revision$
  */
-public class DefaultEventNotifier implements EventNotifier {
+public class LoggingEventNotifier extends EventNotifierSupport {
 
-    private static final Log LOG = LogFactory.getLog(DefaultEventNotifier.class);
+    private Log log = LogFactory.getLog(LoggingEventNotifier.class);
+    private String logName;
 
     public void notify(EventObject event) throws Exception {
-        LOG.trace("Event: " + event);
+        log.info("Event: " + event);
     }
 
     public boolean isEnabled(EventObject event) {
-        return LOG.isTraceEnabled();
+        return log.isInfoEnabled();
     }
 
+    public String getLogName() {
+        return logName;
+    }
+
+    /**
+     * Sets the log name to use.
+     *
+     * @param logName a custom log name to use
+     */
+    public void setLogName(String logName) {
+        this.logName = logName;
+    }
+
+    protected void doStart() throws Exception {
+        if (logName != null) {
+            log = LogFactory.getLog(logName);
+        }
+    }
+
+    protected void doStop() throws Exception {
+    }
 }

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/management/LoggingEventNotifier.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/management/LoggingEventNotifier.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCompletedEvent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCompletedEvent.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCompletedEvent.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCompletedEvent.java
Mon Jan 11 14:50:55 2010
@@ -39,6 +39,6 @@
 
     @Override
     public String toString() {
-        return "Exchange completed: " + exchange;
+        return exchange.getExchangeId() + " exchange completed: " + exchange;
     }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCreatedEvent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCreatedEvent.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCreatedEvent.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCreatedEvent.java
Mon Jan 11 14:50:55 2010
@@ -39,6 +39,6 @@
 
     @Override
     public String toString() {
-        return "Exchange created: " + exchange;
+        return exchange.getExchangeId() + " exchange created: " + exchange;
     }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureEvent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureEvent.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureEvent.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureEvent.java
Mon Jan 11 14:50:55 2010
@@ -39,6 +39,11 @@
 
     @Override
     public String toString() {
-        return "Exchange failure: " + exchange;
+        Exception cause = exchange.getException();
+        if (cause != null) {
+            return exchange.getExchangeId() + " exchange failure: " + exchange + " cause
" + cause;
+        } else {
+            return exchange.getExchangeId() + " exchange failure: " + exchange;
+        }
     }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureHandledEvent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureHandledEvent.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureHandledEvent.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureHandledEvent.java
Mon Jan 11 14:50:55 2010
@@ -59,9 +59,9 @@
     @Override
     public String toString() {
         if (isDeadLetterChannel()) {
-            return "Exchange failed: " + exchange + " but was handled by dead letter channel:
" + failureHandler;
+            return exchange.getExchangeId() + " exchange failed: " + exchange + " but was
handled by dead letter channel: " + failureHandler;
         } else {
-            return "Exchange failed: " + exchange + " but was processed by: " + failureHandler;
+            return exchange.getExchangeId() + " exchange failed: " + exchange + " but was
processed by: " + failureHandler;
         }
     }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/EventNotifier.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/EventNotifier.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/EventNotifier.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/EventNotifier.java Mon Jan 11
14:50:55 2010
@@ -44,4 +44,31 @@
      */
     boolean isEnabled(EventObject event);
 
+    boolean isIgnoreCamelContextEvents();
+
+    void setIgnoreCamelContextEvents(boolean ignoreCamelContextEvents);
+
+    boolean isIgnoreRouteEvents();
+
+    void setIgnoreRouteEvents(boolean ignoreRouteEvents);
+
+    boolean isIgnoreServiceEvents();
+
+    void setIgnoreServiceEvents(boolean ignoreServiceEvents);
+
+    boolean isIgnoreExchangeEvents();
+
+    void setIgnoreExchangeEvents(boolean ignoreExchangeEvents);
+
+    boolean isIgnoreExchangeCreatedEvent();
+
+    void setIgnoreExchangeCreatedEvent(boolean ignoreExchangeCreatedEvent);
+
+    boolean isIgnoreExchangeCompletedEvent();
+
+    void setIgnoreExchangeCompletedEvent(boolean ignoreExchangeCompletedEvent);
+
+    boolean isIgnoreExchangeFailureEvents();
+
+    void setIgnoreExchangeFailureEvents(boolean ignoreExchangeFailureEvents);
 }

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=897885&r1=897884&r2=897885&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 Mon Jan 11
14:50:55 2010
@@ -28,7 +28,7 @@
 import org.apache.commons.logging.LogFactory;
 
 /**
- * Helper for easily sending event notifcations in a single line of code
+ * Helper for easily sending event notifications in a single line of code
  *
  * @version $Revision$
  */
@@ -41,7 +41,7 @@
 
     public static void notifyCamelContextStarting(CamelContext context) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreCamelContextEvents()) {
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -57,7 +57,7 @@
 
     public static void notifyCamelContextStarted(CamelContext context) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreCamelContextEvents()) {
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -73,7 +73,7 @@
 
     public static void notifyCamelContextStartupFailed(CamelContext context, Exception cause)
{
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreCamelContextEvents()) {
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -89,7 +89,7 @@
 
     public static void notifyCamelContextStopping(CamelContext context) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreCamelContextEvents()) {
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -105,7 +105,7 @@
 
     public static void notifyCamelContextStopped(CamelContext context) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreCamelContextEvents()) {
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -121,7 +121,7 @@
 
     public static void notifyCamelContextStopFailed(CamelContext context, Exception cause)
{
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreCamelContextEvents()) {
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -137,7 +137,7 @@
 
     public static void notifyServiceStopFailure(CamelContext context, Object service, Exception
cause) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreServiceEvents()) {
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -153,7 +153,7 @@
 
     public static void notifyServiceStartupFailure(CamelContext context, Object service,
Exception cause) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreServiceEvents()) {
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -169,7 +169,7 @@
 
     public static void notifyRouteStarted(CamelContext context, Route route) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreRouteEvents()) {
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -185,7 +185,7 @@
 
     public static void notifyRouteStopped(CamelContext context, Route route) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreRouteEvents()) {
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -201,7 +201,7 @@
 
     public static void notifyExchangeCreated(CamelContext context, Exchange exchange) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeCreatedEvent())
{
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -217,7 +217,7 @@
 
     public static void notifyExchangeDone(CamelContext context, Exchange exchange) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeCompletedEvent())
{
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -233,7 +233,7 @@
 
     public static void notifyExchangeFailed(CamelContext context, Exchange exchange) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeFailureEvents())
{
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();
@@ -250,7 +250,7 @@
     public static void notifyExchangeFailureHandled(CamelContext context, Exchange exchange,
Processor failureHandler,
                                                     boolean deadLetterChannel) {
         EventNotifier notifier = context.getManagementStrategy().getEventNotifier();
-        if (notifier == null) {
+        if (notifier == null || notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeFailureEvents())
{
             return;
         }
         EventFactory factory = context.getManagementStrategy().getEventFactory();

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java
Mon Jan 11 14:50:55 2010
@@ -33,7 +33,6 @@
 import org.apache.camel.management.event.ExchangeFailureEvent;
 import org.apache.camel.management.event.RouteStartedEvent;
 import org.apache.camel.management.event.RouteStoppedEvent;
-import org.apache.camel.spi.EventNotifier;
 
 /**
  * @version $Revision$
@@ -51,7 +50,7 @@
     @Override
     protected CamelContext createCamelContext() throws Exception {
         DefaultCamelContext context = new DefaultCamelContext(createRegistry());
-        context.getManagementStrategy().setEventNotifier(new EventNotifier() {
+        context.getManagementStrategy().setEventNotifier(new EventNotifierSupport() {
             public void notify(EventObject event) throws Exception {
                 events.add(event);
             }
@@ -59,6 +58,14 @@
             public boolean isEnabled(EventObject event) {
                 return true;
             }
+
+            @Override
+            protected void doStart() throws Exception {
+            }
+
+            @Override
+            protected void doStop() throws Exception {
+            }
         });
         return context;
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierFailreHandledEventsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierFailreHandledEventsTest.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierFailreHandledEventsTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierFailreHandledEventsTest.java
Mon Jan 11 14:50:55 2010
@@ -31,7 +31,6 @@
 import org.apache.camel.management.event.ExchangeFailureHandledEvent;
 import org.apache.camel.management.event.RouteStartedEvent;
 import org.apache.camel.processor.SendProcessor;
-import org.apache.camel.spi.EventNotifier;
 
 /**
  * @version $Revision$
@@ -54,7 +53,7 @@
     @Override
     protected CamelContext createCamelContext() throws Exception {
         DefaultCamelContext context = new DefaultCamelContext(createRegistry());
-        context.getManagementStrategy().setEventNotifier(new EventNotifier() {
+        context.getManagementStrategy().setEventNotifier(new EventNotifierSupport() {
             public void notify(EventObject event) throws Exception {
                 events.add(event);
             }
@@ -62,6 +61,14 @@
             public boolean isEnabled(EventObject event) {
                 return true;
             }
+
+            @Override
+            protected void doStart() throws Exception {
+            }
+
+            @Override
+            protected void doStop() throws Exception {
+            }
         });
         return context;
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierServiceStoppingFailedEventTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierServiceStoppingFailedEventTest.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierServiceStoppingFailedEventTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierServiceStoppingFailedEventTest.java
Mon Jan 11 14:50:55 2010
@@ -28,7 +28,6 @@
 import org.apache.camel.management.event.CamelContextStoppedEvent;
 import org.apache.camel.management.event.CamelContextStoppingEvent;
 import org.apache.camel.management.event.ServiceStopFailureEvent;
-import org.apache.camel.spi.EventNotifier;
 
 /**
  * @version $Revision$
@@ -51,7 +50,7 @@
         context.addService(new MyService("B", true));
         context.addService(new MyService("C", false));
 
-        context.getManagementStrategy().setEventNotifier(new EventNotifier() {
+        context.getManagementStrategy().setEventNotifier(new EventNotifierSupport() {
             public void notify(EventObject event) throws Exception {
                 events.add(event);
             }
@@ -59,6 +58,14 @@
             public boolean isEnabled(EventObject event) {
                 return true;
             }
+
+            @Override
+            protected void doStart() throws Exception {
+            }
+
+            @Override
+            protected void doStop() throws Exception {
+            }
         });
         return context;
     }

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/management/LoggingEventNotifierTest.java
(from r897848, camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/LoggingEventNotifierTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/management/LoggingEventNotifierTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java&r1=897848&r2=897885&rev=897885&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/EventNotifierEventsTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/LoggingEventNotifierTest.java
Mon Jan 11 14:50:55 2010
@@ -16,50 +16,27 @@
  */
 package org.apache.camel.management;
 
-import java.util.ArrayList;
-import java.util.EventObject;
-import java.util.List;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.management.event.CamelContextStartedEvent;
-import org.apache.camel.management.event.CamelContextStartingEvent;
-import org.apache.camel.management.event.CamelContextStoppedEvent;
-import org.apache.camel.management.event.CamelContextStoppingEvent;
-import org.apache.camel.management.event.ExchangeCompletedEvent;
-import org.apache.camel.management.event.ExchangeCreatedEvent;
-import org.apache.camel.management.event.ExchangeFailureEvent;
-import org.apache.camel.management.event.RouteStartedEvent;
-import org.apache.camel.management.event.RouteStoppedEvent;
-import org.apache.camel.spi.EventNotifier;
 
 /**
  * @version $Revision$
  */
-public class EventNotifierEventsTest extends ContextTestSupport {
-
-    private static List<EventObject> events = new ArrayList<EventObject>();
-
-    @Override
-    public void setUp() throws Exception {
-        events.clear();
-        super.setUp();
-    }
+public class LoggingEventNotifierTest extends ContextTestSupport {
 
     @Override
     protected CamelContext createCamelContext() throws Exception {
-        DefaultCamelContext context = new DefaultCamelContext(createRegistry());
-        context.getManagementStrategy().setEventNotifier(new EventNotifier() {
-            public void notify(EventObject event) throws Exception {
-                events.add(event);
-            }
+        LoggingEventNotifier notifier = new LoggingEventNotifier();
+        notifier.setLogName("org.apache.camel.EventLog");
+        notifier.setIgnoreCamelContextEvents(true);
+        notifier.setIgnoreRouteEvents(true);
+        notifier.setIgnoreServiceEvents(true);
+
+        CamelContext context = new DefaultCamelContext(createRegistry());
+        context.getManagementStrategy().setEventNotifier(notifier);
 
-            public boolean isEnabled(EventObject event) {
-                return true;
-            }
-        });
         return context;
     }
 
@@ -70,21 +47,7 @@
 
         assertMockEndpointsSatisfied();
 
-        assertEquals(6, events.size());
-        assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
-        assertIsInstanceOf(RouteStartedEvent.class, events.get(1));
-        assertIsInstanceOf(RouteStartedEvent.class, events.get(2));
-        assertIsInstanceOf(CamelContextStartedEvent.class, events.get(3));
-        assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(4));
-        assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(5));
-
         context.stop();
-
-        assertEquals(10, events.size());
-        assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(6));
-        assertIsInstanceOf(RouteStoppedEvent.class, events.get(7));
-        assertIsInstanceOf(RouteStoppedEvent.class, events.get(8));
-        assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(9));
     }
 
     public void testExchangeFailed() throws Exception {
@@ -96,21 +59,7 @@
             assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
         }
 
-        assertEquals(6, events.size());
-        assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
-        assertIsInstanceOf(RouteStartedEvent.class, events.get(1));
-        assertIsInstanceOf(RouteStartedEvent.class, events.get(2));
-        assertIsInstanceOf(CamelContextStartedEvent.class, events.get(3));
-        assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(4));
-        assertIsInstanceOf(ExchangeFailureEvent.class, events.get(5));
-
         context.stop();
-
-        assertEquals(10, events.size());
-        assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(6));
-        assertIsInstanceOf(RouteStoppedEvent.class, events.get(7));
-        assertIsInstanceOf(RouteStoppedEvent.class, events.get(8));
-        assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(9));
     }
 
     @Override
@@ -125,4 +74,4 @@
         };
     }
 
-}
+}
\ No newline at end of file

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/MyEventNotifier.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/MyEventNotifier.java?rev=897885&r1=897884&r2=897885&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/MyEventNotifier.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/MyEventNotifier.java
Mon Jan 11 14:50:55 2010
@@ -20,12 +20,12 @@
 import java.util.EventObject;
 import java.util.List;
 
-import org.apache.camel.spi.EventNotifier;
+import org.apache.camel.management.EventNotifierSupport;
 
 /**
  * @version $Revision$
  */
-public class MyEventNotifier implements EventNotifier {
+public class MyEventNotifier extends EventNotifierSupport {
 
     private List<EventObject> events = new ArrayList<EventObject>();
 
@@ -40,4 +40,12 @@
     public List<EventObject> getEvents() {
         return events;
     }
+
+    @Override
+    protected void doStart() throws Exception {
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+    }
 }

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.java
(from r897848, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedErrorHandlerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedErrorHandlerTest.java&r1=897848&r2=897885&rev=897885&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedErrorHandlerTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.java
Mon Jan 11 14:50:55 2010
@@ -17,16 +17,17 @@
 package org.apache.camel.spring.management;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.management.ManagedErrorHandlerTest;
+import org.apache.camel.management.LoggingEventNotifierTest;
+
 import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
 /**
  * @version $Revision$
  */
-public class SpringManagedErrorHandlerTest extends ManagedErrorHandlerTest {
+public class SpringLoggingEventNotifierTest extends LoggingEventNotifierTest {
 
     protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/management/SpringManagedErrorHandlerTest.xml");
+        return createSpringCamelContext(this, "org/apache/camel/spring/management/SpringLoggingEventNotifierTest.xml");
     }
 
 }
\ No newline at end of file

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.xml
(from r897848, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedErrorHandlerTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedErrorHandlerTest.xml&r1=897848&r2=897885&rev=897885&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedErrorHandlerTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringLoggingEventNotifierTest.xml
Mon Jan 11 14:50:55 2010
@@ -22,24 +22,27 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <bean id="dlc" class="org.apache.camel.builder.DeadLetterChannelBuilder">
-        <property name="deadLetterUri" value="mock:read"/>
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <bean id="eventLogger" class="org.apache.camel.management.LoggingEventNotifier">
+        <property name="logName" value="org.apache.camel.EventLog"/>
+        <property name="ignoreCamelContextEvents" value="true"/>
+        <property name="ignoreRouteEvents" value="true"/>
+        <property name="ignoreServiceEvents" value="true"/>
     </bean>
 
     <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
         <route>
-            <from uri="direct:foo"/>
-            <to uri="mock:foo"/>
-        </route>
-
-        <route errorHandlerRef="dlc">
-            <from uri="direct:bar"/>
-            <to uri="mock:bar"/>
+            <from uri="direct:start"/>
+            <to uri="log:foo"/>
+            <to uri="mock:result"/>
         </route>
 
         <route>
-            <from uri="direct:baz"/>
-            <to uri="mock:baz"/>
+            <from uri="direct:fail"/>
+            <throwException ref="damn"/>
         </route>
     </camelContext>
 



Mime
View raw message