Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Annogen is a tool which helps you work with JSR175 annotations, a new feature in JDK 1.5. JSR175 is a much-needed improvement to java. However, a few challenges may lie in store for developers of frameworks which need to process JSR175 annotations (hereafter, simply called 'frameworks'). Annogen aims to provide an elegant solution for the following problems:

...

Annogen uses your JSR175 annotation types to code-generate special java beans called AnnoBeans. AnnoBeans look exactly like your JSR175 annotations; in fact, they can actually directly implement your JSR175 annotation interfaces. AnnoBeans carry exactly the same data that appears on your JSR175 annotations. You write your framework code to use AnnoBeans when it needs to understand what annotations are on a java class.

...

Once you have your AnnoBeans, you can create an AnnoOverrider which adds, modifies, or remove AnnoBeans associated with a given java class. How and when this is done depends upon your needs. For example, say you had a 'cache size' deployment annotation which your users might occasionally want to override at deployment time. You could implement an AnnoOverrider which retrieves the user's override preferences (say, from an XML file) and then modifies the AnnoBeans accordingly.

...

In the final step, your framework code reads the AnnoBeans and uses them to do something interesting with them, such as deploy a user application. You retrieve instance of the AnnoBeans through the AnnoViewer interface. You simply ask the AnnoViewer to give you the AnnoBean for a given annotation type on a given class. The AnnoBean you get back may or may not have been modified by your AnnoOverrider; the nice thing is here that you don't have to care. Annogen allows you to maintain a clean separation between the code which gathers and manipulates annotation values and the code which acts on those values.

...

In the Generate phase, you have an option called ' implementAnnotationTypes. ' If true, the generated AnnoBeans will directly implement your JSR175 types. The advantage to this approach is that your framework code in the View phase does not ever have to know about AnnoBeans - you just use JSR175 annotation types just as you would with regular reflection. They will be implemented by AnnoBeans, but your code doesn't have to know that. This approach is somewhat simpler, cleaner and may make it easier to integrate with other code which use the same JSR175 types.

...