Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to access annotation values

#: bednarz-hannover@xxxxxx changed the world a bit at a time by saying on  1/1/2006 6:13 PM :#
Hallo,

I am new to aspectJ 1.5 & annotations and world like to access an annotation value at runtime. My Java source is :

@loglevel{id=1}
public void helloMethod(){
 ....
}


You should check the @this, @target and @args for accessing the annotation. Than getting the value is just normal annotation usage. In the case your pointcuts are not defined in terms of annotation, than you can use the reflection API to get to the annotations.

@loglevel has a runtime retention policy and I would like to access the id within an aspect. Can somebody provide me a source
code example for this? The aspect should simply output the loglevel id to stdout.
Would it be also possible to set loglevels retention policy to SOURCE or CLASS?

Considering that you need those values at runtime, and according to the specification of retention policies, I would say that no, you are required to use the RUNTIME retention.

hth,

./alex
--
.w( the_mindstorm )p.

ps: this being the 1st message from me on the AJ ml this year, I would like to wish everybody here a Happy New Year!


Thank you very much,

Andreas Bednarz

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users




!DSPAM:43b7ffe7906101522813722!





Back to the top