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;
}
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;
}
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;
}
};
}
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);
}
}
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);
}
}
Aggregations