List of usage examples for org.springframework.core.type AnnotationMetadata getAnnotationAttributes
@Nullable default Map<String, Object> getAnnotationAttributes(String annotationName, boolean classValuesAsString)
From source file:com.icfcc.cache.annotation.AbstractCachingConfiguration.java
public void setImportMetadata(AnnotationMetadata importMetadata) { this.enableCaching = importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false); Assert.notNull(this.enableCaching, "@EnableCaching is not present on importing class " + importMetadata.getClassName()); }
From source file:com.github.eddumelendez.autoconfigure.TestAutoConfigurationPackageRegistrar.java
@Override public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { AnnotationAttributes attributes = AnnotationAttributes .fromMap(metadata.getAnnotationAttributes(TestAutoConfigurationPackage.class.getName(), true)); AutoConfigurationPackages.register(registry, ClassUtils.getPackageName(attributes.getString("value"))); }
From source file:io.fabric8.spring.cloud.kubernetes.archaius.ArchaiusConfigMapSourceRegistar.java
@Override public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { Map<String, Object> source = metadata.getAnnotationAttributes(ArchaiusConfigMapSource.class.getName(), true);//ww w.ja v a2 s .co m String name = getSourceName(source); String namespace = getSourceNamespace(source); if (name != null) { registerSourceConfiguration(registry, name, namespace); } }
From source file:com.developmentsprint.spring.breaker.annotations.AbstractCircuitBreakerConfiguration.java
@Override public void setImportMetadata(AnnotationMetadata importMetadata) { this.enableCircuitBreakers = AnnotationAttributes .fromMap(importMetadata.getAnnotationAttributes(EnableCircuitBreakers.class.getName(), false)); Assert.notNull(this.enableCircuitBreakers, "@EnableCircuitBreakers is not present on importing class " + importMetadata.getClassName()); }
From source file:com.ryantenney.metrics.spring.config.annotation.MetricsConfigurationSupport.java
@Override public void setImportMetadata(AnnotationMetadata importMetadata) { final AnnotationAttributes enableMetrics = AnnotationAttributes .fromMap(importMetadata.getAnnotationAttributes(EnableMetrics.class.getName(), false)); Assert.notNull(enableMetrics, "@" + EnableMetrics.class.getSimpleName() + " is not present on importing class " + importMetadata.getClassName()); this.proxyConfig = new ProxyConfig(); this.proxyConfig.setExposeProxy(enableMetrics.getBoolean("exposeProxy")); this.proxyConfig.setProxyTargetClass(enableMetrics.getBoolean("proxyTargetClass")); }
From source file:com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientRegistrar.java
/** * {@inheritDoc}/*from w w w . ja v a2 s . com*/ */ @SuppressWarnings("unchecked") @Override public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) { final List<String> basePackages = new ArrayList<String>(); final Map<String, Object> attributes = annotationMetadata .getAnnotationAttributes(ANNOTATION_CLASS.getName(), false); final Class<? extends ServiceUrlProvider> serviceUrlProvider = get(attributes, "serviceUrlProvider"); final String serviceUrl = get(attributes, "serviceUrl"); addAll(basePackages, attributes, "value"); addAll(basePackages, attributes, "basePackages"); addAll(basePackages, toPackageNames((Class[]) attributes.get("basePackageClasses"))); final JaxRsClientClassPathScanner scanner = new JaxRsClientClassPathScanner(registry); scanner.setServiceUrl(serviceUrl); scanner.setServiceUrlProvider(serviceUrlProvider); scanner.scan(toArray(basePackages)); }
From source file:com.github.ljtfreitas.restify.spring.configure.RestifyConfigurationRegistrar.java
@Override public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { EnableRestifyAnnotationAttributes attributes = new EnableRestifyAnnotationAttributes( metadata.getAnnotationAttributes(EnableRestify.class.getName(), true)); RestifyableTypeScanner scanner = RestifyableTypeScanner.excluding(filters(attributes.exclude())); String[] packages = attributes.packages().length == 0 ? new String[] { packageOf(metadata.getClassName()) } : attributes.packages();// w ww.j a v a2 s . c o m doScan(Arrays.asList(packages), scanner, registry); }
From source file:org.talend.daikon.spring.BndToSpringBeanNameGenerator.java
/** * Derive a bean name from one of the annotations on the class. First delegate to the super class and if it is not a * spring annotation then check for the bnd annotation * //from w ww .ja v a 2 s . c o m * @param annotatedDef the annotation-aware bean definition * @return the bean name, or {@code null} if none is found */ @Override protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) { String beanName = super.determineBeanNameFromAnnotation(annotatedDef); if (beanName != null) { return beanName; } // else check for BND annotation AnnotationMetadata amd = annotatedDef.getMetadata(); Set<String> types = amd.getAnnotationTypes(); for (String type : types) { AnnotationAttributes attributes = AnnotationAttributes .fromMap(amd.getAnnotationAttributes(type, false)); if (isStereotypeWithBndNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) { Object value = attributes.get("name"); if (value instanceof String) { String strVal = (String) value; if (StringUtils.hasLength(strVal)) { if (beanName != null && !strVal.equals(beanName)) { throw new IllegalStateException("Stereotype annotations suggest inconsistent " + "component names: '" + beanName + "' versus '" + strVal + "'"); } beanName = strVal; } } } } return beanName; }
From source file:org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.java
/** * Return the appropriate {@link AnnotationAttributes} from the * {@link AnnotationMetadata}. By default this method will return attributes for * {@link #getAnnotationClass()}.// w ww . j av a 2 s. c om * @param metadata the annotation metadata * @return annotation attributes */ protected AnnotationAttributes getAttributes(AnnotationMetadata metadata) { String name = getAnnotationClass().getName(); AnnotationAttributes attributes = AnnotationAttributes .fromMap(metadata.getAnnotationAttributes(name, true)); Assert.notNull(attributes, () -> "No auto-configuration attributes found. Is " + metadata.getClassName() + " annotated with " + ClassUtils.getShortName(name) + "?"); return attributes; }
From source file:org.springframework.boot.autoconfigure.ComponentScanDetector.java
private List<String> getBasePackages(AnnotationMetadata metadata) { AnnotationAttributes attributes = AnnotationAttributes.fromMap( (metadata == null ? null : metadata.getAnnotationAttributes(ComponentScan.class.getName(), true))); if (attributes != null) { List<String> basePackages = new ArrayList<String>(); addAllHavingText(basePackages, attributes.getStringArray("value")); addAllHavingText(basePackages, attributes.getStringArray("basePackages")); for (String packageClass : attributes.getStringArray("basePackageClasses")) { basePackages.add(ClassUtils.getPackageName(packageClass)); }/*from w ww . ja v a 2 s.c om*/ if (basePackages.isEmpty()) { basePackages.add(ClassUtils.getPackageName(metadata.getClassName())); } return basePackages; } return Collections.emptyList(); }