Uploaded image for project: 'ZK Spring'
  1. ZK Spring
  2. ZKSPRING-28

zkspring-core use JDK 1.6 class: javax.annotation.Resource

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 3.1
    • 3.0
    • core
    • None

      Because zk officially announces to support up to JDK 1.5, we should not use JDK 1.6 class or API.

      The code which use JDK 1.6 javax.annotation.Resource is as follows:

      public class ZkClassPathBeanDefinitionScanner extends ClassPathBeanDefinitionScanner {
      ...
      	private void registerZkComponentFactoryBean0(final BeanDefinition forbd, final String forbdId, final Class klass, final String controllername) {
      		ReflectionUtils.doWithFields(klass, new ReflectionUtils.FieldCallback() {
      			public void doWith(Field field) {
      				if (field.isAnnotationPresent(Resource.class)) {
      					if (Modifier.isStatic(field.getModifiers())) {
      						throw new IllegalStateException("@Resource annotation is not supported on static fields");
      					}
      					if (Component.class.isAssignableFrom(field.getType()) && !Components.isImplicit(field.getName())) {
      						registerZkComponentFactoryBean(field.getName(), controllername, false, "idspace");
      					}
      				}
      			}
      		});
      		ReflectionUtils.doWithMethods(klass, new ReflectionUtils.MethodCallback() {
      			@SuppressWarnings("deprecation")
      			public void doWith(Method method) {
      				if (method.isAnnotationPresent(Resource.class) &&
      						method.equals(ClassUtils.getMostSpecificMethod(method, klass))) {
      					if (Modifier.isStatic(method.getModifiers())) {
      						throw new IllegalStateException("@Resource annotation is not supported on static methods");
      					}
      					final Class[] paramTypes = method.getParameterTypes();
      					if (paramTypes.length != 1) {
      						throw new IllegalStateException("@Resource annotation requires a single-arg method: " + method);
      					}
      					if (Component.class.isAssignableFrom(paramTypes[0])) {
      						PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
      						if (!Components.isImplicit(pd.getName())) {
      							registerZkComponentFactoryBean(pd.getName(), controllername, false, "idspace");
      						}
      					}
      				} 
      ...
      }
      
      

            hawk hawk
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: