private void removeBisEventNotifiers(CamelContext camelContext) { ManagementStrategy managementStrategy = camelContext.getManagementStrategy(); managementStrategy.getEventNotifiers().stream() .filter(notifier -> notifier instanceof BisEventNotifierSupport) .forEach(managementStrategy::removeEventNotifier); }
@Override public void stop() throws Exception { // unregister mbean camelContext.getManagementStrategy().unmanageObject(this); }
@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."); } }
@Override public void start() throws Exception { // register mbean final String contextName = camelContext.getName(); final String name = String.format("io.syndesis.camel:context=%s,type=context,name=\"%s\"", contextName, contextName); final ObjectName instance = ObjectName.getInstance(name); camelContext.getManagementStrategy().manageNamedObject(this, instance); LOG.info("Registered mbean {}", instance); }
private static void configurePerformanceStatistics(CamelContext context, Object value) { ManagementStatisticsLevel level = ManagementStatisticsLevel.valueOf(value.toString()); context.getManagementStrategy().setStatisticsLevel(level); }
@Override public void configure(CamelContext context) { context.getManagementStrategy().getManagementAgent().setCreateConnector(true); } });
private ManagedCamelContext getManagedContext(CamelContext camelContext) { ManagementObjectStrategy managementObjectStrategy = camelContext.getManagementStrategy() .getManagementObjectStrategy(); return (ManagedCamelContext) managementObjectStrategy .getManagedObjectForCamelContext(camelContext); }
@Override protected void doStop() throws Exception { // stop event notifier camelContext.getManagementStrategy().removeEventNotifier(eventNotifier); ServiceHelper.stopService(eventNotifier); // remove route policy camelContext.getRoutePolicyFactories().remove(this); }
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); // stop and close collector ServiceHelper.stopAndShutdownService(spanReporter); if (spanReporter instanceof Closeable) { IOHelper.close((Closeable) spanReporter); } // clear braves braves.clear(); // remove route policy camelContext.getRoutePolicyFactories().remove(this); }
public LocalCamelFacade(CamelContext camelContext) throws Exception { super(camelContext.getManagementName(), camelContext.getManagementStrategy().getManagementAgent().getMBeanServer()); } }
public RouteDetailsInfo(final CamelContext camelContext, final Route route) { super(route); if (camelContext.getManagementStrategy().getManagementAgent() != null) { this.routeDetails = new RouteDetails(camelContext.getManagedRoute(route.getId(), ManagedRouteMBean.class)); } }
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)); } }
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; }
private MBeanServer getMBeanServer() { return camelContext.getManagementStrategy().getManagementAgent().getMBeanServer(); } }
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)); }
@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; } }
protected CamelContext createCamelContext() throws Exception { CamelContext context = super.createCamelContext(); context.addComponent("some-ws-iti", new SomeItiComponent()); DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context .getManagementStrategy().getManagementNamingStrategy(); naming.setHostName("localhost"); naming.setDomainName("org.apache.camel"); return context; }