views:

34

answers:

1

I am trying to create a library which depends heavily on annotating class properties. The properties should be able to be annotated via getters or on the actual underlying fields (ala JPA etc.)

Is there some standard for this? Tons of libraries do this (e.g. Hibernate). Do they all just roll their own implementation and conventions? Is there a good library which makes this easy? It seems as though there should be some standard for this.

I could easily just reflect through all of a class's methods and fields and check for the presence of an annotation, but there are lots of subtleties (e.g. "get" or "is" prefixes on getter methods). Anyone have any ideas?

+2  A: 

I would check the Pluggable Annotation Processing framework.

See

Pascal Thivent
APT has been superceeded by the annotation processor API in java 6.
Robert Munteanu
@Robert Munteanu, Link?
Jordan S. Jones
@Jordan Indeed, by including JSR 269 support, `javac` now acts analogously to the `apt` command in JDK 5 (JPA 2.0 is using this to generate the canonical metamodel for example) and the provided link now points to the Java 6 version of the APIs. But that's still annotation processing.
Pascal Thivent
@Robert, Good deal, thanks for the update. :)
Jordan S. Jones