@Override public String toString() { return this.metadata.getClassName(); } }
@Override public boolean equals(Object other) { return (this == other || (other instanceof SourceClass && this.metadata.getClassName().equals(((SourceClass) other).metadata.getClassName()))); }
@Override public void setImportMetadata(AnnotationMetadata importMetadata) { this.enableLTW = AnnotationConfigUtils.attributesFor(importMetadata, EnableLoadTimeWeaving.class); if (this.enableLTW == null) { throw new IllegalArgumentException( "@EnableLoadTimeWeaving is not present on importing class " + importMetadata.getClassName()); } }
@Override public boolean equals(Object other) { return (this == other || (other instanceof ConfigurationClass && getMetadata().getClassName().equals(((ConfigurationClass) other).getMetadata().getClassName()))); }
@Override public void removeImportingClass(String importingClass) { for (List<AnnotationMetadata> list : this.imports.values()) { for (Iterator<AnnotationMetadata> iterator = list.iterator(); iterator.hasNext();) { if (iterator.next().getClassName().equals(importingClass)) { iterator.remove(); break; } } } }
/** * Create a new {@link ConfigurationClass} with the given name. * @param metadata the metadata for the underlying class to represent * @param beanName name of the {@code @Configuration} class bean * @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass) */ public ConfigurationClass(AnnotationMetadata metadata, String beanName) { Assert.notNull(beanName, "Bean name must not be null"); this.metadata = metadata; this.resource = new DescriptiveResource(metadata.getClassName()); this.beanName = beanName; }
@Override public void setImportMetadata(AnnotationMetadata importMetadata) { Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableMBeanExport.class.getName()); this.enableMBeanExport = AnnotationAttributes.fromMap(map); if (this.enableMBeanExport == null) { throw new IllegalArgumentException( "@EnableMBeanExport is not present on importing class " + importMetadata.getClassName()); } }
@Override public void setImportMetadata(AnnotationMetadata importMetadata) { this.enableAsync = AnnotationAttributes.fromMap( importMetadata.getAnnotationAttributes(EnableAsync.class.getName(), false)); if (this.enableAsync == null) { throw new IllegalArgumentException( "@EnableAsync is not present on importing class " + importMetadata.getClassName()); } }
@Override public void setImportMetadata(AnnotationMetadata importMetadata) { this.enableCaching = AnnotationAttributes.fromMap( importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false)); if (this.enableCaching == null) { throw new IllegalArgumentException( "@EnableCaching is not present on importing class " + importMetadata.getClassName()); } }
@Override public void setImportMetadata(AnnotationMetadata importMetadata) { this.enableTx = AnnotationAttributes.fromMap( importMetadata.getAnnotationAttributes(EnableTransactionManagement.class.getName(), false)); if (this.enableTx == null) { throw new IllegalArgumentException( "@EnableTransactionManagement is not present on importing class " + importMetadata.getClassName()); } }
@Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { ImportSelectorTests.importFrom.put(getClass(), importingClassMetadata.getClassName()); return new String[] { DeferredImportedSelector2.class.getName() }; } }
@Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { ImportSelectorTests.importFrom.put(getClass(), importingClassMetadata.getClassName()); return new String[] { ImportedSelector1.class.getName() }; } }
@Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { ImportSelectorTests.importFrom.put(getClass(), importingClassMetadata.getClassName()); return new String[] { DeferredImportedSelector3.class.getName() }; }
@Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { ImportSelectorTests.importFrom.put(getClass(), importingClassMetadata.getClassName()); return new String[] { DeferredImportSelector2.class.getName() }; }
@Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { ImportSelectorTests.importFrom.put(getClass(), importingClassMetadata.getClassName()); return new String[] { DeferredImportedSelector1.class.getName() }; }
@Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { ImportSelectorTests.importFrom.put(getClass(), importingClassMetadata.getClassName()); return new String[] { ImportedSelector2.class.getName() }; } }
@Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { ImportSelectorTests.importFrom.put(getClass(), importingClassMetadata.getClassName()); return new String[] { DeferredImportSelector1.class.getName(), ChildConfiguration1.class.getName() }; }
@Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { ImportSelectorTests.importFrom.put(getClass(), importingClassMetadata.getClassName()); return new String[] { DeferredImportSelector2.class.getName(), ChildConfiguration2.class.getName() }; }
static Map<String, List<String>> allImports() { return TestImportGroup.imports.entrySet() .stream() .collect(Collectors.toMap((entry) -> entry.getKey().getClassName(), Map.Entry::getValue)); } private final List<Entry> instanceImports = new ArrayList<>();
/** * Factory method to obtain a {@link SourceClass} from a {@link ConfigurationClass}. */ private SourceClass asSourceClass(ConfigurationClass configurationClass) throws IOException { AnnotationMetadata metadata = configurationClass.getMetadata(); if (metadata instanceof StandardAnnotationMetadata) { return asSourceClass(((StandardAnnotationMetadata) metadata).getIntrospectedClass()); } return asSourceClass(metadata.getClassName()); }