diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java index a09f033833..306b957e78 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java @@ -248,7 +248,7 @@ class ConfigurationClassParser { // the candidate class is an ImportSelector -> delegate to it to determine imports try { ImportSelector selector = BeanUtils.instantiateClass(Class.forName(candidate), ImportSelector.class); - ImportSelector.Context context = new ImportSelector.Context(importingClassMetadata, this.registry); + ImportSelectorContext context = new ImportSelectorContext(importingClassMetadata, this.registry); processImport(configClass, selector.selectImports(context), false); } catch (ClassNotFoundException ex) { throw new IllegalStateException(ex); diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/Import.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/Import.java index 36d6d55732..ce0ea87858 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/Import.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/Import.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,26 +23,26 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Indicates one or more @{@link @Configuration} classes to import. + * Indicates one or more @{@link Configuration} classes to import. * *
Provides functionality equivalent to the {@code
{@link Bean @Bean} definitions declared in imported {@code @Configuration} classes - * should be accessed by using {@link Autowired @Autowired} injection. Either the bean - * itself can be autowired, or the configuration class instance declaring the bean can be - * autowired. The latter approach allows for explicit, IDE-friendly navigation between + *
@{@link Bean} definitions declared in imported {@code @Configuration} classes + * should be accessed by using @{@link Autowired} injection. Either the bean itself can + * be autowired, or the configuration class instance declaring the bean can be autowired. + * The latter approach allows for explicit, IDE-friendly navigation between * {@code @Configuration} class methods. * *
If XML or other non-{@code @Configuration} bean definition resources need to be - * imported, use {@link ImportResource @ImportResource} + * imported, use @{@link ImportResource} * * @author Chris Beams * @since 3.0 * @see Configuration - * @see ImportResource * @see ImportSelector + * @see ImportResource */ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @@ -50,7 +50,7 @@ import java.lang.annotation.Target; public @interface Import { /** - * The {@link Configuration} class or classes to import. + * The @{@link Configuration} and/or {@link ImportSelector} classes to import. */ Class>[] value(); } diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/ImportSelector.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/ImportSelector.java index 76920bc97e..a4d8b61b70 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/ImportSelector.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/ImportSelector.java @@ -16,17 +16,14 @@ package org.springframework.context.annotation; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.core.type.AnnotationMetadata; - /** * Interface to be implemented by types that determine which @{@link Configuration} * class(es) should be imported based on a given selection criteria, usually one or more * annotation attributes. * *
In certain cases, an {@code ImportSelector} may register additional bean definitions
- * through the {@link BeanDefinitionRegistry} available in the
- * {@code Context} provided to the {@link #selectImports} method.
+ * through the {@code BeanDefinitionRegistry} available in the
+ * {@link ImportSelectorContext} provided to the {@link #selectImports} method.
*
* @author Chris Beams
* @since 3.1
@@ -40,37 +37,9 @@ public interface ImportSelector {
* the {@code AnnotationMetadata} of the importing {@code @Configuration} class and
* optionally register any {@code BeanDefinition}s necessary to support the selected
* classes.
- * @param context containing the AnnotationMetadata of the importing @{@link
- * Configuration} class and the enclosing {@link BeanDefinitionRegistry}.
+ * @param context containing the {@code AnnotationMetadata} of the importing @{@link
+ * Configuration} class and the enclosing {@code BeanDefinitionRegistry}.
*/
- String[] selectImports(Context context);
-
-
- /**
- * Context object holding the {@link AnnotationMetadata} of the {@code @Configuration}
- * class that imported this {@link ImportSelector} as well as the enclosing
- * {@link BeanDefinitionRegistry} to allow for conditional bean definition
- * registration when necessary.
- *
- * @author Chris Beams
- * @since 3.1
- */
- static class Context {
- private final AnnotationMetadata importingClassMetadata;
- private final BeanDefinitionRegistry registry;
-
- public Context(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
- this.importingClassMetadata = importingClassMetadata;
- this.registry = registry;
- }
-
- public AnnotationMetadata getImportingClassMetadata() {
- return this.importingClassMetadata;
- }
-
- public BeanDefinitionRegistry getBeanDefinitionRegistry() {
- return registry;
- }
- }
+ String[] selectImports(ImportSelectorContext context);
}
diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/ImportSelectorContext.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/ImportSelectorContext.java
new file mode 100644
index 0000000000..ef23c63f9c
--- /dev/null
+++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/ImportSelectorContext.java
@@ -0,0 +1,33 @@
+package org.springframework.context.annotation;
+
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.core.type.AnnotationMetadata;
+
+/**
+ * Context object holding the {@link AnnotationMetadata} of the @{@link Configuration}
+ * class that imported the current {@link ImportSelector} as well as the enclosing
+ * {@link BeanDefinitionRegistry} to allow for conditional bean definition
+ * registration when necessary.
+ *
+ * @author Chris Beams
+ * @since 3.1
+ * @see Import
+ * @see ImportSelector
+ */
+public class ImportSelectorContext {
+ private final AnnotationMetadata importingClassMetadata;
+ private final BeanDefinitionRegistry registry;
+
+ ImportSelectorContext(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
+ this.importingClassMetadata = importingClassMetadata;
+ this.registry = registry;
+ }
+
+ public AnnotationMetadata getImportingClassMetadata() {
+ return this.importingClassMetadata;
+ }
+
+ public BeanDefinitionRegistry getBeanDefinitionRegistry() {
+ return registry;
+ }
+}
\ No newline at end of file
diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java b/org.springframework.context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java
index 9f5791b46f..8cfd0a103b 100644
--- a/org.springframework.context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java
+++ b/org.springframework.context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java
@@ -19,6 +19,7 @@ package org.springframework.scheduling.annotation;
import java.util.Map;
import org.springframework.context.annotation.AnnotationConfigUtils;
+import org.springframework.context.annotation.ImportSelectorContext;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.context.config.AdviceMode;
import org.springframework.core.type.AnnotationMetadata;
@@ -46,7 +47,7 @@ public class AsyncConfigurationSelector implements ImportSelector {
* AspectJAsyncConfiguration}. No additional {@code BeanDefinition}s are registered
* in either case.
*/
- public String[] selectImports(ImportSelector.Context context) {
+ public String[] selectImports(ImportSelectorContext context) {
AnnotationMetadata importingClassMetadata = context.getImportingClassMetadata();
Map