Search in sources :

Example 76 with EventObject

use of java.util.EventObject in project camel by apache.

the class EventNotifierExchangeSentTest method testExchangeWireTap.

public void testExchangeWireTap() throws Exception {
    getMockEndpoint("mock:result").expectedMessageCount(1);
    template.sendBody("direct:tap", "Hello World");
    assertMockEndpointsSatisfied();
    // give it time to complete
    Thread.sleep(200);
    assertEquals(6, events.size());
    // we should find log:foo which we tapped
    // which runs async so they can be in random order
    boolean found = false;
    boolean found2 = false;
    for (EventObject event : events) {
        if (event instanceof ExchangeSendingEvent) {
            ExchangeSendingEvent sending = (ExchangeSendingEvent) event;
            String uri = sending.getEndpoint().getEndpointUri();
            if ("log://foo".equals(uri)) {
                found = true;
            }
        } else if (event instanceof ExchangeSentEvent) {
            ExchangeSentEvent sent = (ExchangeSentEvent) event;
            String uri = sent.getEndpoint().getEndpointUri();
            if ("log://foo".equals(uri)) {
                found2 = true;
            }
        }
    }
    assertTrue("We should find log:foo being wire tapped", found);
    assertTrue("We should find log:foo being wire tapped", found2);
}
Also used : ExchangeSentEvent(org.apache.camel.management.event.ExchangeSentEvent) ExchangeSendingEvent(org.apache.camel.management.event.ExchangeSendingEvent) EventObject(java.util.EventObject)

Example 77 with EventObject

use of java.util.EventObject in project camel by apache.

the class DebugExceptionEventBreakpointTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    breakpoint = new BreakpointSupport() {

        public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
            AbstractExchangeEvent aee = (AbstractExchangeEvent) event;
            Exception e = aee.getExchange().getException();
            logs.add("Breakpoint at " + definition + " caused by: " + e.getClass().getSimpleName() + "[" + e.getMessage() + "]");
        }
    };
    exceptionCondition = new ConditionSupport() {

        public boolean matchEvent(Exchange exchange, EventObject event) {
            return event instanceof ExchangeFailedEvent;
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) ExchangeFailedEvent(org.apache.camel.management.event.ExchangeFailedEvent) BreakpointSupport(org.apache.camel.impl.BreakpointSupport) ConditionSupport(org.apache.camel.impl.ConditionSupport) AbstractExchangeEvent(org.apache.camel.management.event.AbstractExchangeEvent) EventObject(java.util.EventObject)

Example 78 with EventObject

use of java.util.EventObject in project camel by apache.

the class EventHelper method notifyCamelContextStartupFailed.

public static void notifyCamelContextStartupFailed(CamelContext context, Throwable cause) {
    ManagementStrategy management = context.getManagementStrategy();
    if (management == null) {
        return;
    }
    List<EventNotifier> notifiers = management.getEventNotifiers();
    if (notifiers == null || notifiers.isEmpty()) {
        return;
    }
    for (EventNotifier notifier : notifiers) {
        if (notifier.isIgnoreCamelContextEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createCamelContextStartupFailureEvent(context, cause);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
Also used : ManagementStrategy(org.apache.camel.spi.ManagementStrategy) EventNotifier(org.apache.camel.spi.EventNotifier) EventFactory(org.apache.camel.spi.EventFactory) EventObject(java.util.EventObject)

Example 79 with EventObject

use of java.util.EventObject in project camel by apache.

the class EventHelper method notifyCamelContextStarted.

public static void notifyCamelContextStarted(CamelContext context) {
    ManagementStrategy management = context.getManagementStrategy();
    if (management == null) {
        return;
    }
    List<EventNotifier> notifiers = management.getEventNotifiers();
    if (notifiers == null || notifiers.isEmpty()) {
        return;
    }
    for (EventNotifier notifier : notifiers) {
        if (notifier.isIgnoreCamelContextEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createCamelContextStartedEvent(context);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
Also used : ManagementStrategy(org.apache.camel.spi.ManagementStrategy) EventNotifier(org.apache.camel.spi.EventNotifier) EventFactory(org.apache.camel.spi.EventFactory) EventObject(java.util.EventObject)

Example 80 with EventObject

use of java.util.EventObject in project camel by apache.

the class EventHelper method notifyCamelContextResuming.

public static void notifyCamelContextResuming(CamelContext context) {
    ManagementStrategy management = context.getManagementStrategy();
    if (management == null) {
        return;
    }
    List<EventNotifier> notifiers = management.getEventNotifiers();
    if (notifiers == null || notifiers.isEmpty()) {
        return;
    }
    for (EventNotifier notifier : notifiers) {
        if (notifier.isIgnoreCamelContextEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createCamelContextResumingEvent(context);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
Also used : ManagementStrategy(org.apache.camel.spi.ManagementStrategy) EventNotifier(org.apache.camel.spi.EventNotifier) EventFactory(org.apache.camel.spi.EventFactory) EventObject(java.util.EventObject)

Aggregations

EventObject (java.util.EventObject)111 EventFactory (org.apache.camel.spi.EventFactory)25 EventNotifier (org.apache.camel.spi.EventNotifier)25 ManagementStrategy (org.apache.camel.spi.ManagementStrategy)25 AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)21 EventNotifierSupport (org.apache.camel.support.EventNotifierSupport)15 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)10 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)9 Hashtable (java.util.Hashtable)8 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)7 ProgressDialogListener (org.vcell.util.ProgressDialogListener)7 Test (org.junit.Test)6 MouseEvent (java.awt.event.MouseEvent)4 File (java.io.File)4 ExchangeCompletedEvent (org.apache.camel.management.event.ExchangeCompletedEvent)4 ClientConfig (com.hazelcast.client.config.ClientConfig)3 Design (edu.cmu.cs.hcii.cogtool.model.Design)3 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)3 DesignEditorFrame (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)3 PreferencesHandler (jmri.plaf.macosx.PreferencesHandler)3