Package org.springframework.core.annotation

Examples of org.springframework.core.annotation.AnnotationAttributes


   */
  public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    boolean candidateFound = false;
    Set<String> annoTypes = importingClassMetadata.getAnnotationTypes();
    for (String annoType : annoTypes) {
      AnnotationAttributes candidate = attributesFor(importingClassMetadata, annoType);
      Object mode = candidate.get("mode");
      Object proxyTargetClass = candidate.get("proxyTargetClass");
      if (mode != null && proxyTargetClass != null
          && mode.getClass().equals(AdviceMode.class)
          && proxyTargetClass.getClass().equals(Boolean.class)) {
        candidateFound = true;
        if (mode == AdviceMode.PROXY) {
View Full Code Here


    this.attributes.put(attributeName, attributeValue);
  }

  public AnnotationVisitor visitAnnotation(String attributeName, String asmTypeDescriptor) {
    String annotationType = Type.getType(asmTypeDescriptor).getClassName();
    AnnotationAttributes nestedAttributes = new AnnotationAttributes();
    this.attributes.put(attributeName, nestedAttributes);
    return new RecursiveAnnotationAttributesVisitor(annotationType, nestedAttributes, this.classLoader);
  }
View Full Code Here

  }

  @Override
  public AnnotationVisitor visitAnnotation(String attributeName, String asmTypeDescriptor) {
    String annotationType = Type.getType(asmTypeDescriptor).getClassName();
    AnnotationAttributes nestedAttributes = new AnnotationAttributes();
    this.allNestedAttributes.add(nestedAttributes);
    return new RecursiveAnnotationAttributesVisitor(annotationType, nestedAttributes, this.classLoader);
  }
View Full Code Here

  public AnnotationAttributesReadingVisitor(
      String annotationType, Map<String, AnnotationAttributes> attributesMap,
      Map<String, Set<String>> metaAnnotationMap, ClassLoader classLoader) {

    super(annotationType, new AnnotationAttributes(), classLoader);
    this.annotationType = annotationType;
    this.attributesMap = attributesMap;
    this.metaAnnotationMap = metaAnnotationMap;
  }
View Full Code Here

  }

  public AnnotationAttributes getAnnotationAttributes(
      String annotationType, boolean classValuesAsString, boolean nestedAttributesAsMap) {

    AnnotationAttributes raw = this.attributeMap.get(annotationType);
    return convertClassValues(raw, classValuesAsString, nestedAttributesAsMap);
  }
View Full Code Here

      AnnotationAttributes original, boolean classValuesAsString, boolean nestedAttributesAsMap) {

    if (original == null) {
      return null;
    }
    AnnotationAttributes result = new AnnotationAttributes(original.size());
    for (Map.Entry<String, Object> entry : original.entrySet()) {
      try {
        Object value = entry.getValue();
        if (value instanceof AnnotationAttributes) {
          value = convertClassValues((AnnotationAttributes)value, classValuesAsString, nestedAttributesAsMap);
        }
        else if (value instanceof AnnotationAttributes[]) {
          AnnotationAttributes[] values = (AnnotationAttributes[])value;
          for (int i = 0; i < values.length; i++) {
            values[i] = convertClassValues(values[i], classValuesAsString, nestedAttributesAsMap);
          }
        }
        else if (value instanceof Type) {
          value = (classValuesAsString ? ((Type) value).getClassName() :
              this.classLoader.loadClass(((Type) value).getClassName()));
        }
        else if (value instanceof Type[]) {
          Type[] array = (Type[]) value;
          Object[] convArray = (classValuesAsString ? new String[array.length] : new Class[array.length]);
          for (int i = 0; i < array.length; i++) {
            convArray[i] = (classValuesAsString ? array[i].getClassName() :
                this.classLoader.loadClass(array[i].getClassName()));
          }
          value = convArray;
        }
        else if (classValuesAsString) {
          if (value instanceof Class) {
            value = ((Class<?>) value).getName();
          }
          else if (value instanceof Class[]) {
            Class<?>[] clazzArray = (Class[]) value;
            String[] newValue = new String[clazzArray.length];
            for (int i = 0; i < clazzArray.length; i++) {
              newValue[i] = clazzArray[i].getName();
            }
            value = newValue;
          }
        }
        result.put(entry.getKey(), value);
      }
      catch (Exception ex) {
        // Class not found - can't resolve class reference in annotation attribute.
      }
    }
View Full Code Here

  public void registerBeanDefinitions(
      AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

    AopConfigUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(registry);

    AnnotationAttributes enableAJAutoProxy =
        attributesFor(importingClassMetadata, EnableAspectJAutoProxy.class);
    if (enableAJAutoProxy.getBoolean("proxyTargetClass")) {
      AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
    }
  }
View Full Code Here

  public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    if (definition instanceof AnnotatedBeanDefinition) {
      AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
      AnnotationAttributes attributes =
          attributesFor(annDef.getMetadata(), this.scopeAnnotationType);
      if (attributes != null) {
        metadata.setScopeName(attributes.getString("value"));
        ScopedProxyMode proxyMode = attributes.getEnum("proxyMode");
        if (proxyMode == null || proxyMode == ScopedProxyMode.DEFAULT) {
          proxyMode = this.defaultProxyMode;
        }
        metadata.setScopedProxyMode(proxyMode);
      }
View Full Code Here

  protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
    AnnotationMetadata amd = annotatedDef.getMetadata();
    Set<String> types = amd.getAnnotationTypes();
    String beanName = null;
    for (String type : types) {
      AnnotationAttributes attributes = MetadataUtils.attributesFor(amd, type);
      if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
        String value = (String) attributes.get("value");
        if (StringUtils.hasLength(value)) {
          if (beanName != null && !value.equals(beanName)) {
            throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
                "component names: '" + beanName + "' versus '" + value + "'");
          }
View Full Code Here

  public void registerBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers) {
    AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
    AnnotationMetadata metadata = abd.getMetadata();
    if (metadata.isAnnotated(Profile.class.getName())) {
      AnnotationAttributes profile = MetadataUtils.attributesFor(metadata, Profile.class);
      if (!this.environment.acceptsProfiles(profile.getStringArray("value"))) {
        return;
      }
    }
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(abd);
    abd.setScope(scopeMetadata.getScopeName());
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.