Merge pull request #7744 from Artem Bilan

* gh-7744:
  Make use of new extensions point in IntegrationComponentScanRegistrar
pull/8128/head
Andy Wilkinson 8 years ago
commit 4e3d606fad

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,8 @@
package org.springframework.boot.autoconfigure.integration; package org.springframework.boot.autoconfigure.integration;
import java.util.LinkedHashMap; import java.util.Collection;
import java.util.List; import java.util.Collections;
import java.util.Map;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
@ -50,33 +49,16 @@ class IntegrationAutoConfigurationScanRegistrar extends IntegrationComponentScan
@Override @Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
final BeanDefinitionRegistry registry) { final BeanDefinitionRegistry registry) {
super.registerBeanDefinitions( super.registerBeanDefinitions(new StandardAnnotationMetadata(
new IntegrationComponentScanConfigurationMetaData(this.beanFactory), IntegrationComponentScanConfiguration.class, true), registry);
registry);
} }
private static class IntegrationComponentScanConfigurationMetaData @Override
extends StandardAnnotationMetadata { protected Collection<String> getBasePackages(
AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
private final BeanFactory beanFactory; return AutoConfigurationPackages.has(this.beanFactory)
? AutoConfigurationPackages.get(this.beanFactory)
IntegrationComponentScanConfigurationMetaData(BeanFactory beanFactory) { : Collections.emptyList();
super(IntegrationComponentScanConfiguration.class, true);
this.beanFactory = beanFactory;
}
@Override
public Map<String, Object> getAnnotationAttributes(String annotationName) {
Map<String, Object> attributes = super.getAnnotationAttributes(
annotationName);
if (IntegrationComponentScan.class.getName().equals(annotationName)
&& AutoConfigurationPackages.has(this.beanFactory)) {
List<String> packages = AutoConfigurationPackages.get(this.beanFactory);
attributes = new LinkedHashMap<String, Object>(attributes);
attributes.put("value", packages.toArray(new String[packages.size()]));
}
return attributes;
}
} }
@IntegrationComponentScan @IntegrationComponentScan

Loading…
Cancel
Save