Package org.springframework.core.annotation

Examples of org.springframework.core.annotation.AnnotationAttributes


  @Override
  public void prepareTestInstance(TestContext testContext) throws Exception {
    Class<?> testClass = testContext.getTestClass();
    if (AnnotatedElementUtils.isAnnotated(testClass, ANNOTATION_TYPE)) {
      AnnotationAttributes annotationAttributes = AnnotatedElementUtils
          .getAnnotationAttributes(testClass, ANNOTATION_TYPE);
      addPropertySourceProperties(testContext,
          annotationAttributes.getStringArray("value"));
    }
  }
View Full Code Here


  private ResourceLoader resourceLoader;

  @Override
  public String[] selectImports(AnnotationMetadata metadata) {
    try {
      AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata
          .getAnnotationAttributes(EnableAutoConfiguration.class.getName(),
              true));

      Assert.notNull(attributes, "No auto-configuration attributes found. Is "
          + metadata.getClassName()
          + " annotated with @EnableAutoConfiguration?");

      // Find all possible auto configuration classes, filtering duplicates
      List<String> factories = new ArrayList<String>(new LinkedHashSet<String>(
          SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class,
              this.beanClassLoader)));

      // Remove those specifically disabled
      factories.removeAll(Arrays.asList(attributes.getStringArray("exclude")));

      // Sort
      factories = new AutoConfigurationSorter(this.resourceLoader)
          .getInPriorityOrder(factories);
View Full Code Here

    ImportBeanDefinitionRegistrar {

  @Override
  public void registerBeanDefinitions(AnnotationMetadata metadata,
      BeanDefinitionRegistry registry) {
    AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata
        .getAnnotationAttributes(TestAutoConfigurationPackage.class.getName(),
            true));
    AutoConfigurationPackages.set(registry,
        ClassUtils.getPackageName(attributes.getString("value")));
  }
View Full Code Here

  @Override
  public ConditionOutcome getMatchOutcome(ConditionContext context,
      AnnotatedTypeMetadata metadata) {

    AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(metadata
        .getAnnotationAttributes(ConditionalOnProperty.class.getName()));

    String prefix = annotationAttributes.getString("prefix").trim();
    if (StringUtils.hasText(prefix) && !prefix.endsWith(".")) {
      prefix = prefix + ".";
    }
    String havingValue = annotationAttributes.getString("havingValue");
    String[] names = getNames(annotationAttributes);
    boolean relaxedNames = annotationAttributes.getBoolean("relaxedNames");
    boolean matchIfMissing = annotationAttributes.getBoolean("matchIfMissing");

    PropertyResolver resolver = context.getEnvironment();
    if (relaxedNames) {
      resolver = new RelaxedPropertyResolver(resolver, prefix);
    }
View Full Code Here

class OnJndiCondition extends SpringBootCondition {

  @Override
  public ConditionOutcome getMatchOutcome(ConditionContext context,
      AnnotatedTypeMetadata metadata) {
    AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(metadata
        .getAnnotationAttributes(ConditionalOnJndi.class.getName()));
    String[] locations = annotationAttributes.getStringArray("value");
    try {
      return getMatchOutcome(locations);
    }
    catch (NoClassDefFoundError ex) {
      return ConditionOutcome.noMatch("JNDI class not found");
View Full Code Here

    @Override
    public void registerBeanDefinitions(final AnnotationMetadata importingClassMetadata,
                                        final BeanDefinitionRegistry registry) {
        final ConstrettoConfiguration constrettoConfiguration = getConstrettoConfigurationForConfigurationClass(importingClassMetadata.getClassName());
        AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(Constretto.class.getName()));
        if (annotationAttributes.getBoolean("enablePropertyPlaceholder")) {
            registry.registerBeanDefinition(ConstrettoPropertyPlaceholderConfigurer.class.getName(), createPropertyPlaceholderBeanDefinition(constrettoConfiguration));
        }
        if (annotationAttributes.getBoolean("enableAnnotationSupport")) {
            registry.registerBeanDefinition(ConfigurationAnnotationConfigurer.class.getName(), createConfigurationAnnotationConfigurerBeanDefinition(constrettoConfiguration));
        }


    }
View Full Code Here

   */
   AnnotationFunctionExecutionConfigurationSource(AnnotationMetadata metadata) {

    Assert.notNull(metadata);

    this.attributes = new AnnotationAttributes(metadata.getAnnotationAttributes(EnableGemfireFunctionExecutions.class.getName()));
    this.metadata = metadata;
   
  }
View Full Code Here

    @Override
    public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
        Class<EnableGlobalMethodSecurity> annoType = EnableGlobalMethodSecurity.class;
        Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(annoType.getName(), false);
        AnnotationAttributes attributes = AnnotationAttributes.fromMap(annotationAttributes);
        Assert.notNull(attributes, String.format(
                "@%s is not present on importing class '%s' as expected",
                annoType.getSimpleName(), importingClassMetadata.getClassName()));

        // TODO would be nice if could use BeanClassLoaderAware (does not work)
        Class<?> importingClass = ClassUtils.resolveClassName(importingClassMetadata.getClassName(), ClassUtils.getDefaultClassLoader());
        boolean skipMethodSecurityConfiguration = GlobalMethodSecurityConfiguration.class.isAssignableFrom(importingClass);

        AdviceMode mode = attributes.getEnum("mode");
        String autoProxyClassName = AdviceMode.PROXY == mode ? AutoProxyRegistrar.class.getName()
                : GlobalMethodSecurityAspectJAutoProxyRegistrar.class.getName();
        if(skipMethodSecurityConfiguration) {
            return new String[] { autoProxyClassName };
        }
View Full Code Here

     * @see org.springframework.context.annotation.ImportAware#setImportMetadata(org.springframework.core.type.AnnotationMetadata)
     */
    @Override
    public void setImportMetadata(AnnotationMetadata importMetadata) {
        Map<String, Object> enableWebSecurityAttrMap = importMetadata.getAnnotationAttributes(EnableWebSecurity.class.getName());
        AnnotationAttributes enableWebSecurityAttrs = AnnotationAttributes.fromMap(enableWebSecurityAttrMap);
        if(enableWebSecurityAttrs == null) {
            // search parent classes
            Class<?> currentClass = ClassUtils.resolveClassName(importMetadata.getClassName(), beanClassLoader);
            for(Class<?> classToInspect = currentClass ;classToInspect != null; classToInspect = classToInspect.getSuperclass()) {
                EnableWebSecurity enableWebSecurityAnnotation = AnnotationUtils.findAnnotation(classToInspect, EnableWebSecurity.class);
                if(enableWebSecurityAnnotation == null) {
                    continue;
                }
                enableWebSecurityAttrMap = AnnotationUtils
                        .getAnnotationAttributes(enableWebSecurityAnnotation);
                enableWebSecurityAttrs = AnnotationAttributes.fromMap(enableWebSecurityAttrMap);
            }
        }
        boolean debugEnabled = enableWebSecurityAttrs.getBoolean("debug");
        this.webSecurity.debug(debugEnabled);
    }
View Full Code Here

                .registerAspectJAnnotationAutoProxyCreatorIfNecessary(registry);

        Map<String, Object> annotationAttributes = importingClassMetadata
                .getAnnotationAttributes(EnableGlobalMethodSecurity.class
                        .getName());
        AnnotationAttributes enableAJAutoProxy = AnnotationAttributes
                .fromMap(annotationAttributes);

        if (enableAJAutoProxy.getBoolean("proxyTargetClass")) {
            AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
        }
    }
View Full Code Here

TOP

Related Classes of org.springframework.core.annotation.AnnotationAttributes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.