@@ -91,6 +91,17 @@ void importSelectors() {
91
91
ordered .verify (beanFactory ).registerBeanDefinition (eq ("c" ), any ());
92
92
}
93
93
94
+ @ Test
95
+ void filteredImportSelector () {
96
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext ();
97
+ context .register (FilteredConfig .class );
98
+ context .refresh ();
99
+ String [] beanNames = context .getBeanFactory ().getBeanDefinitionNames ();
100
+ assertThat (beanNames ).endsWith ("importSelectorTests.FilteredConfig" ,
101
+ ImportedSelector2 .class .getName (), "b" );
102
+ assertThat (beanNames ).doesNotContain (Object .class .getName ());
103
+ }
104
+
94
105
@ Test
95
106
void invokeAwareMethodsInImportSelector () {
96
107
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext (AwareConfig .class );
@@ -274,6 +285,25 @@ public String[] selectImports(AnnotationMetadata importingClassMetadata) {
274
285
}
275
286
}
276
287
288
+ @ Configuration
289
+ @ Import (FilteredImportSelector .class )
290
+ public static class FilteredConfig {
291
+ }
292
+
293
+ public static class FilteredImportSelector implements ImportSelector {
294
+
295
+ @ Override
296
+ public String [] selectImports (AnnotationMetadata importingClassMetadata ) {
297
+ return new String [] { ImportedSelector1 .class .getName (), ImportedSelector2 .class .getName (), ImportedSelector3 .class .getName () };
298
+ }
299
+
300
+ @ Override
301
+ public Predicate <String > getExclusionFilter () {
302
+ return (className -> className .equals (ImportedSelector1 .class .getName ()) ||
303
+ className .equals (ImportedSelector3 .class .getName ()));
304
+ }
305
+ }
306
+
277
307
278
308
public static class DeferredImportSelector1 implements DeferredImportSelector , Ordered {
279
309
@@ -320,6 +350,15 @@ public String b() {
320
350
}
321
351
}
322
352
353
+ @ Configuration
354
+ public static class ImportedSelector3 {
355
+
356
+ @ Bean
357
+ public String c () {
358
+ return "c" ;
359
+ }
360
+ }
361
+
323
362
324
363
@ Configuration
325
364
public static class DeferredImportedSelector1 {
0 commit comments