Package org.springframework.beans.factory.annotation

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


  }


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


  public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException {
    return null;
  }

  public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
    InjectionMetadata metadata = findPersistenceMetadata(bean.getClass());
    try {
      metadata.injectFields(bean, beanName);
    }
    catch (Throwable ex) {
      throw new BeanCreationException(beanName, "Injection of persistence fields failed", ex);
    }
    return true;
View Full Code Here

  }

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

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

  }


  private InjectionMetadata findPersistenceMetadata(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) {
          final InjectionMetadata newMetadata = new InjectionMetadata(clazz);
          ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
            public void doWith(Field field) {
              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");
                }
                newMetadata.addInjectedField(new PersistenceElement(field, null));
              }
            }
          });
          ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
            public void doWith(Method method) {
              PersistenceContext pc = method.getAnnotation(PersistenceContext.class);
              PersistenceUnit pu = method.getAnnotation(PersistenceUnit.class);
              if (pc != null || pu != null &&
                  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);
                newMetadata.addInjectedMethod(new PersistenceElement(method, pd));
              }
            }
          });
          metadata = newMetadata;
          this.injectionMetadataCache.put(clazz, metadata);
View Full Code Here

  }


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

  public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException {
    return null;
  }

  public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
    InjectionMetadata metadata = findPersistenceMetadata(bean.getClass());
    try {
      metadata.injectFields(bean, beanName);
    }
    catch (Throwable ex) {
      throw new BeanCreationException(beanName, "Injection of persistence fields failed", ex);
    }
    return true;
View Full Code Here

  }

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

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

  }

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

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

  }


  private InjectionMetadata findResourceMetadata(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) {
          final InjectionMetadata newMetadata = new InjectionMetadata();
          ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
            public void doWith(Field field) {
              if (webServiceRefClass != null && field.isAnnotationPresent(webServiceRefClass)) {
                if (Modifier.isStatic(field.getModifiers())) {
                  throw new IllegalStateException("@WebServiceRef annotation is not supported on static fields");
                }
                newMetadata.addInjectedField(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");
                }
                newMetadata.addInjectedField(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");
                }
                newMetadata.addInjectedField(new ResourceElement(field, null));
              }
            }
          });
          ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
            public void doWith(Method method) {
              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);
                newMetadata.addInjectedMethod(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);
                newMetadata.addInjectedMethod(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");
                }
                if (method.getParameterTypes().length != 1) {
                  throw new IllegalStateException("@Resource annotation requires a single-arg method: " + method);
                }
                PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
                newMetadata.addInjectedMethod(new ResourceElement(method, pd));
              }
            }
          });
          metadata = newMetadata;
          this.injectionMetadataCache.put(clazz, metadata);
View Full Code Here

  public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException {
    return null;
  }

  public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
    InjectionMetadata metadata = findResourceMetadata(bean.getClass());
    try {
      metadata.injectFields(bean, beanName);
    }
    catch (Throwable ex) {
      throw new BeanCreationException(beanName, "Injection of resource fields failed", ex);
    }
    return true;
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement

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.