Examples of AnnotationAttributes


Examples of org.springframework.core.annotation.AnnotationAttributes

   * returns {@code null}
   */
  @Override
  public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
    Class<?> annoType = GenericTypeResolver.resolveTypeArgument(getClass(), AdviceModeImportSelector.class);
    AnnotationAttributes attributes = AnnotationConfigUtils.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

Examples of org.springframework.core.annotation.AnnotationAttributes

  @Override
  public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    boolean candidateFound = false;
    Set<String> annoTypes = importingClassMetadata.getAnnotationTypes();
    for (String annoType : annoTypes) {
      AnnotationAttributes candidate = AnnotationConfigUtils.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) {
          AopConfigUtils.registerAutoProxyCreatorIfNecessary(registry);
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

@SuppressWarnings("serial")
public class SpringTransactionAnnotationParser implements TransactionAnnotationParser, Serializable {

  @Override
  public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
    AnnotationAttributes ann = AnnotatedElementUtils.getAnnotationAttributes(ae, Transactional.class.getName());
    if (ann != null) {
      return parseTransactionAnnotation(ann);
    }
    else {
      return null;
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

@SuppressWarnings("serial")
public class JtaTransactionAnnotationParser implements TransactionAnnotationParser, Serializable {

  @Override
  public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
    AnnotationAttributes ann = AnnotatedElementUtils.getAnnotationAttributes(ae, javax.transaction.Transactional.class.getName());
    if (ann != null) {
      return parseTransactionAnnotation(ann);
    }
    else {
      return null;
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

  }

  @Override
  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

Examples of org.springframework.core.annotation.AnnotationAttributes

  }

  @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

Examples of org.springframework.core.annotation.AnnotationAttributes

  public AnnotationAttributesReadingVisitor(String annotationType,
      MultiValueMap<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

Examples of org.springframework.core.annotation.AnnotationAttributes

    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(classLoader, (AnnotationAttributes) value, classValuesAsString);
        }
        else if (value instanceof AnnotationAttributes[]) {
          AnnotationAttributes[] values = (AnnotationAttributes[]) value;
          for (int i = 0; i < values.length; i++) {
            values[i] = convertClassValues(classLoader, values[i], classValuesAsString);
          }
        }
        else if (value instanceof Type) {
          value = (classValuesAsString ? ((Type) value).getClassName()
              : 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()
                : 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

Examples of org.springframework.core.annotation.AnnotationAttributes

    // To start with, we populate the results with a copy of all attribute
    // values from the target annotation. A copy is necessary so that we do
    // not inadvertently mutate the state of the metadata passed to this
    // method.
    AnnotationAttributes results = new AnnotationAttributes(attributesList.get(0));

    Set<String> overridableAttributeNames = new HashSet<String>(results.keySet());
    overridableAttributeNames.remove(AnnotationUtils.VALUE);

    // Since the map is a LinkedMultiValueMap, we depend on the ordering of
    // elements in the map and reverse the order of the keys in order to traverse
    // "down" the annotation hierarchy.
    List<String> annotationTypes = new ArrayList<String>(attributesMap.keySet());
    Collections.reverse(annotationTypes);

    // No need to revisit the target annotation type:
    annotationTypes.remove(annotationType);

    for (String currentAnnotationType : annotationTypes) {
      List<AnnotationAttributes> currentAttributesList = attributesMap.get(currentAnnotationType);
      if (currentAttributesList != null && !currentAttributesList.isEmpty()) {
        Set<String> metaAnns = metaAnnotationMap.get(currentAnnotationType);
        if (metaAnns != null && metaAnns.contains(annotationType)) {
          AnnotationAttributes currentAttributes = currentAttributesList.get(0);
          for (String overridableAttributeName : overridableAttributeNames) {
            Object value = currentAttributes.get(overridableAttributeName);
            if (value != null) {
              // Store the value, potentially overriding a value from an
              // attribute of the same name found higher in the annotation
              // hierarchy.
              results.put(overridableAttributeName, value);
View Full Code Here

Examples of org.springframework.core.annotation.AnnotationAttributes

    return getAnnotationAttributes(annotationType, false);
  }

  @Override
  public AnnotationAttributes getAnnotationAttributes(String annotationType, boolean classValuesAsString) {
    AnnotationAttributes raw = AnnotationReadingVisitorUtils.getMergedAnnotationAttributes(
        this.attributesMap, this.metaAnnotationMap, annotationType);
    return AnnotationReadingVisitorUtils.convertClassValues(this.classLoader, raw, classValuesAsString);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.