All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.microsphere.spring.test.jdbc.embedded.EmbeddedDataBaseBeanDefinitionsRegistrar Maven / Gradle / Ivy

There is a newer version: 0.0.3
Show newest version
package io.microsphere.spring.test.jdbc.embedded;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;

import java.lang.annotation.Annotation;

import static org.springframework.core.annotation.AnnotationAttributes.fromMap;

/**
 * {@link EnableEmbeddedDatabases} {@link ImportBeanDefinitionRegistrar}
 *
 * @author Mercy
 * @see EnableEmbeddedDatabases
 * @see EmbeddedDataBaseBeanDefinitionRegistrar
 * @since 1.0.0
 */
class EmbeddedDataBaseBeanDefinitionsRegistrar implements ImportBeanDefinitionRegistrar {

    private static final Class ANNOTATION_TYPE = EnableEmbeddedDatabases.class;

    @Override
    public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
        AnnotationAttributes attributes = fromMap(metadata.getAnnotationAttributes(ANNOTATION_TYPE.getName()));
        EmbeddedDataBaseBeanDefinitionRegistrar registrar = new EmbeddedDataBaseBeanDefinitionRegistrar();
        for (AnnotationAttributes valueAttributes : attributes.getAnnotationArray("value")) {
            registrar.registerBeanDefinitions(valueAttributes, registry);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy