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?

1 Answer 1

2

I would check the Pluggable Annotation Processing framework.

See

Sign up to request clarification or add additional context in comments.

2 Comments

APT has been superceeded by the annotation processor API in java 6.
@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.