Search in sources :

Example 51 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project newton by muoncore.

the class EnableNewtonRegistrar method initScan.

private void initScan(AnnotationMetadata importingClassMetadata) throws ClassNotFoundException {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(EnableNewton.class.getName(), false));
    String[] packages = attributes.getStringArray("value");
    List<String> packs = new ArrayList<>();
    packs.addAll(Arrays.asList(packages));
    packs.add(Class.forName(importingClassMetadata.getClassName()).getPackage().getName());
    log.debug("Initialising Newton by scanning the packages {}", packs);
    MuonLookupUtils.init(packs.toArray(new String[packs.size()]));
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) ArrayList(java.util.ArrayList)

Example 52 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-session by spring-projects.

the class RedisWebSessionConfiguration method setImportMetadata.

@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    Map<String, Object> attributeMap = importMetadata.getAnnotationAttributes(EnableRedisWebSession.class.getName());
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(attributeMap);
    this.maxInactiveIntervalInSeconds = attributes.getNumber("maxInactiveIntervalInSeconds");
    String redisNamespaceValue = attributes.getString("redisNamespace");
    if (StringUtils.hasText(redisNamespaceValue)) {
        this.redisNamespace = this.embeddedValueResolver.resolveStringValue(redisNamespaceValue);
    }
    this.redisFlushMode = attributes.getEnum("redisFlushMode");
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes)

Example 53 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-session by spring-projects.

the class HazelcastHttpSessionConfiguration method setImportMetadata.

@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
    Map<String, Object> attributeMap = importMetadata.getAnnotationAttributes(EnableHazelcastHttpSession.class.getName());
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(attributeMap);
    this.maxInactiveIntervalInSeconds = attributes.getNumber("maxInactiveIntervalInSeconds");
    String sessionMapNameValue = attributes.getString("sessionMapName");
    if (StringUtils.hasText(sessionMapNameValue)) {
        this.sessionMapName = sessionMapNameValue;
    }
    this.hazelcastFlushMode = attributes.getEnum("hazelcastFlushMode");
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes)

Example 54 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-integration by spring-projects.

the class IntegrationComponentScanRegistrar method registerBeanDefinitions.

@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    Map<String, Object> componentScan = importingClassMetadata.getAnnotationAttributes(IntegrationComponentScan.class.getName());
    Collection<String> basePackages = getBasePackages(importingClassMetadata, registry);
    if (basePackages.isEmpty()) {
        basePackages = Collections.singleton(ClassUtils.getPackageName(importingClassMetadata.getClassName()));
    }
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false) {

        @Override
        protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
            return beanDefinition.getMetadata().isIndependent() && !beanDefinition.getMetadata().isAnnotation();
        }
    };
    if ((boolean) componentScan.get("useDefaultFilters")) {
        for (TypeFilter typeFilter : this.componentRegistrars.keySet()) {
            scanner.addIncludeFilter(typeFilter);
        }
    }
    for (AnnotationAttributes filter : (AnnotationAttributes[]) componentScan.get("includeFilters")) {
        for (TypeFilter typeFilter : typeFiltersFor(filter, registry)) {
            scanner.addIncludeFilter(typeFilter);
        }
    }
    for (AnnotationAttributes filter : (AnnotationAttributes[]) componentScan.get("excludeFilters")) {
        for (TypeFilter typeFilter : typeFiltersFor(filter, registry)) {
            scanner.addExcludeFilter(typeFilter);
        }
    }
    scanner.setResourceLoader(this.resourceLoader);
    for (String basePackage : basePackages) {
        Set<BeanDefinition> candidateComponents = scanner.findCandidateComponents(basePackage);
        for (BeanDefinition candidateComponent : candidateComponents) {
            if (candidateComponent instanceof AnnotatedBeanDefinition) {
                for (ImportBeanDefinitionRegistrar registrar : this.componentRegistrars.values()) {
                    registrar.registerBeanDefinitions(((AnnotatedBeanDefinition) candidateComponent).getMetadata(), registry);
                }
            }
        }
    }
}
Also used : IntegrationComponentScan(org.springframework.integration.annotation.IntegrationComponentScan) AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) ClassPathScanningCandidateComponentProvider(org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider) TypeFilter(org.springframework.core.type.filter.TypeFilter) AspectJTypeFilter(org.springframework.core.type.filter.AspectJTypeFilter) AnnotationTypeFilter(org.springframework.core.type.filter.AnnotationTypeFilter) RegexPatternTypeFilter(org.springframework.core.type.filter.RegexPatternTypeFilter) AssignableTypeFilter(org.springframework.core.type.filter.AssignableTypeFilter) ImportBeanDefinitionRegistrar(org.springframework.context.annotation.ImportBeanDefinitionRegistrar) AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Example 55 with AnnotationAttributes

use of org.springframework.core.annotation.AnnotationAttributes in project spring-data-keyvalue by spring-projects.

the class KeyValueRepositoryConfigurationExtension method postProcess.

/*
	 * (non-Javadoc)
	 * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#postProcess(org.springframework.beans.factory.support.BeanDefinitionBuilder, org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource)
	 */
@Override
public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config) {
    AnnotationAttributes attributes = config.getAttributes();
    builder.addPropertyReference("keyValueOperations", attributes.getString(KEY_VALUE_TEMPLATE_BEAN_REF_ATTRIBUTE));
    builder.addPropertyValue("queryCreator", getQueryCreatorType(config));
    builder.addPropertyValue("queryType", getQueryType(config));
    builder.addPropertyReference("mappingContext", getMappingContextBeanRef());
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes)

Aggregations

AnnotationAttributes (org.springframework.core.annotation.AnnotationAttributes)89 Test (org.junit.jupiter.api.Test)17 ArrayList (java.util.ArrayList)8 LinkedHashSet (java.util.LinkedHashSet)7 AnnotationMetadata (org.springframework.core.type.AnnotationMetadata)7 Annotation (java.lang.annotation.Annotation)6 Method (java.lang.reflect.Method)6 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)3 ConditionOutcome (org.springframework.boot.autoconfigure.condition.ConditionOutcome)3 StandardAnnotationMetadata (org.springframework.core.type.StandardAnnotationMetadata)3 DubboReference (org.apache.dubbo.config.annotation.DubboReference)2 ReferenceBean (org.apache.dubbo.config.spring.ReferenceBean)2 Test (org.junit.Test)2 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)2 BeanNameGenerator (org.springframework.beans.factory.support.BeanNameGenerator)2 DiscoveredOperationMethod (org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod)2 ContextConfiguration (org.springframework.test.context.ContextConfiguration)2