Search in sources :

Example 71 with EventObject

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

the class EventNotifierRedeliveryEventsTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext(createRegistry());
    context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() {

        public void notify(EventObject event) throws Exception {
            events.add(event);
        }

        public boolean isEnabled(EventObject event) {
            return true;
        }

        @Override
        protected void doStart() throws Exception {
            setIgnoreCamelContextEvents(true);
            setIgnoreRouteEvents(true);
            setIgnoreServiceEvents(true);
        }

        @Override
        protected void doStop() throws Exception {
        }
    });
    return context;
}
Also used : EventNotifierSupport(org.apache.camel.support.EventNotifierSupport) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) EventObject(java.util.EventObject)

Example 72 with EventObject

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

the class EventNotifierServiceStoppingFailedEventTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.addService(new MyService("A", false));
    context.addService(new MyService("B", true));
    context.addService(new MyService("C", false));
    context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() {

        public void notify(EventObject event) throws Exception {
            events.add(event);
        }

        public boolean isEnabled(EventObject event) {
            return true;
        }

        @Override
        protected void doStart() throws Exception {
        }

        @Override
        protected void doStop() throws Exception {
        }
    });
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) EventNotifierSupport(org.apache.camel.support.EventNotifierSupport) EventObject(java.util.EventObject)

Example 73 with EventObject

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

the class EventNotifierEventsTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext(createRegistry());
    context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() {

        public void notify(EventObject event) throws Exception {
            events.add(event);
        }

        public boolean isEnabled(EventObject event) {
            return true;
        }

        @Override
        protected void doStart() throws Exception {
        }

        @Override
        protected void doStop() throws Exception {
        }
    });
    return context;
}
Also used : EventNotifierSupport(org.apache.camel.support.EventNotifierSupport) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) EventObject(java.util.EventObject)

Example 74 with EventObject

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

the class EventNotifierExchangeCompletedTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext(createRegistry());
    context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() {

        public void notify(EventObject event) throws Exception {
            events.add(event);
        }

        public boolean isEnabled(EventObject event) {
            // we only want the completed event
            return event instanceof ExchangeCompletedEvent;
        // you can add additional filtering such as the exchange
        // should be from a specific endpoint or route
        // just return true for the events you like
        }

        protected void doStart() throws Exception {
        // noop
        }

        protected void doStop() throws Exception {
        // noop
        }
    });
    return context;
}
Also used : EventNotifierSupport(org.apache.camel.support.EventNotifierSupport) ExchangeCompletedEvent(org.apache.camel.management.event.ExchangeCompletedEvent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) EventObject(java.util.EventObject)

Example 75 with EventObject

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

the class EventNotifierExchangeSentParallelTest method testExchangeSentRecipient.

public void testExchangeSentRecipient() throws Exception {
    getMockEndpoint("mock:result").expectedMessageCount(1);
    template.sendBodyAndHeader("direct:foo", "Hello World", "foo", "direct:cool,direct:start");
    // wait for the message to be fully done using oneExchangeDone
    assertMockEndpointsSatisfied();
    assertTrue(oneExchangeDone.matchesMockWaitTime());
    // stop Camel to let all the events complete
    context.stop();
    assertTrue("Should be 11 or more, was: " + events.size(), events.size() >= 11);
    // we run parallel so just assert we got 6 sending and 6 sent events
    int sent = 0;
    int sending = 0;
    for (EventObject event : events) {
        if (event instanceof ExchangeSendingEvent) {
            sending++;
        } else {
            sent++;
        }
    }
    assertTrue("There should be 5 or more, was " + sending, sending >= 5);
    assertTrue("There should be 5 or more, was " + sent, sent >= 5);
}
Also used : ExchangeSendingEvent(org.apache.camel.management.event.ExchangeSendingEvent) 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