[jboss-cvs] jboss-seam/src/main/org/jboss/seam ...

Peter Muir peter at bleepbleep.org.uk
Wed Aug 8 05:47:07 EDT 2007


  User: pmuir   
  Date: 07/08/08 05:47:07

  Modified:    src/main/org/jboss/seam  Component.java
  Log:
  JBSEAM-1757
  
  Revision  Changes    Path
  1.280     +55 -1     jboss-seam/src/main/org/jboss/seam/Component.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Component.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/Component.java,v
  retrieving revision 1.279
  retrieving revision 1.280
  diff -u -b -r1.279 -r1.280
  --- Component.java	25 Jul 2007 14:40:30 -0000	1.279
  +++ Component.java	8 Aug 2007 09:47:07 -0000	1.280
  @@ -774,7 +774,7 @@
            if ( ann.annotationType().isAnnotationPresent(DataBinderClass.class) )
            {
               String name = toName( createWrapper(ann).getVariableName(ann), method );
  -            dataModelGetters.add( new BijectedMethod(name, method, ann) );
  +            dataModelGetters.add( new BijectedProperty(name, method, ann) );
               dataModelNames.add(name);
            }
            if ( ann.annotationType().isAnnotationPresent(DataSelectorClass.class) )
  @@ -2518,6 +2518,60 @@
         }
      }
      
  +   final class BijectedProperty<T extends Annotation> implements BijectedAttribute<T>
  +   {
  +      
  +      private BijectedMethod<T> getter;
  +      private BijectedMethod<T> setter;
  +      
  +      public BijectedProperty(String name, Method getter, Method setter, T annotation)
  +      {
  +         this.getter = new BijectedMethod(name, getter, annotation);
  +         this.setter = new BijectedMethod(name, setter, annotation);
  +      }
  +      
  +      public BijectedProperty(String name, Method getter, T annotation)
  +      {
  +         this.getter = new BijectedMethod(name, getter, annotation);
  +         Method setterMethod;
  +         try
  +         {
  +            setterMethod = Reflections.getSetterMethod(getter.getDeclaringClass(), name);
  +         }
  +         catch (IllegalArgumentException e)
  +         {
  +            throw new IllegalArgumentException("Component must have a getter/setter pair for property " + name + " annotated with @" + annotation.annotationType().getSimpleName(), e);
  +         }
  +         this.setter = new BijectedMethod(name, setterMethod, annotation);
  +      }
  +
  +      public Object get(Object bean)
  +      {
  +         return getter.get(bean);
  +      }
  +
  +      public T getAnnotation()
  +      {
  +         return getter.getAnnotation();
  +      }
  +
  +      public String getName()
  +      {
  +         return getter.getName();
  +      }
  +
  +      public Class getType()
  +      {
  +         return getter.getType();
  +      }
  +
  +      public void set(Object bean, Object value)
  +      {
  +         setter.set(bean, value); 
  +      }
  +      
  +   }
  +   
      final class BijectedField<T extends Annotation> implements BijectedAttribute<T>
      {
         private final String name;
  
  
  



More information about the jboss-cvs-commits mailing list