You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by ka...@apache.org on 2012/11/02 03:28:51 UTC

git commit: FIXED - TAP5-2022: Add PropertyAccess.getAnnotation - implement convenience for PropertyAccess.getAdapter().getPropertyAdapter().getAnnotation()

Updated Branches:
  refs/heads/master 015816ed4 -> b108e06f4


FIXED - TAP5-2022: Add PropertyAccess.getAnnotation 
- implement convenience for
PropertyAccess.getAdapter().getPropertyAdapter().getAnnotation()


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/b108e06f
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/b108e06f
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/b108e06f

Branch: refs/heads/master
Commit: b108e06f4b633d77461dda220a07016ee806c0c7
Parents: 015816e
Author: Kalle Korhonen <ka...@apache.org>
Authored: Thu Nov 1 19:28:25 2012 -0700
Committer: Kalle Korhonen <ka...@apache.org>
Committed: Thu Nov 1 19:28:25 2012 -0700

----------------------------------------------------------------------
 .../services/ClassPropertyAdapterImpl.java         |   15 ++++++---
 .../ioc/internal/services/PropertyAccessImpl.java  |   14 ++++++--
 .../ioc/services/ClassPropertyAdapter.java         |   14 ++++++++
 .../tapestry5/ioc/services/PropertyAccess.java     |   20 +++++++++++-
 .../groovy/ioc/specs/PropertyAccessImplSpec.groovy |   24 +++++++++++----
 5 files changed, 70 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
index b96a0c2..7da0728 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
@@ -14,18 +14,19 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
-import org.apache.tapestry5.ioc.internal.util.GenericsUtils;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
-import org.apache.tapestry5.ioc.services.PropertyAdapter;
+import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
 
 import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.List;
 import java.util.Map;
 
-import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
+import org.apache.tapestry5.ioc.internal.util.GenericsUtils;
+import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
+import org.apache.tapestry5.ioc.services.PropertyAdapter;
 
 public class ClassPropertyAdapterImpl implements ClassPropertyAdapter
 {
@@ -105,6 +106,10 @@ public class ClassPropertyAdapterImpl implements ClassPropertyAdapter
         adaptorFor(propertyName).set(instance, value);
     }
 
