Examples of InjectionMetadata


Examples of org.springframework.beans.factory.annotation.InjectionMetadata

        }
    }

    public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) {
        if (beanType != null) {
            InjectionMetadata metadata = findAnnotationMetadata(beanType);
            metadata.checkConfigMembers(beanDefinition);
        }
    }
View Full Code Here

Examples of org.springframework.beans.factory.annotation.InjectionMetadata

    }

    public PropertyValues postProcessPropertyValues(
            PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {

        InjectionMetadata metadata = findAnnotationMetadata(bean.getClass());
        try {
            metadata.inject(bean, beanName, pvs);
        }
        catch (Throwable ex) {
            throw new BeanCreationException(beanName, INJECTION_OF_KIE_DEPENDENCIES_FAILED, ex);
        }
View Full Code Here

Examples of org.springframework.beans.factory.annotation.InjectionMetadata

        return bean;
    }

    private InjectionMetadata findAnnotationMetadata(final Class clazz) {
        // Quick check on the concurrent map first, with minimal locking.
        InjectionMetadata metadata = this.injectionMetadataCache.get(clazz);
        if (metadata == null) {
            synchronized (this.injectionMetadataCache) {
                metadata = this.injectionMetadataCache.get(clazz);
                if (metadata == null) {
                    LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
                    Class<?> targetClass = clazz;

                    do {
                        LinkedList<InjectionMetadata.InjectedElement> currElements = new LinkedList<InjectionMetadata.InjectedElement>();
                        checkForFieldInjections(targetClass, currElements);
                        checkForMethodInjections(targetClass, currElements);
                        elements.addAll(0, currElements);
                        targetClass = targetClass.getSuperclass();
                    }
                    while (targetClass != null && targetClass != Object.class);

                    metadata = new InjectionMetadata(clazz, elements);
                    this.injectionMetadataCache.put(clazz, metadata);
                }
            }
        }
        return metadata;
View Full Code Here

Examples of org.springframework.beans.factory.annotation.InjectionMetadata

  @Override
  public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
    super.postProcessMergedBeanDefinition(beanDefinition, beanType, beanName);
    if (beanType != null) {
      InjectionMetadata metadata = findResourceMetadata(beanName, beanType);
      metadata.checkConfigMembers(beanDefinition);
    }
  }
View Full Code Here

Examples of org.springframework.beans.factory.annotation.InjectionMetadata

  @Override
  public PropertyValues postProcessPropertyValues(
      PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {

    InjectionMetadata metadata = findResourceMetadata(beanName, bean.getClass());
    try {
      metadata.inject(bean, beanName, pvs);
    }
    catch (Throwable ex) {
      throw new BeanCreationException(beanName, "Injection of resource dependencies failed", ex);
    }
    return pvs;
View Full Code Here

Examples of org.springframework.beans.factory.annotation.InjectionMetadata

  private InjectionMetadata findResourceMetadata(String beanName, final Class<?> clazz) {
    // Quick check on the concurrent map first, with minimal locking.
    // Fall back to class name as cache key, for backwards compatibility with custom callers.
    String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName());
    InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey);
    if (InjectionMetadata.needsRefresh(metadata, clazz)) {
      synchronized (this.injectionMetadataCache) {
        metadata = this.injectionMetadataCache.get(cacheKey);
        if (InjectionMetadata.needsRefresh(metadata, clazz)) {
          LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
          Class<?> targetClass = clazz;

          do {
            LinkedList<InjectionMetadata.InjectedElement> currElements = new LinkedList<InjectionMetadata.InjectedElement>();
            for (Field field : targetClass.getDeclaredFields()) {
              if (webServiceRefClass != null && field.isAnnotationPresent(webServiceRefClass)) {
                if (Modifier.isStatic(field.getModifiers())) {
                  throw new IllegalStateException("@WebServiceRef annotation is not supported on static fields");
                }
                currElements.add(new WebServiceRefElement(field, null));
              }
              else if (ejbRefClass != null && field.isAnnotationPresent(ejbRefClass)) {
                if (Modifier.isStatic(field.getModifiers())) {
                  throw new IllegalStateException("@EJB annotation is not supported on static fields");
                }
                currElements.add(new EjbRefElement(field, null));
              }
              else if (field.isAnnotationPresent(Resource.class)) {
                if (Modifier.isStatic(field.getModifiers())) {
                  throw new IllegalStateException("@Resource annotation is not supported on static fields");
                }
                if (!ignoredResourceTypes.contains(field.getType().getName())) {
                  currElements.add(new ResourceElement(field, null));
                }
              }
            }
            for (Method method : targetClass.getDeclaredMethods()) {
              if (!method.isBridge() && method.equals(ClassUtils.getMostSpecificMethod(method, clazz))) {
                if (webServiceRefClass != null && method.isAnnotationPresent(webServiceRefClass)) {
                  if (Modifier.isStatic(method.getModifiers())) {
                    throw new IllegalStateException("@WebServiceRef annotation is not supported on static methods");
                  }
                  if (method.getParameterTypes().length != 1) {
                    throw new IllegalStateException("@WebServiceRef annotation requires a single-arg method: " + method);
                  }
                  PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
                  currElements.add(new WebServiceRefElement(method, pd));
                }
                else if (ejbRefClass != null && method.isAnnotationPresent(ejbRefClass)) {
                  if (Modifier.isStatic(method.getModifiers())) {
                    throw new IllegalStateException("@EJB annotation is not supported on static methods");
                  }
                  if (method.getParameterTypes().length != 1) {
                    throw new IllegalStateException("@EJB annotation requires a single-arg method: " + method);
                  }
                  PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
                  currElements.add(new EjbRefElement(method, pd));
                }
                else if (method.isAnnotationPresent(Resource.class)) {
                  if (Modifier.isStatic(method.getModifiers())) {
                    throw new IllegalStateException("@Resource annotation is not supported on static methods");
                  }
                  Class<?>[] paramTypes = method.getParameterTypes();
                  if (paramTypes.length != 1) {
                    throw new IllegalStateException("@Resource annotation requires a single-arg method: " + method);
                  }
                  if (!ignoredResourceTypes.contains(paramTypes[0].getName())) {
                    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
                    currElements.add(new ResourceElement(method, pd));
                  }
                }
              }
            }
            elements.addAll(0, currElements);
            targetClass = targetClass.getSuperclass();
          }
          while (targetClass != null && targetClass != Object.class);

          metadata = new InjectionMetadata(clazz, elements);
          this.injectionMetadataCache.put(cacheKey, metadata);
        }
      }
    }
    return metadata;
View Full Code Here

Examples of org.springframework.beans.factory.annotation.InjectionMetadata


  @Override
  public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
    if (beanType != null) {
      InjectionMetadata metadata = findPersistenceMetadata(beanName, beanType);
      metadata.checkConfigMembers(beanDefinition);
    }
  }
View Full Code Here

Examples of org.springframework.beans.factory.annotation.InjectionMetadata

  @Override
  public PropertyValues postProcessPropertyValues(
      PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {

    InjectionMetadata metadata = findPersistenceMetadata(beanName, bean.getClass());
    try {
      metadata.inject(bean, beanName, pvs);
    }
    catch (Throwable ex) {
      throw new BeanCreationException(beanName, "Injection of persistence dependencies failed", ex);
    }
    return pvs;
View Full Code Here

Examples of org.springframework.beans.factory.annotation.InjectionMetadata

  private InjectionMetadata findPersistenceMetadata(String beanName, final Class<?> clazz) {
    // Quick check on the concurrent map first, with minimal locking.
    // Fall back to class name as cache key, for backwards compatibility with custom callers.
    String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName());
    InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey);
    if (InjectionMetadata.needsRefresh(metadata, clazz)) {
      synchronized (this.injectionMetadataCache) {
        metadata = this.injectionMetadataCache.get(cacheKey);
        if (InjectionMetadata.needsRefresh(metadata, clazz)) {
          LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
          Class<?> targetClass = clazz;

          do {
            LinkedList<InjectionMetadata.InjectedElement> currElements = new LinkedList<InjectionMetadata.InjectedElement>();
            for (Field field : targetClass.getDeclaredFields()) {
              PersistenceContext pc = field.getAnnotation(PersistenceContext.class);
              PersistenceUnit pu = field.getAnnotation(PersistenceUnit.class);
              if (pc != null || pu != null) {
                if (Modifier.isStatic(field.getModifiers())) {
                  throw new IllegalStateException("Persistence annotations are not supported on static fields");
                }
                currElements.add(new PersistenceElement(field, null));
              }
            }
            for (Method method : targetClass.getDeclaredMethods()) {
              PersistenceContext pc = method.getAnnotation(PersistenceContext.class);
              PersistenceUnit pu = method.getAnnotation(PersistenceUnit.class);
              if ((pc != null || pu != null) && !method.isBridge() &&
                  method.equals(ClassUtils.getMostSpecificMethod(method, clazz))) {
                if (Modifier.isStatic(method.getModifiers())) {
                  throw new IllegalStateException("Persistence annotations are not supported on static methods");
                }
                if (method.getParameterTypes().length != 1) {
                  throw new IllegalStateException("Persistence annotation requires a single-arg method: " + method);
                }
                PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
                currElements.add(new PersistenceElement(method, pd));
              }
            }
            elements.addAll(0, currElements);
            targetClass = targetClass.getSuperclass();
          }
          while (targetClass != null && targetClass != Object.class);

          metadata = new InjectionMetadata(clazz, elements);
          this.injectionMetadataCache.put(cacheKey, metadata);
        }
      }
    }
    return metadata;
View Full Code Here

Examples of org.springframework.beans.factory.annotation.InjectionMetadata

  @Override
  public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) {
    super.postProcessMergedBeanDefinition(beanDefinition, beanType, beanName);
    if (beanType != null) {
      InjectionMetadata metadata = findResourceMetadata(beanType);
      metadata.checkConfigMembers(beanDefinition);
    }
  }
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.