Source:
<code>public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException { BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; List<GlobalChannelInterceptorWrapper> globalChannelInterceptors = new ManagedList<GlobalChannelInterceptorWrapper>(); Map<String, ChannelInterceptor> beansOfType = beanFactory.getBeansOfType(ChannelInterceptor.class); for (Map.Entry<String, ChannelInterceptor> entry : beansOfType.entrySet()) { String beanName = entry.getKey(); ChannelInterceptor interceptor = entry.getValue(); GlobalChannelInterceptor annotation = AnnotationUtils.findAnnotation(interceptor.getClass(), GlobalChannelInterceptor.class); if (annotation == null) { BeanDefinition beanDefinition = registry.getBeanDefinition(beanName); if (beanDefinition instanceof AnnotatedBeanDefinition) { StandardMethodMetadata beanMethod = (StandardMethodMetadata) beanDefinition.getSource(); annotation = AnnotationUtils.findAnnotation(beanMethod.getIntrospectedMethod(), GlobalChannelInterceptor.class); } } if (annotation != null) { GlobalChannelInterceptorWrapper wrapper = new GlobalChannelInterceptorWrapper(interceptor); wrapper.setPatterns(annotation.patterns()); wrapper.setOrder(annotation.order()); globalChannelInterceptors.add(wrapper); } } if (beanFactory.containsBeanDefinition(IntegrationContextUtils.GLOBAL_CHANNEL_INTERCEPTOR_POST_PROCESSOR_BEAN_NAME)) { BeanDefinition postProcessorDef = registry.getBeanDefinition(IntegrationContextUtils.GLOBAL_CHANNEL_INTERCEPTOR_POST_PROCESSOR_BEAN_NAME); @SuppressWarnings("unchecked") List<Object> globalChannelInterceptorsValue = (List<Object>) postProcessorDef .getConstructorArgumentValues().getIndexedArgumentValues().values().iterator().next().getValue(); <START> globalChannelInterceptorsValue.addAll(globalChannelInterceptors); <END> } else { BeanDefinitionBuilder postProcessorBuilder = BeanDefinitionBuilder.genericBeanDefinition(GlobalChannelInterceptorBeanPostProcessor.class); postProcessorBuilder.addConstructorArgValue(globalChannelInterceptors); BeanDefinition beanDef = postProcessorBuilder.getBeanDefinition(); registry.registerBeanDefinition(IntegrationContextUtils.GLOBAL_CHANNEL_INTERCEPTOR_POST_PROCESSOR_BEAN_NAME, beanDef); } }</code><technical_language>this bean created yet</technical_language>

Target:
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException { BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; for (String beanName : registry.getBeanDefinitionNames()) { BeanDefinition beanDefinition = registry.getBeanDefinition(beanName); if (beanDefinition instanceof AnnotatedBeanDefinition) { AnnotationMetadata metadata = ((AnnotatedBeanDefinition) beanDefinition).getMetadata(); Map<String, Object> annotationAttributes = metadata.getAnnotationAttributes(GlobalChannelInterceptor.class.getName()); if (CollectionUtils.isEmpty(annotationAttributes) && beanDefinition.getSource() instanceof MethodMetadata) { MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource(); annotationAttributes = beanMethod.getAnnotationAttributes(GlobalChannelInterceptor.class.getName()); } if (!CollectionUtils.isEmpty(annotationAttributes)) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(GlobalChannelInterceptorWrapper.class) .addConstructorArgReference(beanName) .addPropertyValue("patterns", annotationAttributes.get("patterns")) .addPropertyValue("order", annotationAttributes.get("order")); BeanDefinitionReaderUtils.registerWithGeneratedName(builder.getBeanDefinition(), registry); } } } }