+    public Annotation getAnnotation(Object instance, String propertyName, Class<? extends Annotation> annotationClass) {
+	return adaptorFor(propertyName).getAnnotation(annotationClass);
+    }
+
     private PropertyAdapter adaptorFor(String name)
     {
         PropertyAdapter pa = adapters.get(name);

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
index e37158b..5eb1b3c 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
@@ -14,14 +14,11 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.Arrays;
@@ -29,6 +26,10 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+
 @SuppressWarnings("unchecked")
 public class PropertyAccessImpl implements PropertyAccess
 {
@@ -44,6 +45,11 @@ public class PropertyAccessImpl implements PropertyAccess
         getAdapter(instance).set(instance, propertyName, value);
     }
 
+    public Annotation getAnnotation(Object instance, String propertyName, Class<? extends Annotation> annotationClass) {
+	return getAdapter(instance).getAnnotation(instance, propertyName, annotationClass);
+    }
+
+
     /**
      * Clears the cache of adapters and asks the {@link Introspector} to clear its cache.
      */

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
index 409a950..6159ed3 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry5.ioc.services;
 
+import java.lang.annotation.Annotation;
 import java.util.List;
 
 /**
@@ -62,4 +63,17 @@ public interface ClassPropertyAdapter
      * @throws IllegalArgumentException      if property does not exist
      */
     void set(Object instance, String propertyName, Object value);
+
+    /**
+     * Returns the annotation of a given property for the specified type if such an annotation is present, else null.
+     *
+     * @param instance     the object to read a value from
+     * @param propertyName the name of the property to read (case is ignored)
+     * @param annotationClass the type of annotation to return
+     *
+     * @throws IllegalArgumentException      if property does not exist
+     *
+     * @since 5.4
+     */
+    Annotation getAnnotation(Object instance, String propertyName, Class<? extends Annotation> annotationClass);
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
index a7422d0..1a02a96 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
@@ -14,6 +14,8 @@
 
 package org.apache.tapestry5.ioc.services;
 
+import java.lang.annotation.Annotation;
+
 /**
  * A wrapper around the JavaBean Introspector that allows more manageable access to JavaBean properties of objects.
  * <p/>
@@ -26,7 +28,7 @@ public interface PropertyAccess
 {
     /**
      * Reads the value of a property.
-     * 
+     *
      * @throws UnsupportedOperationException
      *             if the property is write only
      * @throws IllegalArgumentException
@@ -36,7 +38,7 @@ public interface PropertyAccess
 
     /**
      * Updates the value of a property.
-     * 
+     *
      * @throws UnsupportedOperationException
      *             if the property is read only
      * @throws IllegalArgumentException
@@ -45,6 +47,20 @@ public interface PropertyAccess
     void set(Object instance, String propertyName, Object value);
 
     /**
+     * Returns the annotation of a given property for the specified type if such an annotation is present, else null.
+     * A convenience over invoking {@link #getAdapter(Object)}.{@link #ClassPropertyAdapter.getPropertyAdapter(String)}.{@link #PropertyAdapter.getAnnotation(Class)}
+     *
+     * @param instance     the object to read a value from
+     * @param propertyName the name of the property to read (case is ignored)
+     * @param annotationClass the type of annotation to return
+     * @throws IllegalArgumentException
+     *             if property does not exist
+     *
+     * @since 5.4
+     */
+    Annotation getAnnotation(Object instance, String propertyName, Class<? extends Annotation> annotationClass);
+
+    /**
      * Returns the adapter for a particular object instance. A convienience over invoking {@link #getAdapter(Class)}.
      */
     ClassPropertyAdapter getAdapter(Object instance);

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy b/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
index 93a1459..f0ac187 100644
--- a/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
@@ -1,21 +1,20 @@
 package ioc.specs
 
+import java.awt.Image
+import java.beans.*
+import java.lang.reflect.Method
+
 import org.apache.tapestry5.beaneditor.DataType
 import org.apache.tapestry5.beaneditor.Validate
 import org.apache.tapestry5.ioc.annotations.Scope
+import org.apache.tapestry5.ioc.internal.services.*
 import org.apache.tapestry5.ioc.internal.util.Pair
 import org.apache.tapestry5.ioc.internal.util.StringLongPair
 import org.apache.tapestry5.ioc.services.ClassPropertyAdapter
 import org.apache.tapestry5.ioc.services.PropertyAccess
 
-import java.awt.Image
-import java.lang.reflect.Method
-
-import org.apache.tapestry5.ioc.internal.services.*
 import spock.lang.*
 
-import java.beans.*
-
 class ExceptionBean {
 
   boolean getFailure() {
@@ -438,6 +437,19 @@ class PropertyAccessImplSpec extends Specification {
     cpa.propertyNames == ["class", "primitiveProperty"]
   }
 
+  def "getAnnotation from a bean property"() {
+    AnnotatedBean b = new AnnotatedBean()
+
+    when:
+
+    def annotation = access.getAnnotation(b, "annotationOnRead", Scope)
+
+    then:
+
+    annotation.value() == "onread"
+  }
+
+
   def "getAnnotation() when annotation is not present is null"() {
 
     when:


Re: git commit: FIXED - TAP5-2022: Add PropertyAccess.getAnnotation - implement convenience for PropertyAccess.getAdapter().getPropertyAdapter().getAnnotation()

Posted by Bob Harner <bo...@gmail.com>.
https://builds.apache.org/job/tapestry-trunk-freestyle/ws/tapestry-core/build/reports/tests/index.html
shows the error as:

    Page did not contain 'Oscar' -- from TreeTests.groovy line 66.

On Fri, Nov 2, 2012 at 10:57 AM, Kalle Korhonen
<ka...@gmail.com> wrote:
> On Fri, Nov 2, 2012 at 1:20 AM, Ulrich Stärk <ul...@spielviel.de> wrote:
>
>> Please also fix the build ;)
>> Uli
>>
>
> I couldn't access builds.apache.org (502 or the requests never complete). I
> added one test and all ioc tests pass on my machine. I'm not quite sure how
> the addition would break the build or is it just the suite is unreliable?
>
> Kalle
>
>
>>
>> On 02.11.2012 03:28, kaosko@apache.org wrote:
>> > Updated Branches:
>> >   refs/heads/master 015816ed4 -> b108e06f4
>> >
>> >
>> > FIXED - TAP5-2022: Add PropertyAccess.getAnnotation
>> > - implement convenience for
>> > PropertyAccess.getAdapter().getPropertyAdapter().getAnnotation()
>> >
>> >
>> > Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
>> > Commit:
>> http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/b108e06f
>> > Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/b108e06f
>> > Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/b108e06f
>> >
>> > Branch: refs/heads/master
>> > Commit: b108e06f4b633d77461dda220a07016ee806c0c7
>> > Parents: 015816e
>> > Author: Kalle Korhonen <ka...@apache.org>
>> > Authored: Thu Nov 1 19:28:25 2012 -0700
>> > Committer: Kalle Korhonen <ka...@apache.org>
>> > Committed: Thu Nov 1 19:28:25 2012 -0700
>> >
>> > ----------------------------------------------------------------------
>> >  .../services/ClassPropertyAdapterImpl.java         |   15 ++++++---
>> >  .../ioc/internal/services/PropertyAccessImpl.java  |   14 ++++++--
>> >  .../ioc/services/ClassPropertyAdapter.java         |   14 ++++++++
>> >  .../tapestry5/ioc/services/PropertyAccess.java     |   20 +++++++++++-
>> >  .../groovy/ioc/specs/PropertyAccessImplSpec.groovy |   24
>> +++++++++++----
>> >  5 files changed, 70 insertions(+), 17 deletions(-)
>> > ----------------------------------------------------------------------
>> >
>> >
>> >
>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
>> > ----------------------------------------------------------------------
>> > diff --git
>> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
>> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
>> > index b96a0c2..7da0728 100644
>> > ---
>> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
>> > +++
>> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
>> > @@ -14,18 +14,19 @@
>> >
>> >  package org.apache.tapestry5.ioc.internal.services;
>> >
>> > -import org.apache.tapestry5.ioc.internal.util.GenericsUtils;
>> > -import org.apache.tapestry5.ioc.internal.util.InternalUtils;
>> > -import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
>> > -import org.apache.tapestry5.ioc.services.PropertyAdapter;
>> > +import static
>> org.apache.tapestry5.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
>> >
>> >  import java.beans.PropertyDescriptor;
>> > +import java.lang.annotation.Annotation;
>> >  import java.lang.reflect.Field;
>> >  import java.lang.reflect.Method;
>> >  import java.util.List;
>> >  import java.util.Map;
>> >
>> > -import static
>> org.apache.tapestry5.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
>> > +import org.apache.tapestry5.ioc.internal.util.GenericsUtils;
>> > +import org.apache.tapestry5.ioc.internal.util.InternalUtils;
>> > +import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
>> > +import org.apache.tapestry5.ioc.services.PropertyAdapter;
>> >
>> >  public class ClassPropertyAdapterImpl implements ClassPropertyAdapter
>> >  {
>> > @@ -105,6 +106,10 @@ public class ClassPropertyAdapterImpl implements
>> ClassPropertyAdapter
>> >          adaptorFor(propertyName).set(instance, value);
>> >      }
>> >
>> > +    public Annotation getAnnotation(Object instance, String
>> propertyName, Class<? extends Annotation> annotationClass) {
>> > +     return adaptorFor(propertyName).getAnnotation(annotationClass);
>> > +    }
>> > +
>> >      private PropertyAdapter adaptorFor(String name)
>> >      {
>> >          PropertyAdapter pa = adapters.get(name);
>> >
>> >
>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
>> > ----------------------------------------------------------------------
>> > diff --git
>> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
>> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
>> > index e37158b..5eb1b3c 100644
>> > ---
>> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
>> > +++
>> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
>> > @@ -14,14 +14,11 @@
>> >
>> >  package org.apache.tapestry5.ioc.internal.services;
>> >
>> > -import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
>> > -import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
>> > -import org.apache.tapestry5.ioc.services.PropertyAccess;
>> > -
>> >  import java.beans.BeanInfo;
>> >  import java.beans.IntrospectionException;
>> >  import java.beans.Introspector;
>> >  import java.beans.PropertyDescriptor;
>> > +import java.lang.annotation.Annotation;
>> >  import java.lang.reflect.Method;
>> >  import java.lang.reflect.Modifier;
>> >  import java.util.Arrays;
>> > @@ -29,6 +26,10 @@ import java.util.LinkedList;
>> >  import java.util.List;
>> >  import java.util.Map;
>> >
>> > +import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
>> > +import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
>> > +import org.apache.tapestry5.ioc.services.PropertyAccess;
>> > +
>> >  @SuppressWarnings("unchecked")
>> >  public class PropertyAccessImpl implements PropertyAccess
>> >  {
>> > @@ -44,6 +45,11 @@ public class PropertyAccessImpl implements
>> PropertyAccess
>> >          getAdapter(instance).set(instance, propertyName, value);
>> >      }
>> >
>> > +    public Annotation getAnnotation(Object instance, String
>> propertyName, Class<? extends Annotation> annotationClass) {
>> > +     return getAdapter(instance).getAnnotation(instance, propertyName,
>> annotationClass);
>> > +    }
>> > +
>> > +
>> >      /**
>> >       * Clears the cache of adapters and asks the {@link Introspector}
>> to clear its cache.
>> >       */
>> >
>> >
>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
>> > ----------------------------------------------------------------------
>> > diff --git
>> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
>> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
>> > index 409a950..6159ed3 100644
>> > ---
>> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
>> > +++
>> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
>> > @@ -14,6 +14,7 @@
>> >
>> >  package org.apache.tapestry5.ioc.services;
>> >
>> > +import java.lang.annotation.Annotation;
>> >  import java.util.List;
>> >
>> >  /**
>> > @@ -62,4 +63,17 @@ public interface ClassPropertyAdapter
>> >       * @throws IllegalArgumentException      if property does not exist
>> >       */
>> >      void set(Object instance, String propertyName, Object value);
>> > +
>> > +    /**
>> > +     * Returns the annotation of a given property for the specified
>> type if such an annotation is present, else null.
>> > +     *
>> > +     * @param instance     the object to read a value from
>> > +     * @param propertyName the name of the property to read (case is
>> ignored)
>> > +     * @param annotationClass the type of annotation to return
>> > +     *
>> > +     * @throws IllegalArgumentException      if property does not exist
>> > +     *
>> > +     * @since 5.4
>> > +     */
>> > +    Annotation getAnnotation(Object instance, String propertyName,
>> Class<? extends Annotation> annotationClass);
>> >  }
>> >
>> >
>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
>> > ----------------------------------------------------------------------
>> > diff --git
>> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
>> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
>> > index a7422d0..1a02a96 100644
>> > ---
>> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
>> > +++
>> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
>> > @@ -14,6 +14,8 @@
>> >
>> >  package org.apache.tapestry5.ioc.services;
>> >
>> > +import java.lang.annotation.Annotation;
>> > +
>> >  /**
>> >   * A wrapper around the JavaBean Introspector that allows more
>> manageable access to JavaBean properties of objects.
>> >   * <p/>
>> > @@ -26,7 +28,7 @@ public interface PropertyAccess
>> >  {
>> >      /**
>> >       * Reads the value of a property.
>> > -     *
>> > +     *
>> >       * @throws UnsupportedOperationException
>> >       *             if the property is write only
>> >       * @throws IllegalArgumentException
>> > @@ -36,7 +38,7 @@ public interface PropertyAccess
>> >
>> >      /**
>> >       * Updates the value of a property.
>> > -     *
>> > +     *
>> >       * @throws UnsupportedOperationException
>> >       *             if the property is read only
>> >       * @throws IllegalArgumentException
>> > @@ -45,6 +47,20 @@ public interface PropertyAccess
>> >      void set(Object instance, String propertyName, Object value);
>> >
>> >      /**
>> > +     * Returns the annotation of a given property for the specified
>> type if such an annotation is present, else null.
>> > +     * A convenience over invoking {@link #getAdapter(Object)}.{@link
>> #ClassPropertyAdapter.getPropertyAdapter(String)}.{@link
>> #PropertyAdapter.getAnnotation(Class)}
>> > +     *
>> > +     * @param instance     the object to read a value from
>> > +     * @param propertyName the name of the property to read (case is
>> ignored)
>> > +     * @param annotationClass the type of annotation to return
>> > +     * @throws IllegalArgumentException
>> > +     *             if property does not exist
>> > +     *
>> > +     * @since 5.4
>> > +     */
>> > +    Annotation getAnnotation(Object instance, String propertyName,
>> Class<? extends Annotation> annotationClass);
>> > +
>> > +    /**
>> >       * Returns the adapter for a particular object instance. A
>> convienience over invoking {@link #getAdapter(Class)}.
>> >       */
>> >      ClassPropertyAdapter getAdapter(Object instance);
>> >
>> >
>> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
>> > ----------------------------------------------------------------------
>> > diff --git
>> a/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
>> b/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
>> > index 93a1459..f0ac187 100644
>> > ---
>> a/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
>> > +++
>> b/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
>> > @@ -1,21 +1,20 @@
>> >  package ioc.specs
>> >
>> > +import java.awt.Image
>> > +import java.beans.*
>> > +import java.lang.reflect.Method
>> > +
>> >  import org.apache.tapestry5.beaneditor.DataType
>> >  import org.apache.tapestry5.beaneditor.Validate
>> >  import org.apache.tapestry5.ioc.annotations.Scope
>> > +import org.apache.tapestry5.ioc.internal.services.*
>> >  import org.apache.tapestry5.ioc.internal.util.Pair
>> >  import org.apache.tapestry5.ioc.internal.util.StringLongPair
>> >  import org.apache.tapestry5.ioc.services.ClassPropertyAdapter
>> >  import org.apache.tapestry5.ioc.services.PropertyAccess
>> >
>> > -import java.awt.Image
>> > -import java.lang.reflect.Method
>> > -
>> > -import org.apache.tapestry5.ioc.internal.services.*
>> >  import spock.lang.*
>> >
>> > -import java.beans.*
>> > -
>> >  class ExceptionBean {
>> >
>> >    boolean getFailure() {
>> > @@ -438,6 +437,19 @@ class PropertyAccessImplSpec extends Specification {
>> >      cpa.propertyNames == ["class", "primitiveProperty"]
>> >    }
>> >
>> > +  def "getAnnotation from a bean property"() {
>> > +    AnnotatedBean b = new AnnotatedBean()
>> > +
>> > +    when:
>> > +
>> > +    def annotation = access.getAnnotation(b, "annotationOnRead", Scope)
>> > +
>> > +    then:
>> > +
>> > +    annotation.value() == "onread"
>> > +  }
>> > +
>> > +
>> >    def "getAnnotation() when annotation is not present is null"() {
>> >
>> >      when:
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: dev-help@tapestry.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: git commit: FIXED - TAP5-2022: Add PropertyAccess.getAnnotation - implement convenience for PropertyAccess.getAdapter().getPropertyAdapter().getAnnotation()

Posted by Kalle Korhonen <ka...@gmail.com>.
On Fri, Nov 2, 2012 at 1:20 AM, Ulrich Stärk <ul...@spielviel.de> wrote:

> Please also fix the build ;)
> Uli
>

I couldn't access builds.apache.org (502 or the requests never complete). I
added one test and all ioc tests pass on my machine. I'm not quite sure how
the addition would break the build or is it just the suite is unreliable?

Kalle


>
> On 02.11.2012 03:28, kaosko@apache.org wrote:
> > Updated Branches:
> >   refs/heads/master 015816ed4 -> b108e06f4
> >
> >
> > FIXED - TAP5-2022: Add PropertyAccess.getAnnotation
> > - implement convenience for
> > PropertyAccess.getAdapter().getPropertyAdapter().getAnnotation()
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
> > Commit:
> http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/b108e06f
> > Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/b108e06f
> > Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/b108e06f
> >
> > Branch: refs/heads/master
> > Commit: b108e06f4b633d77461dda220a07016ee806c0c7
> > Parents: 015816e
> > Author: Kalle Korhonen <ka...@apache.org>
> > Authored: Thu Nov 1 19:28:25 2012 -0700
> > Committer: Kalle Korhonen <ka...@apache.org>
> > Committed: Thu Nov 1 19:28:25 2012 -0700
> >
> > ----------------------------------------------------------------------
> >  .../services/ClassPropertyAdapterImpl.java         |   15 ++++++---
> >  .../ioc/internal/services/PropertyAccessImpl.java  |   14 ++++++--
> >  .../ioc/services/ClassPropertyAdapter.java         |   14 ++++++++
> >  .../tapestry5/ioc/services/PropertyAccess.java     |   20 +++++++++++-
> >  .../groovy/ioc/specs/PropertyAccessImplSpec.groovy |   24
> +++++++++++----
> >  5 files changed, 70 insertions(+), 17 deletions(-)
> > ----------------------------------------------------------------------
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
> > ----------------------------------------------------------------------
> > diff --git
> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
> > index b96a0c2..7da0728 100644
> > ---
> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
> > +++
> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
> > @@ -14,18 +14,19 @@
> >
> >  package org.apache.tapestry5.ioc.internal.services;
> >
> > -import org.apache.tapestry5.ioc.internal.util.GenericsUtils;
> > -import org.apache.tapestry5.ioc.internal.util.InternalUtils;
> > -import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
> > -import org.apache.tapestry5.ioc.services.PropertyAdapter;
> > +import static
> org.apache.tapestry5.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
> >
> >  import java.beans.PropertyDescriptor;
> > +import java.lang.annotation.Annotation;
> >  import java.lang.reflect.Field;
> >  import java.lang.reflect.Method;
> >  import java.util.List;
> >  import java.util.Map;
> >
> > -import static
> org.apache.tapestry5.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
> > +import org.apache.tapestry5.ioc.internal.util.GenericsUtils;
> > +import org.apache.tapestry5.ioc.internal.util.InternalUtils;
> > +import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
> > +import org.apache.tapestry5.ioc.services.PropertyAdapter;
> >
> >  public class ClassPropertyAdapterImpl implements ClassPropertyAdapter
> >  {
> > @@ -105,6 +106,10 @@ public class ClassPropertyAdapterImpl implements
> ClassPropertyAdapter
> >          adaptorFor(propertyName).set(instance, value);
> >      }
> >
> > +    public Annotation getAnnotation(Object instance, String
> propertyName, Class<? extends Annotation> annotationClass) {
> > +     return adaptorFor(propertyName).getAnnotation(annotationClass);
> > +    }
> > +
> >      private PropertyAdapter adaptorFor(String name)
> >      {
> >          PropertyAdapter pa = adapters.get(name);
> >
> >
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
> > ----------------------------------------------------------------------
> > diff --git
> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
> > index e37158b..5eb1b3c 100644
> > ---
> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
> > +++
> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
> > @@ -14,14 +14,11 @@
> >
> >  package org.apache.tapestry5.ioc.internal.services;
> >
> > -import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
> > -import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
> > -import org.apache.tapestry5.ioc.services.PropertyAccess;
> > -
> >  import java.beans.BeanInfo;
> >  import java.beans.IntrospectionException;
> >  import java.beans.Introspector;
> >  import java.beans.PropertyDescriptor;
> > +import java.lang.annotation.Annotation;
> >  import java.lang.reflect.Method;
> >  import java.lang.reflect.Modifier;
> >  import java.util.Arrays;
> > @@ -29,6 +26,10 @@ import java.util.LinkedList;
> >  import java.util.List;
> >  import java.util.Map;
> >
> > +import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
> > +import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
> > +import org.apache.tapestry5.ioc.services.PropertyAccess;
> > +
> >  @SuppressWarnings("unchecked")
> >  public class PropertyAccessImpl implements PropertyAccess
> >  {
> > @@ -44,6 +45,11 @@ public class PropertyAccessImpl implements
> PropertyAccess
> >          getAdapter(instance).set(instance, propertyName, value);
> >      }
> >
> > +    public Annotation getAnnotation(Object instance, String
> propertyName, Class<? extends Annotation> annotationClass) {
> > +     return getAdapter(instance).getAnnotation(instance, propertyName,
> annotationClass);
> > +    }
> > +
> > +
> >      /**
> >       * Clears the cache of adapters and asks the {@link Introspector}
> to clear its cache.
> >       */
> >
> >
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
> > ----------------------------------------------------------------------
> > diff --git
> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
> > index 409a950..6159ed3 100644
> > ---
> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
> > +++
> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
> > @@ -14,6 +14,7 @@
> >
> >  package org.apache.tapestry5.ioc.services;
> >
> > +import java.lang.annotation.Annotation;
> >  import java.util.List;
> >
> >  /**
> > @@ -62,4 +63,17 @@ public interface ClassPropertyAdapter
> >       * @throws IllegalArgumentException      if property does not exist
> >       */
> >      void set(Object instance, String propertyName, Object value);
> > +
> > +    /**
> > +     * Returns the annotation of a given property for the specified
> type if such an annotation is present, else null.
> > +     *
> > +     * @param instance     the object to read a value from
> > +     * @param propertyName the name of the property to read (case is
> ignored)
> > +     * @param annotationClass the type of annotation to return
> > +     *
> > +     * @throws IllegalArgumentException      if property does not exist
> > +     *
> > +     * @since 5.4
> > +     */
> > +    Annotation getAnnotation(Object instance, String propertyName,
> Class<? extends Annotation> annotationClass);
> >  }
> >
> >
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
> > ----------------------------------------------------------------------
> > diff --git
> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
> > index a7422d0..1a02a96 100644
> > ---
> a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
> > +++
> b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
> > @@ -14,6 +14,8 @@
> >
> >  package org.apache.tapestry5.ioc.services;
> >
> > +import java.lang.annotation.Annotation;
> > +
> >  /**
> >   * A wrapper around the JavaBean Introspector that allows more
> manageable access to JavaBean properties of objects.
> >   * <p/>
> > @@ -26,7 +28,7 @@ public interface PropertyAccess
> >  {
> >      /**
> >       * Reads the value of a property.
> > -     *
> > +     *
> >       * @throws UnsupportedOperationException
> >       *             if the property is write only
> >       * @throws IllegalArgumentException
> > @@ -36,7 +38,7 @@ public interface PropertyAccess
> >
> >      /**
> >       * Updates the value of a property.
> > -     *
> > +     *
> >       * @throws UnsupportedOperationException
> >       *             if the property is read only
> >       * @throws IllegalArgumentException
> > @@ -45,6 +47,20 @@ public interface PropertyAccess
> >      void set(Object instance, String propertyName, Object value);
> >
> >      /**
> > +     * Returns the annotation of a given property for the specified
> type if such an annotation is present, else null.
> > +     * A convenience over invoking {@link #getAdapter(Object)}.{@link
> #ClassPropertyAdapter.getPropertyAdapter(String)}.{@link
> #PropertyAdapter.getAnnotation(Class)}
> > +     *
> > +     * @param instance     the object to read a value from
> > +     * @param propertyName the name of the property to read (case is
> ignored)
> > +     * @param annotationClass the type of annotation to return
> > +     * @throws IllegalArgumentException
> > +     *             if property does not exist
> > +     *
> > +     * @since 5.4
> > +     */
> > +    Annotation getAnnotation(Object instance, String propertyName,
> Class<? extends Annotation> annotationClass);
> > +
> > +    /**
> >       * Returns the adapter for a particular object instance. A
> convienience over invoking {@link #getAdapter(Class)}.
> >       */
> >      ClassPropertyAdapter getAdapter(Object instance);
> >
> >
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
> > ----------------------------------------------------------------------
> > diff --git
> a/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
> b/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
> > index 93a1459..f0ac187 100644
> > ---
> a/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
> > +++
> b/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
> > @@ -1,21 +1,20 @@
> >  package ioc.specs
> >
> > +import java.awt.Image
> > +import java.beans.*
> > +import java.lang.reflect.Method
> > +
> >  import org.apache.tapestry5.beaneditor.DataType
> >  import org.apache.tapestry5.beaneditor.Validate
> >  import org.apache.tapestry5.ioc.annotations.Scope
> > +import org.apache.tapestry5.ioc.internal.services.*
> >  import org.apache.tapestry5.ioc.internal.util.Pair
> >  import org.apache.tapestry5.ioc.internal.util.StringLongPair
> >  import org.apache.tapestry5.ioc.services.ClassPropertyAdapter
> >  import org.apache.tapestry5.ioc.services.PropertyAccess
> >
> > -import java.awt.Image
> > -import java.lang.reflect.Method
> > -
> > -import org.apache.tapestry5.ioc.internal.services.*
> >  import spock.lang.*
> >
> > -import java.beans.*
> > -
> >  class ExceptionBean {
> >
> >    boolean getFailure() {
> > @@ -438,6 +437,19 @@ class PropertyAccessImplSpec extends Specification {
> >      cpa.propertyNames == ["class", "primitiveProperty"]
> >    }
> >
> > +  def "getAnnotation from a bean property"() {
> > +    AnnotatedBean b = new AnnotatedBean()
> > +
> > +    when:
> > +
> > +    def annotation = access.getAnnotation(b, "annotationOnRead", Scope)
> > +
> > +    then:
> > +
> > +    annotation.value() == "onread"
> > +  }
> > +
> > +
> >    def "getAnnotation() when annotation is not present is null"() {
> >
> >      when:
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>

Re: git commit: FIXED - TAP5-2022: Add PropertyAccess.getAnnotation - implement convenience for PropertyAccess.getAdapter().getPropertyAdapter().getAnnotation()

Posted by Ulrich Stärk <ul...@spielviel.de>.
Please also fix the build ;)

Uli

On 02.11.2012 03:28, kaosko@apache.org wrote:
> Updated Branches:
>   refs/heads/master 015816ed4 -> b108e06f4
> 
> 
> FIXED - TAP5-2022: Add PropertyAccess.getAnnotation 
> - implement convenience for
> PropertyAccess.getAdapter().getPropertyAdapter().getAnnotation()
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
> Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/b108e06f
> Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/b108e06f
> Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/b108e06f
> 
> Branch: refs/heads/master
> Commit: b108e06f4b633d77461dda220a07016ee806c0c7
> Parents: 015816e
> Author: Kalle Korhonen <ka...@apache.org>
> Authored: Thu Nov 1 19:28:25 2012 -0700
> Committer: Kalle Korhonen <ka...@apache.org>
> Committed: Thu Nov 1 19:28:25 2012 -0700
> 
> ----------------------------------------------------------------------
>  .../services/ClassPropertyAdapterImpl.java         |   15 ++++++---
>  .../ioc/internal/services/PropertyAccessImpl.java  |   14 ++++++--
>  .../ioc/services/ClassPropertyAdapter.java         |   14 ++++++++
>  .../tapestry5/ioc/services/PropertyAccess.java     |   20 +++++++++++-
>  .../groovy/ioc/specs/PropertyAccessImplSpec.groovy |   24 +++++++++++----
>  5 files changed, 70 insertions(+), 17 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
> index b96a0c2..7da0728 100644
> --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
> +++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ClassPropertyAdapterImpl.java
> @@ -14,18 +14,19 @@
>  
>  package org.apache.tapestry5.ioc.internal.services;
>  
> -import org.apache.tapestry5.ioc.internal.util.GenericsUtils;
> -import org.apache.tapestry5.ioc.internal.util.InternalUtils;
> -import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
> -import org.apache.tapestry5.ioc.services.PropertyAdapter;
> +import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
>  
>  import java.beans.PropertyDescriptor;
> +import java.lang.annotation.Annotation;
>  import java.lang.reflect.Field;
>  import java.lang.reflect.Method;
>  import java.util.List;
>  import java.util.Map;
>  
> -import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
> +import org.apache.tapestry5.ioc.internal.util.GenericsUtils;
> +import org.apache.tapestry5.ioc.internal.util.InternalUtils;
> +import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
> +import org.apache.tapestry5.ioc.services.PropertyAdapter;
>  
>  public class ClassPropertyAdapterImpl implements ClassPropertyAdapter
>  {
> @@ -105,6 +106,10 @@ public class ClassPropertyAdapterImpl implements ClassPropertyAdapter
>          adaptorFor(propertyName).set(instance, value);
>      }
>  
> +    public Annotation getAnnotation(Object instance, String propertyName, Class<? extends Annotation> annotationClass) {
> +	return adaptorFor(propertyName).getAnnotation(annotationClass);
> +    }
> +
>      private PropertyAdapter adaptorFor(String name)
>      {
>          PropertyAdapter pa = adapters.get(name);
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
> index e37158b..5eb1b3c 100644
> --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
> +++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImpl.java
> @@ -14,14 +14,11 @@
>  
>  package org.apache.tapestry5.ioc.internal.services;
>  
> -import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
> -import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
> -import org.apache.tapestry5.ioc.services.PropertyAccess;
> -
>  import java.beans.BeanInfo;
>  import java.beans.IntrospectionException;
>  import java.beans.Introspector;
>  import java.beans.PropertyDescriptor;
> +import java.lang.annotation.Annotation;
>  import java.lang.reflect.Method;
>  import java.lang.reflect.Modifier;
>  import java.util.Arrays;
> @@ -29,6 +26,10 @@ import java.util.LinkedList;
>  import java.util.List;
>  import java.util.Map;
>  
> +import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
> +import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
> +import org.apache.tapestry5.ioc.services.PropertyAccess;
> +
>  @SuppressWarnings("unchecked")
>  public class PropertyAccessImpl implements PropertyAccess
>  {
> @@ -44,6 +45,11 @@ public class PropertyAccessImpl implements PropertyAccess
>          getAdapter(instance).set(instance, propertyName, value);
>      }
>  
> +    public Annotation getAnnotation(Object instance, String propertyName, Class<? extends Annotation> annotationClass) {
> +	return getAdapter(instance).getAnnotation(instance, propertyName, annotationClass);
> +    }
> +
> +
>      /**
>       * Clears the cache of adapters and asks the {@link Introspector} to clear its cache.
>       */
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
> index 409a950..6159ed3 100644
> --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
> +++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassPropertyAdapter.java
> @@ -14,6 +14,7 @@
>  
>  package org.apache.tapestry5.ioc.services;
>  
> +import java.lang.annotation.Annotation;
>  import java.util.List;
>  
>  /**
> @@ -62,4 +63,17 @@ public interface ClassPropertyAdapter
>       * @throws IllegalArgumentException      if property does not exist
>       */
>      void set(Object instance, String propertyName, Object value);
> +
> +    /**
> +     * Returns the annotation of a given property for the specified type if such an annotation is present, else null.
> +     *
> +     * @param instance     the object to read a value from
> +     * @param propertyName the name of the property to read (case is ignored)
> +     * @param annotationClass the type of annotation to return
> +     *
> +     * @throws IllegalArgumentException      if property does not exist
> +     *
> +     * @since 5.4
> +     */
> +    Annotation getAnnotation(Object instance, String propertyName, Class<? extends Annotation> annotationClass);
>  }
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
> index a7422d0..1a02a96 100644
> --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
> +++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAccess.java
> @@ -14,6 +14,8 @@
>  
>  package org.apache.tapestry5.ioc.services;
>  
> +import java.lang.annotation.Annotation;
> +
>  /**
>   * A wrapper around the JavaBean Introspector that allows more manageable access to JavaBean properties of objects.
>   * <p/>
> @@ -26,7 +28,7 @@ public interface PropertyAccess
>  {
>      /**
>       * Reads the value of a property.
> -     * 
> +     *
>       * @throws UnsupportedOperationException
>       *             if the property is write only
>       * @throws IllegalArgumentException
> @@ -36,7 +38,7 @@ public interface PropertyAccess
>  
>      /**
>       * Updates the value of a property.
> -     * 
> +     *
>       * @throws UnsupportedOperationException
>       *             if the property is read only
>       * @throws IllegalArgumentException
> @@ -45,6 +47,20 @@ public interface PropertyAccess
>      void set(Object instance, String propertyName, Object value);
>  
>      /**
> +     * Returns the annotation of a given property for the specified type if such an annotation is present, else null.
> +     * A convenience over invoking {@link #getAdapter(Object)}.{@link #ClassPropertyAdapter.getPropertyAdapter(String)}.{@link #PropertyAdapter.getAnnotation(Class)}
> +     *
> +     * @param instance     the object to read a value from
> +     * @param propertyName the name of the property to read (case is ignored)
> +     * @param annotationClass the type of annotation to return
> +     * @throws IllegalArgumentException
> +     *             if property does not exist
> +     *
> +     * @since 5.4
> +     */
> +    Annotation getAnnotation(Object instance, String propertyName, Class<? extends Annotation> annotationClass);
> +
> +    /**
>       * Returns the adapter for a particular object instance. A convienience over invoking {@link #getAdapter(Class)}.
>       */
>      ClassPropertyAdapter getAdapter(Object instance);
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b108e06f/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy b/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
> index 93a1459..f0ac187 100644
> --- a/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
> +++ b/tapestry-ioc/src/test/groovy/ioc/specs/PropertyAccessImplSpec.groovy
> @@ -1,21 +1,20 @@
>  package ioc.specs
>  
> +import java.awt.Image
> +import java.beans.*
> +import java.lang.reflect.Method
> +
>  import org.apache.tapestry5.beaneditor.DataType
>  import org.apache.tapestry5.beaneditor.Validate
>  import org.apache.tapestry5.ioc.annotations.Scope
> +import org.apache.tapestry5.ioc.internal.services.*
>  import org.apache.tapestry5.ioc.internal.util.Pair
>  import org.apache.tapestry5.ioc.internal.util.StringLongPair
>  import org.apache.tapestry5.ioc.services.ClassPropertyAdapter
>  import org.apache.tapestry5.ioc.services.PropertyAccess
>  
> -import java.awt.Image
> -import java.lang.reflect.Method
> -
> -import org.apache.tapestry5.ioc.internal.services.*
>  import spock.lang.*
>  
> -import java.beans.*
> -
>  class ExceptionBean {
>  
>    boolean getFailure() {
> @@ -438,6 +437,19 @@ class PropertyAccessImplSpec extends Specification {
>      cpa.propertyNames == ["class", "primitiveProperty"]
>    }
>  
> +  def "getAnnotation from a bean property"() {
> +    AnnotatedBean b = new AnnotatedBean()
> +
> +    when:
> +
> +    def annotation = access.getAnnotation(b, "annotationOnRead", Scope)
> +
> +    then:
> +
> +    annotation.value() == "onread"
> +  }
> +
> +
>    def "getAnnotation() when annotation is not present is null"() {
>  
>      when:
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org