@Override protected void doStart() throws Exception { LOG.info("Starting notifier " + notifier); ServiceHelper.startService(notifier); managementStrategy.addEventNotifier(notifier); }
@Override public void manage(CamelContext context) throws Exception { context.getManagementStrategy().addEventNotifier(this); }
@Override public void manage(CamelContext context) throws Exception { context.getManagementStrategy().addEventNotifier(this); }
private void registerEventNotifier(ApplicationContext applicationContext, Class<? extends EventNotifierSupport> notifierClass) { EventNotifierSupport bean = applicationContext.getBean(notifierClass); ManagementStrategy managementStrategy = camelContext.getManagementStrategy(); if (!managementStrategy.getEventNotifiers().contains(bean)) { managementStrategy.addEventNotifier(bean); } else { LOG.debug("Event notifier " + bean + " is already registered."); } }
/** * Adds new event notifier. * <p> * Use manual adding via this method or use {@link EventNotifier} annotation * for automatic registration. Don't use both. * * @param eventNotifier the event notifier */ protected final void addEventNotifier(EventNotifier eventNotifier) { Assert.notNull(eventNotifier, "the eventNotifier must not be null"); getContext().getManagementStrategy().addEventNotifier(eventNotifier); }
/** * Create a new instance of OsgiSwitchYardCamelContextImpl. * @param bundleContext bundleContext */ public OsgiSwitchYardCamelContextImpl(BundleContext bundleContext) { _bundleContext = bundleContext; OsgiCamelContextHelper.osgiUpdate(this, bundleContext); // Ensure we publish this CamelContext to the OSGi service registry getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundleContext)); }
@Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); // setup the application context classloader with the bundle delegating classloader ClassLoader cl = new BundleDelegatingClassLoader(bundleContext.getBundle()); LOG.debug("Set the application context classloader to: {}", cl); getContext().setApplicationContextClassLoader(cl); osgiCamelContextPublisher = new OsgiCamelContextPublisher(bundleContext); osgiCamelContextPublisher.start(); getContext().getManagementStrategy().addEventNotifier(osgiCamelContextPublisher); try { getClass().getClassLoader().loadClass("org.osgi.service.event.EventAdmin"); getContext().getManagementStrategy().addEventNotifier(new OsgiEventAdminNotifier(bundleContext)); } catch (Throwable t) { // Ignore, if the EventAdmin package is not available, just don't use it LOG.debug("EventAdmin package is not available, just don't use it"); } // ensure routes is setup setupRoutes(); }
/** * Creates new camel context. * @param autoDetectCdi Should cdi integration be auto detected and enabled. */ public SwitchYardCamelContextImpl(boolean autoDetectCdi) { _cdiIntegration = autoDetectCdi; if (isEnableCdiIntegration()) { CDISupport.setCdiInjector(this); } else { CommonCamelLogger.ROOT_LOGGER.cdiNotDetected(); } getManagementStrategy().addEventNotifier(new CamelEventBridge()); }
context.getManagementStrategy().addEventNotifier(new CdiEventNotifier(manager, qualifiers));
@Override protected void doStart() throws Exception { ObjectHelper.notNull(camelContext, "CamelContext", this); camelContext.getManagementStrategy().addEventNotifier(eventNotifier); if (!camelContext.getRoutePolicyFactories().contains(this)) { camelContext.addRoutePolicyFactory(this); } camelContext.addLogListener(logListener); if (tracer == null) { Set<Tracer> tracers = camelContext.getRegistry().findByType(Tracer.class); if (tracers.size() == 1) { tracer = tracers.iterator().next(); } } if (tracer == null) { tracer = TracerResolver.resolveTracer(); } if (tracer == null) { // No tracer is available, so setup NoopTracer tracer = NoopTracerFactory.create(); } ServiceHelper.startServices(eventNotifier); }
public CamelContext getOrMakeContextByRid(String rid,Component component){ CamelContext context; Map<String,CamelContext> contextMap = Application.get().getMetaData(INTEGRATION_SESSIONS_KEY); if (contextMap.containsKey(rid)){ context = contextMap.get(rid); }else{ IOrientDbSettings dbSettings = OrientDbWebApplication.get().getOrientDbSettings(); OrientDbWebSession session = OrientDbWebSession.get(); if (session.getUsername()==null){ throw new UnauthorizedActionException(component, Component.RENDER); } context = new DefaultCamelContext(); Map<String, String> properties = context.getProperties(); properties.put(OrientDBComponent.DB_URL, dbSettings.getDBUrl()); properties.put(OrientDBComponent.DB_USERNAME, session.getUsername()); properties.put(OrientDBComponent.DB_PASSWORD, session.getPassword()); context.setProperties(properties); context.getManagementStrategy().addEventNotifier(new CamelEventHandler(new OCamelTaskSessionCallback(context),this,context)); contextMap.put(rid, context); } return context; }
protected void setupCamelContext(final BundleContext bundleContext, final String camelContextId) throws Exception { // Set up CamelContext if (camelContextId != null) { context.setNameStrategy(new ExplicitCamelContextNameStrategy(camelContextId)); } // Add routes for (RoutesBuilder route : getRouteBuilders()) { context.addRoutes(configure(context, route, log)); } // ensure we publish this CamelContext to the OSGi service registry context.getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundleContext)); }
ObjectHelper.notNull(camelContext, "CamelContext", this); camelContext.getManagementStrategy().addEventNotifier(eventNotifier); if (!camelContext.getRoutePolicyFactories().contains(this)) { camelContext.addRoutePolicyFactory(this);
camelContext.getManagementStrategy().addEventNotifier(notifier); camelContext.getManagementStrategy().addEventNotifier(notifier); camelContext.getManagementStrategy().addEventNotifier(new EventNotifierSupport() { @Override public void notify(EventObject eventObject) throws Exception {
@Override public T produce(CreationalContext<T> ctx) { T context = super.produce(ctx); // Register the context in the OSGi registry BundleContext bundle = BundleContextUtils.getBundleContext(getClass()); context.getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundle)); if (!(context instanceof DefaultCamelContext)) { // Fail fast for the time being to avoid side effects by some methods get declared on the CamelContext interface throw new InjectionException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext"); } DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class); adapted.setRegistry(OsgiCamelContextHelper.wrapRegistry(context, context.getRegistry(), bundle)); CamelContextNameStrategy strategy = context.getNameStrategy(); OsgiCamelContextHelper.osgiUpdate(adapted, bundle); // FIXME: the above call should not override explicit strategies provided by the end user or should decorate them instead of overriding them completely if (!(strategy instanceof DefaultCamelContextNameStrategy)) { context.setNameStrategy(strategy); } return context; } }
mgmtStrategy.addEventNotifier(new EventNotifierSupport() {
mgmtStrategy.addEventNotifier(new EventNotifierSupport() {