views:

124

answers:

1

I thought this should be obvious but I can't find it.

Now that fields can have annotations, I thought this should be reflected in the JavaBean spec, but I can't find it.

What I mean:

JavaBean is a specification that allows you to treat objects in an uniform way by discovering their properties, and then reading and writing them.

As POJOs properties can now be annotated (as in Hibernate annotations for example), I expected annotations to be accessible using the JavaBean specification - in order to discover more metadata than just the type of the property.

Or must I resort to the trick of getting the getter method and find the metadata using plain reflection API?

+3  A: 

You can access the getter and setter methods through the PropertyDescriptor class in the Java Beans API. From getReadMethod() and getWriteMethod() the annotations on those methods are available. In the end it is a little bit of a mix between the Java Beans API and the Reflection API.

John Meagher
that's what I found too. But then it means that dynamic beans cannot have annotations.
flybywire