Package org.springframework.core.annotation

Examples of org.springframework.core.annotation.AnnotationAttributes


  @Override
  public void setImportMetadata(AnnotationMetadata importMetadata) {
    Map<String, Object> enableConfigurationAttrMap =
        importMetadata.getAnnotationAttributes(EnableAnnotationConfiguration.class.getName());
    AnnotationAttributes enableConfigurationAttrs = AnnotationAttributes.fromMap(enableConfigurationAttrMap);
    if(enableConfigurationAttrs == null) {
      // search parent classes
      Class<?> currentClass = ClassUtils.resolveClassName(importMetadata.getClassName(), beanClassLoader);
      for(Class<?> classToInspect = currentClass ;classToInspect != null; classToInspect = classToInspect.getSuperclass()) {
        EnableAnnotationConfiguration enableConfigurationAnnotation =
View Full Code Here


  @Override
  public void setImportMetadata(AnnotationMetadata importMetadata) {
    super.setImportMetadata(importMetadata);
    Map<String, Object> enableYarnMap =
        importMetadata.getAnnotationAttributes(EnableYarn.class.getName());
    AnnotationAttributes enableYarnAttrs = AnnotationAttributes.fromMap(enableYarnMap);
    log.info("Enabling " + enableYarnAttrs.getEnum("enable") + " for Yarn");
  }
View Full Code Here

  @Override
  public String[] selectImports(AnnotationMetadata importingClassMetadata) {

    Map<String, Object> attrMap = importingClassMetadata.getAnnotationAttributes(EnableYarn.class.getName());
    AnnotationAttributes enableAttrs = AnnotationAttributes.fromMap(attrMap);
    Enable enable = enableAttrs.getEnum("enable");

    String[] configs = new String[2];

    if (enable == Enable.CLIENT) {
      configs[0] = SpringYarnClientConfiguration.class.getName();
View Full Code Here

    Assert.notNull(metadata);
    Assert.notNull(annotation);
    Assert.notNull(resourceLoader);

    this.attributes = new AnnotationAttributes(metadata.getAnnotationAttributes(annotation.getName()));
    this.metadata = metadata;
    this.resourceLoader = resourceLoader;
    this.hasExplicitFilters = hasExplicitFilters(attributes);
  }
View Full Code Here

  public AnnotationAuditingConfiguration(AnnotationMetadata metadata, Class<? extends Annotation> annotation) {

    Assert.notNull(metadata, "AnnotationMetadata must not be null!");
    Assert.notNull(annotation, "Annotation must not be null!");

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

    ParsingUtils.setPropertyReference(builder, element, COUCHBASE_TEMPLATE_REF, "couchbaseOperations");
  }

  @Override
  public void postProcess(final BeanDefinitionBuilder builder, final AnnotationRepositoryConfigurationSource config) {
    AnnotationAttributes attributes = config.getAttributes();
    builder.addPropertyReference("couchbaseOperations", attributes.getString("couchbaseTemplateRef"));
  }
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

    AnnotationAttributes annoAttrs = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(MapperScan.class.getName()));
    ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);

    // this check is needed in Spring 3.1
    if (resourceLoader != null) {
      scanner.setResourceLoader(resourceLoader);
    }

    Class<? extends Annotation> annotationClass = annoAttrs.getClass("annotationClass");
    if (!Annotation.class.equals(annotationClass)) {
      scanner.setAnnotationClass(annotationClass);
    }

    Class<?> markerInterface = annoAttrs.getClass("markerInterface");
    if (!Class.class.equals(markerInterface)) {
      scanner.setMarkerInterface(markerInterface);
    }

    Class<? extends BeanNameGenerator> generatorClass = annoAttrs.getClass("nameGenerator");
    if (!BeanNameGenerator.class.equals(generatorClass)) {
      scanner.setBeanNameGenerator(BeanUtils.instantiateClass(generatorClass));
    }

    scanner.setSqlSessionTemplateBeanName(annoAttrs.getString("sqlSessionTemplateRef"));
    scanner.setSqlSessionFactoryBeanName(annoAttrs.getString("sqlSessionFactoryRef"));

    List<String> basePackages = new ArrayList<String>();
    for (String pkg : annoAttrs.getStringArray("value")) {
      if (StringUtils.hasText(pkg)) {
        basePackages.add(pkg);
      }
    }
    for (String pkg : annoAttrs.getStringArray("basePackages")) {
      if (StringUtils.hasText(pkg)) {
        basePackages.add(pkg);
      }
    }
    for (Class<?> clazz : annoAttrs.getClassArray("basePackageClasses")) {
      basePackages.add(ClassUtils.getPackageName(clazz));
    }
    scanner.registerFilters();
    scanner.doScan(StringUtils.toStringArray(basePackages));
  }
View Full Code Here

final class GlobalMethodSecuritySelector implements ImportSelector {

    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

    /* (non-Javadoc)
     * @see org.springframework.context.annotation.ImportAware#setImportMetadata(org.springframework.core.type.AnnotationMetadata)
     */
    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);
            }
        }
        debugEnabled = enableWebSecurityAttrs.getBoolean("debug");
        if(webSecurity != null) {
            webSecurity.debug(debugEnabled);
        }
    }
View Full Code Here

   * returns {@code null}
   */
  public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
    Class<?> annoType = GenericTypeResolver.resolveTypeArgument(this.getClass(), AdviceModeImportSelector.class);

    AnnotationAttributes attributes = attributesFor(importingClassMetadata, annoType);
    Assert.notNull(attributes, String.format(
        "@%s is not present on importing class '%s' as expected",
        annoType.getSimpleName(), importingClassMetadata.getClassName()));

    AdviceMode adviceMode = attributes.getEnum(this.getAdviceModeAttributeName());

    String[] imports = selectImports(adviceMode);
    Assert.notNull(imports, String.format("Unknown AdviceMode: '%s'", adviceMode));

    return imports;
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.