List of usage examples for org.springframework.core.annotation AnnotationAttributes getBoolean
public boolean getBoolean(String attributeName)
From source file:com.frank.search.solr.repository.config.SolrRepositoryConfigExtension.java
@Override public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config) { AnnotationAttributes attributes = config.getAttributes(); if (!attributes.getBoolean("multicoreSupport")) { builder.addPropertyReference(BeanDefinition.SOLR_OPERATIONS.getBeanName(), attributes.getString("solrTemplateRef")); } else {// w w w .j a v a 2s .c om builder.addPropertyReference(BeanDefinition.SOLR_CLIENT.getBeanName(), attributes.getString("solrClientRef")); } builder.addPropertyValue("schemaCreationSupport", attributes.getBoolean("schemaCreationSupport")); builder.addPropertyReference(BeanDefinition.SOLR_MAPPTING_CONTEXT.getBeanName(), "solrMappingContext"); }
From source file:com.alibaba.dubbo.config.spring.context.annotation.DubboConfigBindingRegistrar.java
protected void registerBeanDefinitions(AnnotationAttributes attributes, BeanDefinitionRegistry registry) { String prefix = environment.resolvePlaceholders(attributes.getString("prefix")); Class<? extends AbstractConfig> configClass = attributes.getClass("type"); boolean multiple = attributes.getBoolean("multiple"); registerDubboConfigBeans(prefix, configClass, multiple, registry); }
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:org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.java
/** * Determine if the annotated field or method requires its dependency. * <p>A 'required' dependency means that autowiring should fail when no beans * are found. Otherwise, the autowiring process will simply bypass the field * or method when no beans are found.//from w w w . ja v a 2 s. com * @param ann the Autowired annotation * @return whether the annotation indicates that a dependency is required */ protected boolean determineRequiredStatus(AnnotationAttributes ann) { return (!ann.containsKey(this.requiredParameterName) || this.requiredParameterValue == ann.getBoolean(this.requiredParameterName)); }
From source file:org.springframework.context.annotation.ConfigurationClassParser.java
/** * Process the given <code>@PropertySource</code> annotation metadata. * @param propertySource metadata for the <code>@PropertySource</code> annotation found * @throws IOException if loading a property source failed *//*from w w w . j a v a 2s . co m*/ private void processPropertySource(AnnotationAttributes propertySource) throws IOException { String name = propertySource.getString("name"); if (!StringUtils.hasLength(name)) { name = null; } String encoding = propertySource.getString("encoding"); if (!StringUtils.hasLength(encoding)) { encoding = null; } String[] locations = propertySource.getStringArray("value"); Assert.isTrue(locations.length > 0, "At least one @PropertySource(value) location is required"); boolean ignoreResourceNotFound = propertySource.getBoolean("ignoreResourceNotFound"); Class<? extends PropertySourceFactory> factoryClass = propertySource.getClass("factory"); PropertySourceFactory factory = (factoryClass == PropertySourceFactory.class ? DEFAULT_PROPERTY_SOURCE_FACTORY : BeanUtils.instantiateClass(factoryClass)); for (String location : locations) { try { String resolvedLocation = this.environment.resolveRequiredPlaceholders(location); Resource resource = this.resourceLoader.getResource(resolvedLocation); addPropertySource(factory.createPropertySource(name, new EncodedResource(resource, encoding))); } catch (IllegalArgumentException | FileNotFoundException | UnknownHostException ex) { // Placeholders not resolvable or resource not found when trying to open it if (ignoreResourceNotFound) { if (logger.isInfoEnabled()) { logger.info("Properties location [" + location + "] not resolvable: " + ex.getMessage()); } } else { throw ex; } } } }
From source file:org.springframework.test.context.ContextConfigurationAttributes.java
/** * Construct a new {@link ContextConfigurationAttributes} instance for the * supplied {@link AnnotationAttributes} (parsed from a * {@link ContextConfiguration @ContextConfiguration} annotation) and * the {@linkplain Class test class} that declared them. * @param declaringClass the test class that declared {@code @ContextConfiguration} * @param annAttrs the annotation attributes from which to retrieve the attributes *//*from ww w .ja va2s. co m*/ @SuppressWarnings("unchecked") public ContextConfigurationAttributes(Class<?> declaringClass, AnnotationAttributes annAttrs) { this(declaringClass, annAttrs.getStringArray("locations"), annAttrs.getClassArray("classes"), annAttrs.getBoolean("inheritLocations"), (Class<? extends ApplicationContextInitializer<?>>[]) annAttrs.getClassArray("initializers"), annAttrs.getBoolean("inheritInitializers"), annAttrs.getString("name"), annAttrs.getClass("loader")); }