Yes, you can "declare annotation". Here's the relevant manual page with
the particulars. The examples are even very close to your example!
http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-declare.html
dean
Jeppe Cramon wrote:
Hi
I'm pretty this is not possible, but I wanted to hear it from the
really experienced guys.
Is it possible using intertype definitions to enhance/decorate
classes/fields/methods with annotations...?
Exmaple: I have a web application where the infrastructure uses a
@Secure annotation to define access control to Controllers.
Since we have a lot of Controllers neatly placed in meaningfull
packages, I wanted to define an Aspect where I could say all
Controllers (there's an interface you can use to spot them out), that
are in the com.mycompany.web.admin should have
@Secure(roles="ROLE_ADMIN") added to their class declaration and all in
package com.x.y should have @Secure(roles="ROLE_USER") finally the rest
should be left alone.
The alternative way would be to write an Aspect that worked with the
security infrastructure and used the packages to define the required
roles, but just out of curiosity I would like to know if the other
solution is at all possible (for cases where you have to play by the
rules
and apply the annotations as the framework expects) ?
/Jeppe
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
|