Refine search
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."); } }
public LocalCamelFacade(CamelContext camelContext) throws Exception { super(camelContext.getManagementName(), camelContext.getManagementStrategy().getManagementAgent().getMBeanServer()); } }
@Override protected void doStop() throws Exception { // stop event notifier camelContext.getManagementStrategy().removeEventNotifier(eventNotifier); ServiceHelper.stopService(eventNotifier); // remove route policy camelContext.getRoutePolicyFactories().remove(this); }
&& camelContext.getStatus().isStopped()) { LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName()); try { LOG.debug("Injecting following route into the CamelContext: {}", routesBuilder); camelContext.addRoutes(routesBuilder); } catch (Exception e) { throw new CamelSpringBootInitializationException(e); camelContext.getManagementStrategy().addEventNotifier(notifier); camelContext.getManagementStrategy().addEventNotifier(notifier); camelContext.getManagementStrategy().addEventNotifier(new EventNotifierSupport() { @Override public void notify(EventObject eventObject) throws Exception {
ObjectHelper.notNull(camelContext, "CamelContext", this); camelContext.getManagementStrategy().addEventNotifier(eventNotifier); if (!camelContext.getRoutePolicyFactories().contains(this)) { camelContext.addRoutePolicyFactory(this);
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)); }
protected CamelContext createCamelContext() throws Exception { CamelContext answer = new DefaultCamelContext(); // simulate JMS with the Mock component answer.addComponent("jms", answer.getComponent("mock")); // enable connector for remote management answer.getManagementStrategy().getManagementAgent().setCreateConnector(true); return answer; }
@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; } }
@Override protected void doStart() throws Exception { if (metricsRegistry == null) { Registry camelRegistry = getCamelContext().getRegistry(); metricsRegistry = camelRegistry.lookupByNameAndType(MetricsComponent.METRIC_REGISTRY_NAME, MetricRegistry.class); ManagementAgent agent = getCamelContext().getManagementStrategy().getManagementAgent(); if (agent != null) { MBeanServer server = agent.getMBeanServer();
@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); }
camelContext.disableJMX(); camelContext.getShutdownStrategy().setTimeout(config.getShutdownTimeout()); camelContext.getShutdownStrategy().setSuppressLoggingOnTimeout(config.isShutdownSuppressLoggingOnTimeout()); camelContext.getShutdownStrategy().setShutdownNowOnTimeout(config.isShutdownNowOnTimeout()); camelContext.getShutdownStrategy().setShutdownRoutesInReverseOrder(config.isShutdownRoutesInReverseOrder()); camelContext.setLoadTypeConverters(config.isLoadTypeConverters()); if (camelContext.getManagementStrategy().getManagementAgent() != null) { camelContext.getManagementStrategy().getManagementAgent().setEndpointRuntimeStatisticsEnabled(config.isEndpointRuntimeStatisticsEnabled()); camelContext.getManagementStrategy().getManagementAgent().setStatisticsLevel(config.getJmxManagementStatisticsLevel()); camelContext.getManagementStrategy().getManagementAgent().setManagementNamePattern(config.getJmxManagementNamePattern()); camelContext.getManagementStrategy().getManagementAgent().setCreateConnector(config.isJmxCreateConnector());
if (context.getNameStrategy() instanceof DefaultCamelContextNameStrategy) { context.setNameStrategy(nameStrategy(annotated)); DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class); adapted.setRegistry(new CdiCamelRegistry(manager)); adapted.setInjector(new CdiCamelInjector(context.getInjector(), manager)); context.getManagementStrategy().addEventNotifier(new CdiEventNotifier(manager, qualifiers));
ClassLoader classLoader = camelctx.getApplicationContextClassLoader(); IllegalStateAssertion.assertTrue(classLoader instanceof ModuleClassLoader, "Invalid class loader association: " + classLoader); ManagementStrategy mgmtStrategy = camelctx.getManagementStrategy(); mgmtStrategy.addEventNotifier(new EventNotifierSupport() {
camelContext.addInterceptStrategy(tracer); final ManagementStrategy managementStrategy = camelContext.getManagementStrategy(); registerPropertyForBeanType(applicationContext, RuntimeEndpointRegistry.class, camelContext::setRuntimeEndpointRegistry); registerPropertiesForBeanTypes(applicationContext, TypeConverters.class, camelContext.getTypeConverterRegistry()::addTypeConverters); final Predicate<EventNotifier> containsEventNotifier = managementStrategy.getEventNotifiers()::contains; registerPropertiesForBeanTypesWithCondition(applicationContext, EventNotifier.class, containsEventNotifier.negate(), managementStrategy::addEventNotifier);
@Override public void manage(CamelContext context) throws Exception { context.getManagementStrategy().addEventNotifier(this); }
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; }
public RouteDetailsEndpointInfo(final CamelContext camelContext, final Route route) { super(route); if (camelContext.getManagementStrategy().getManagementAgent() != null) { this.routeDetails = new RouteDetails(camelContext.getManagedRoute(route.getId(), ManagedRouteMBean.class)); } }
@Override public void configure(CamelContext context) { context.getManagementStrategy().getManagementAgent().setCreateConnector(true); } });
private void removeBisEventNotifiers(CamelContext camelContext) { ManagementStrategy managementStrategy = camelContext.getManagementStrategy(); managementStrategy.getEventNotifiers().stream() .filter(notifier -> notifier instanceof BisEventNotifierSupport) .forEach(managementStrategy::removeEventNotifier); }
/** * Callback when an endpoint was intercepted with the given mock endpoint * * @param uri the uri * @param endpoint the endpoint * @param mockEndpoint the mocked endpoint * @param mockProducer the mock producer * @return the mock producer */ protected Producer onInterceptEndpoint(String uri, Endpoint endpoint, MockEndpoint mockEndpoint, Producer mockProducer) { CamelContext context = mockEndpoint.getCamelContext(); // the mock endpoint should be registered in JMX try { Object me = context.getManagementStrategy().getManagementObjectStrategy().getManagedObjectForEndpoint(context, mockEndpoint); if (me != null && !context.getManagementStrategy().isManaged(me, null)) { LOG.info("Registering mock endpoint in JMX: {}", mockEndpoint); context.getManagementStrategy().manageObject(me); } } catch (Exception e) { LOG.warn("Error registering mock endpoint in JMX: " + mockEndpoint + " due " + e.getMessage() + ". This exception is ignored."); } return mockProducer; }