Java 类org.apache.camel.spi.EventNotifier 实例源码

项目:Camel    文件:DefaultManagementNamingStrategy.java   
public ObjectName getObjectNameForEventNotifier(CamelContext context, EventNotifier eventNotifier) throws MalformedObjectNameException {
    StringBuilder buffer = new StringBuilder();
    buffer.append(domainName).append(":");
    buffer.append(KEY_CONTEXT + "=").append(getContextId(context)).append(",");
    buffer.append(KEY_TYPE + "=" + TYPE_EVENT_NOTIFIER + ",");

    if (eventNotifier instanceof JmxNotificationEventNotifier) {
        // JMX notifier shall have an easy to use name
        buffer.append(KEY_NAME + "=").append("JmxEventNotifier");
    } else {
        // others can be per instance
        buffer.append(KEY_NAME + "=")
            .append("EventNotifier")
            .append("(").append(ObjectHelper.getIdentityHashCode(eventNotifier)).append(")");
    }
    return createObjectName(buffer);
}
项目:Camel    文件:EventHelper.java   
private static void doNotifyEvent(EventNotifier notifier, EventObject event) {
    // only notify if notifier is started
    boolean started = true;
    if (notifier instanceof StatefulService) {
        started = ((StatefulService) notifier).isStarted();
    }
    if (!started) {
        LOG.debug("Ignoring notifying event {}. The EventNotifier has not been started yet: {}", event, notifier);
        return;
    }

    if (!notifier.isEnabled(event)) {
        LOG.trace("Notifier: {} is not enabled for the event: {}", notifier, event);
        return;
    }

    try {
        notifier.notify(event);
    } catch (Throwable e) {
        LOG.warn("Error notifying event " + event + ". This exception will be ignored. ", e);
    }
}
项目:switchyard    文件:SwitchYardCamelContextImpl.java   
/**
 * Associates camel context with given service domain.
 * 
 * @param domain Domain to associate.
 */
