Source:
<code>public void afterSingletonsInstantiated() { Assert.state(this.applicationContext != null, "'applicationContext' must not be null"); Assert.state(MANAGEMENT_CONFIGURER_NAME.equals(this.beanName), getClass().getSimpleName() + " bean name must be " + MANAGEMENT_CONFIGURER_NAME); ClassLoader classLoader = IntegrationManagementConfigurer.class.getClassLoader(); if (ClassUtils.isPresent("io.micrometer.core.instrument.MeterRegistry", classLoader)) { try { Class<?> captor = ClassUtils.forName( "org.springframework.integration.support.management.micrometer.MicrometerMetricsCaptor", classLoader); Method method = captor.getDeclaredMethod("loadCaptor", ApplicationContext.class); <START> this.metricsCaptor = (MetricsCaptor) method.invoke(null, applicationContext); <END> } catch (Exception e) { } } if (this.metricsCaptor != null) { injectCaptor(); registerComponentGauges(); } if (this.metricsFactory == null && StringUtils.hasText(this.metricsFactoryBeanName)) { this.metricsFactory = this.applicationContext.getBean(this.metricsFactoryBeanName, MetricsFactory.class); } if (this.metricsFactory == null) { Map<String, MetricsFactory> factories = this.applicationContext.getBeansOfType(MetricsFactory.class); if (factories.size() == 1) { this.metricsFactory = factories.values().iterator().next(); } } if (this.metricsFactory == null) { this.metricsFactory = new DefaultMetricsFactory(); } this.sourceConfigurers.putAll(this.applicationContext.getBeansOfType(MessageSourceMetricsConfigurer.class)); Map<String, IntegrationManagement> managed = this.applicationContext.getBeansOfType(IntegrationManagement.class); for (Entry<String, IntegrationManagement> entry : managed.entrySet()) { IntegrationManagement bean = entry.getValue(); if (!bean.getOverrides().loggingConfigured) { bean.setLoggingEnabled(this.defaultLoggingEnabled); } String name = entry.getKey(); doConfigureMetrics(bean, name); } this.singletonsInstantiated = true; }</code><technical_language>do need reflection kung-fu? for MicrometerMetricsCaptor.loadCaptor() is static good proper class loading. Thank</technical_language>

Target:
public void afterSingletonsInstantiated() { Assert.state(this.applicationContext != null, "'applicationContext' must not be null"); Assert.state(MANAGEMENT_CONFIGURER_NAME.equals(this.beanName), getClass().getSimpleName() + " bean name must be " + MANAGEMENT_CONFIGURER_NAME); ClassLoader classLoader = IntegrationManagementConfigurer.class.getClassLoader(); if (ClassUtils.isPresent("io.micrometer.core.instrument.MeterRegistry", classLoader)) { try { Class<?> captor = ClassUtils.forName( "org.springframework.integration.support.management.micrometer.MicrometerMetricsCaptor", classLoader); Method method = captor.getDeclaredMethod("loadCaptor", ApplicationContext.class); this.metricsCaptor = (MetricsCaptor) method.invoke(null, this.applicationContext); } catch (Exception e) { } } if (this.metricsCaptor != null) { injectCaptor(); registerComponentGauges(); } if (this.metricsFactory == null && StringUtils.hasText(this.metricsFactoryBeanName)) { this.metricsFactory = this.applicationContext.getBean(this.metricsFactoryBeanName, MetricsFactory.class); } if (this.metricsFactory == null) { Map<String, MetricsFactory> factories = this.applicationContext.getBeansOfType(MetricsFactory.class); if (factories.size() == 1) { this.metricsFactory = factories.values().iterator().next(); } } if (this.metricsFactory == null) { this.metricsFactory = new DefaultMetricsFactory(); } this.sourceConfigurers.putAll(this.applicationContext.getBeansOfType(MessageSourceMetricsConfigurer.class)); Map<String, IntegrationManagement> managed = this.applicationContext.getBeansOfType(IntegrationManagement.class); for (Entry<String, IntegrationManagement> entry : managed.entrySet()) { IntegrationManagement bean = entry.getValue(); if (!bean.getOverrides().loggingConfigured) { bean.setLoggingEnabled(this.defaultLoggingEnabled); } String name = entry.getKey(); doConfigureMetrics(bean, name); } this.singletonsInstantiated = true; }