Wednesday, March 23, 2005

Annotation-based Persistence

The getter/setter idiom has always been problematic; it allows too-broad access to the implementation of your classes, degrading maintainability as a consequence. The J2SE 5 annotation (or metadata) feature provides an alternative. Rather than using introspection to find get/set methods, you can "tag" an object with an annotation and then access that annotation at either compilation or at runtime. This article both describes the annotation mechanism and presents the output side of an XML-based persistence mechanism that uses annotations to tag persistent classes and fields.
rating comment: A very interesting article, though the idea of a metadata-based persistence framework is not new, XDoclet pursuits the same approach. This article is more of an tutorial, giving you an overview of how to use Annotations in a useful manner.

No comments: