Groovy ideas coming from all directions Go Groovy! JSR 241 approved by all
Mar 27

declare annotation: AOP + Metadata marriage made in heaven

AOP, Tech Add comments

I am really excited about the marriage of AOP with the new JSR 175 annotations. As I have mentioned before, I am a little worried that they will be taken too far, and we will run into @ hell.

Having annotations in classes are cross-cutting concerns themselves, and so we have a chance to deal with them in some cases via AOP.

This will naturally happen anyway. Tools that have up until now said “A method that is set*() is a setter” will probably start to use:

“A method that is set*() AND doesn’t have a @nowrite annotation
OR
A method that has a @write attribute

This is just due to some legacy rules that we have lying around.

Some scenarios will be ripe for us to just slap on some annotations manually. These will be for the types of metadata that don’t tend to be slapped on a huge amount of methods all over the shop.

The other side of the house has cross-cutting concerns that can applied to a heap of methods. The exteme would be something like having to put @log on every method that you wanted to log!

For this scenario we can mix AOP with annotations. AOP will be responsible for weaving annotations into our code.

Right now we use AOP to put marker interfaces on certain classes… e.g:

declare parents: org.atrack.ui..controller..Edit* && Action+ implements StartsApplicationTransactions;

With metadata we will be able to do something like:

declare annotation: org.atrack.ui..controller..Edit* && Action+ annotates @Transaction(type=”Requres”)

One Response to “declare annotation: AOP + Metadata marriage made in heaven”

  1. replica handbags Says:

    thanks for sharing

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: What is the number before 3? (just put in the digit)