public void setServiceDomain(ServiceDomain domain) {
    _domain = domain;

    for (EventNotifier notifier : getManagementStrategy().getEventNotifiers()) {
        if (notifier instanceof CamelEventBridge) {
            ((CamelEventBridge) notifier).setEventPublisher(domain.getEventPublisher());
        }
    }

    PackageScanClassResolver packageScanClassResolver = findPackageScanClassResolver();
    if (packageScanClassResolver != null) {
        setPackageScanClassResolver(packageScanClassResolver);
    }

    _domain.setProperty(CAMEL_CONTEXT_PROPERTY, this);
}
项目:cleverbus    文件:AsynchEventHelper.java   
private static void doNotifyEvent(EventNotifier notifier, EventObject event) {
    // only notify if notifier is started
    boolean started = true;
    if (notifier instanceof StatefulService) {
        started = ((StatefulService) notifier).isStarted();
    }

    if (!started) {
        Log.debug("Ignoring notifying event {}. The EventNotifier has not been started yet: {}", event, notifier);
        return;
    }

    if (!notifier.isEnabled(event)) {
        Log.debug("Notification of event is disabled: {}", event);
        return;
    }

    try {
        Log.debug("Event {} arrived to notifier {}", event, notifier.getClass().getName());

        notifier.notify(event);
    } catch (Throwable e) {
        Log.warn("Error notifying event " + event + ". This exception will be ignored. ", e);
    }
}
项目:Camel    文件:DefaultManagementStrategy.java   
public void notify(EventObject event) throws Exception {
    if (eventNotifiers != null && !eventNotifiers.isEmpty()) {
        for (EventNotifier notifier : eventNotifiers) {
            if (notifier.isEnabled(event)) {
                notifier.notify(event);
            }
        }
    }
}
项目:Camel    文件:DefaultManagementStrategy.java   
protected void doStartManagementStrategy() throws Exception {
    ObjectHelper.notNull(camelContext, "CamelContext");

    if (eventNotifiers != null) {
        for (EventNotifier notifier : eventNotifiers) {

            // inject CamelContext if the service is aware
            if (notifier instanceof CamelContextAware) {
                CamelContextAware aware = (CamelContextAware) notifier;
                aware.setCamelContext(camelContext);
            }

            ServiceHelper.startService(notifier);
        }
    }

    if (managementAgent != null) {
        ServiceHelper.startService(managementAgent);
        // set the naming strategy using the domain name from the agent
        if (managementNamingStrategy == null) {
            setManagementNamingStrategy(new DefaultManagementNamingStrategy(managementAgent.getMBeanObjectDomainName()));
        }
    }
    if (managementNamingStrategy instanceof CamelContextAware) {
        ((CamelContextAware) managementNamingStrategy).setCamelContext(getCamelContext());
    }
}
项目:Camel    文件:ManagedEventNotifier.java   
public ManagedEventNotifier(CamelContext context, EventNotifier eventNotifier) {
    this.context = context;
    this.eventNotifier = eventNotifier;
    if (eventNotifier instanceof JmxNotificationBroadcasterAware) {
        ((JmxNotificationBroadcasterAware)eventNotifier).setNotificationBroadcaster(this);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyCamelContextStarting(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.createCamelContextStartingEvent(context);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
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);
    }
}
项目:Camel    文件:EventHelper.java   
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);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyCamelContextStopping(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.createCamelContextStoppingEvent(context);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyCamelContextStopped(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.createCamelContextStoppedEvent(context);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyCamelContextStopFailed(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.createCamelContextStopFailureEvent(context, cause);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
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);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyServiceStartupFailure(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.createServiceStartupFailureEvent(context, service, cause);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyRouteStarted(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.createRouteStartedEvent(route);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
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);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyRouteAdded(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.createRouteAddedEvent(route);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyRouteRemoved(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.createRouteRemovedEvent(route);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyExchangeCreated(CamelContext context, Exchange exchange) {
    if (exchange.getProperty(Exchange.NOTIFY_EVENT, false, Boolean.class)) {
        // do not generate events for an notify event
        return;
    }

    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.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeCreatedEvent()) {
            continue;
        }

        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeCreatedEvent(exchange);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyExchangeDone(CamelContext context, Exchange exchange) {
    if (exchange.getProperty(Exchange.NOTIFY_EVENT, false, Boolean.class)) {
        // do not generate events for an notify event
        return;
    }

    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.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeCompletedEvent()) {
            continue;
        }

        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeCompletedEvent(exchange);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyExchangeFailed(CamelContext context, Exchange exchange) {
    if (exchange.getProperty(Exchange.NOTIFY_EVENT, false, Boolean.class)) {
        // do not generate events for an notify event
        return;
    }

    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.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeFailedEvents()) {
            continue;
        }

        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeFailedEvent(exchange);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyExchangeFailureHandling(CamelContext context, Exchange exchange, Processor failureHandler,
                                                 boolean deadLetterChannel, String deadLetterUri) {
    if (exchange.getProperty(Exchange.NOTIFY_EVENT, false, Boolean.class)) {
        // do not generate events for an notify event
        return;
    }

    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.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeFailedEvents()) {
            continue;
        }

        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeFailureHandlingEvent(exchange, failureHandler, deadLetterChannel, deadLetterUri);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyExchangeFailureHandled(CamelContext context, Exchange exchange, Processor failureHandler,
                                                boolean deadLetterChannel, String deadLetterUri) {
    if (exchange.getProperty(Exchange.NOTIFY_EVENT, false, Boolean.class)) {
        // do not generate events for an notify event
        return;
    }

    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.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeFailedEvents()) {
            continue;
        }

        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeFailureHandledEvent(exchange, failureHandler, deadLetterChannel, deadLetterUri);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyExchangeRedelivery(CamelContext context, Exchange exchange, int attempt) {
    if (exchange.getProperty(Exchange.NOTIFY_EVENT, false, Boolean.class)) {
        // do not generate events for an notify event
        return;
    }

    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.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeFailedEvents()) {
            continue;
        }

        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeRedeliveryEvent(exchange, attempt);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyExchangeSending(CamelContext context, Exchange exchange, Endpoint endpoint) {
    if (exchange.getProperty(Exchange.NOTIFY_EVENT, false, Boolean.class)) {
        // do not generate events for an notify event
        return;
    }

    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.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeSentEvents()) {
            continue;
        }

        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeSendingEvent(exchange, endpoint);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyExchangeSent(CamelContext context, Exchange exchange, Endpoint endpoint, long timeTaken) {
    if (exchange.getProperty(Exchange.NOTIFY_EVENT, false, Boolean.class)) {
        // do not generate events for an notify event
        return;
    }

    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.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeSentEvents()) {
            continue;
        }

        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeSentEvent(exchange, endpoint, timeTaken);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyCamelContextSuspending(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.createCamelContextSuspendingEvent(context);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyCamelContextSuspended(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.createCamelContextSuspendedEvent(context);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
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);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyCamelContextResumed(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.createCamelContextResumedEvent(context);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:EventHelper.java   
public static void notifyCamelContextResumeFailed(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.createCamelContextResumeFailureEvent(context, cause);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:BlueprintCamelContext.java   
private void maybeStart() throws Exception {
    LOG.trace("maybeStart: {}", this);

    // allow to register the BluerintCamelContext eager in the OSGi Service Registry, which ex is needed
    // for unit testing with camel-test-blueprint
    boolean eager = "true".equalsIgnoreCase(System.getProperty("registerBlueprintCamelContextEager"));
    if (eager) {
        for (EventNotifier notifier : getManagementStrategy().getEventNotifiers()) {
            if (notifier instanceof OsgiCamelContextPublisher) {
                OsgiCamelContextPublisher publisher = (OsgiCamelContextPublisher) notifier;
                publisher.registerCamelContext(this);
                break;
            }
        }
    }

    // for example from unit testing we want to start Camel later and not
    // when blueprint loading the bundle
    boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
    if (skip) {
        LOG.trace("maybeStart: {} is skipping as System property skipStartingCamelContext is set", this);
        return;
    }

    if (!isStarted() && !isStarting()) {
        LOG.debug("Starting {}", this);
        start();
    } else {
        // ignore as Camel is already started
        LOG.trace("Ignoring maybeStart() as {} is already started", this);
    }
}
项目:cleverbus    文件:AsynchEventHelper.java   
/**
 * Notifies event notifiers.
 *
 * @param exchange the exchange
 * @param callback the callback contract for creating new events.
 */
public static void notifyMsg(Exchange exchange, EventNotifierCallback callback) {
    Assert.notNull(exchange, "the exchange must not be null");

    if (exchange.getProperty(Exchange.NOTIFY_EVENT, false, Boolean.class)) {
        // do not generate events for an notify event
        return;
    }

    CamelContext context = exchange.getContext();

    ManagementStrategy management = context.getManagementStrategy();
    if (management == null) {
        return;
    }

    List<EventNotifier> notifiers = management.getEventNotifiers();
    if (notifiers == null || notifiers.isEmpty()) {
        return;
    }

    for (EventNotifier notifier : notifiers) {
        if (callback.ignore(notifier)) {
            continue;
        }

        // we want to have new event instance for all notifiers
        EventObject event = callback.createEvent(exchange);

        doNotifyEvent(notifier, event);
    }
}
项目:Camel    文件:DefaultManagementObjectStrategy.java   
public Object getManagedObjectForEventNotifier(CamelContext context, EventNotifier eventNotifier) {
    ManagedEventNotifier men = new ManagedEventNotifier(context, eventNotifier);
    men.init(context.getManagementStrategy());
    return men;
}
项目:Camel    文件:DefaultManagementStrategy.java   
public List<EventNotifier> getEventNotifiers() {
    return eventNotifiers;
}
项目:Camel    文件:DefaultManagementStrategy.java   
public void addEventNotifier(EventNotifier eventNotifier) {
    this.eventNotifiers.add(eventNotifier);
}
项目:Camel    文件:DefaultManagementStrategy.java   
public boolean removeEventNotifier(EventNotifier eventNotifier) {
    return eventNotifiers.remove(eventNotifier);
}
项目:Camel    文件:DefaultManagementStrategy.java   
public void setEventNotifiers(List<EventNotifier> eventNotifiers) {
    this.eventNotifiers = eventNotifiers;
}
项目:Camel    文件:ManagedEventNotifier.java   
public EventNotifier getEventNotifier() {
    return eventNotifier;
}