Search in sources :

Example 11 with EventObject

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

the class MultipleEventNotifierEventsTest 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 {
        }
    });
    context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() {

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

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

        @Override
        protected void doStart() throws Exception {
            setIgnoreCamelContextEvents(true);
            setIgnoreServiceEvents(true);
            setIgnoreRouteEvents(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 12 with EventObject

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

the class UnitOfWorkProducerTest 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 event instanceof ExchangeCompletedEvent;
        }

        @Override
        protected void doStart() throws Exception {
        }

        @Override
        protected void doStop() throws Exception {
        }
    });
    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 13 with EventObject

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

the class DebugTest method setUp.

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

        public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            String body = exchange.getIn().getBody(String.class);
            logs.add("Breakpoint at " + definition + " with body: " + body);
        }

        public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
            String body = exchange.getIn().getBody(String.class);
            logs.add("Breakpoint event " + event.getClass().getSimpleName() + " with body: " + body);
        }
    };
    camelCondition = new ConditionSupport() {

        public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            return body().contains("Camel").matches(exchange);
        }
    };
    mockCondition = new ConditionSupport() {

        public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            // match when sending to mocks
            if (definition instanceof ToDefinition) {
                ToDefinition to = (ToDefinition) definition;
                return to.getUriOrRef().startsWith("mock");
            }
            return false;
        }
    };
    doneCondition = new ConditionSupport() {

        @Override
        public boolean matchEvent(Exchange exchange, EventObject event) {
            return event instanceof ExchangeCompletedEvent;
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) ToDefinition(org.apache.camel.model.ToDefinition) Processor(org.apache.camel.Processor) BreakpointSupport(org.apache.camel.impl.BreakpointSupport) ConditionSupport(org.apache.camel.impl.ConditionSupport) ExchangeCompletedEvent(org.apache.camel.management.event.ExchangeCompletedEvent) EventObject(java.util.EventObject)

Example 14 with EventObject

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

the class EventHelper method notifyRouteStopped.

public static void notifyRouteStopped(CamelContext context, Route route) {
    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.isIgnoreRouteEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createRouteStoppedEvent(route);
        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 15 with EventObject

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

the class EventHelper method notifyServiceStopFailure.

public static void notifyServiceStopFailure(CamelContext context, Object service, 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.isIgnoreServiceEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createServiceStopFailureEvent(context, service, 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)

Aggregations

EventObject (java.util.EventObject)91 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 ExchangeCompletedEvent (org.apache.camel.management.event.ExchangeCompletedEvent)4 ClientConfig (com.hazelcast.client.config.ClientConfig)3 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)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 MouseEvent (java.awt.event.MouseEvent)3 PreferencesHandler (jmri.plaf.macosx.PreferencesHandler)3 ExchangeSendingEvent (org.apache.camel.management.event.ExchangeSendingEvent)3 ListenerConfig (com.hazelcast.config.ListenerConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2