[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re:[OT] [aspectj-users] Exposing state held in method annotations
|
I do this with AspectWerkz and the Java 5 API.
public void before( final StaticJoinPoint sjp ) {
try{
Class<PaperSheet> clazz = PaperSheet.class;
Method method = clazz.getMethod( sjp.getSignature
().getName(),
Graphics2D.class);
if( method.isAnnotationPresent( StatusShow.class )){
BluePrint.getStatus(). setText( method.getAnnotation
( StatusShow.class ).
message() );
}
Mohan
--- Ramnivas Laddad <ramnivas@xxxxxxxxxxxxxxx> wrote:
> Not tried, but the following should work:
>
> pointcut constantArgumentMethods(ConstantArguments
> annot)
> : call(@ConstantArguments * *.*(..))
> && @annotation(annot);
>
> Then inside advice, you may access the value
> property of the "annot" context:
>
> before(ConstantArguments annot) :
> constantArgumentMethods(annot) {
> System.out.println("Value is : " + annot.value());
> }
>
>
>
> Eric Bodden wrote:
>
> >
> >-----BEGIN PGP SIGNED MESSAGE-----
> >Hash: SHA1
> >
> >Hi all.
> >
> >Today I came across an annotation problem which I
> don't know how to
> >solve:
> >
> >I have a method annotated like this:
> >
> >@ConstantArguments({1}) public int foo(Wrapper a) {
> >..
> >}
> >
> >Now I am matching on calls to it like this:
> >
> >pointcut constantArgumentMethods() :
> call(@ConstantArguments *
> >*.*(..));
> >
> >But how can I expose the "value" state "{1}" that I
> passed in above?
> >The following does *not* work:
> >
> >pointcut constantArgumentMethods(int[] value) :
> >call(@ConstantArguments(value) * *.*(..));
> >
> >I guess @target will not help, since it returns
> annotations of the
> >target *type*, not *method*, or am I wrong?
> >
> >Cheers,
> >Eric
> >
> >P.S. Definition of the ynnotation type:
> >
> >public @interface ConstantArguments {
> >
> > int[] value() default {};
> >
> >}
> >
> >- --
> >Eric Bodden
> >Chair I2 for Programming Languages and Program
> Analysis
> >RWTH Aachen University
> >
> >-----BEGIN PGP SIGNATURE-----
> >Version: PGP 8.0.3
> >
>
>iQA/AwUBQfkyNMwiFCm7RlWCEQJUvwCdF6oPnnOj0IOrwgK3oqBFsEG+f+EAn1lW
> >n+BcQ4OfJRo3KlGuMlt7q+3Y
> >=IJhX
> >-----END PGP SIGNATURE-----
> >
> >
> >_______________________________________________
> >aspectj-users mailing list
> >aspectj-users@xxxxxxxxxxx
>
>http://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
> >
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
>
http://dev.eclipse.org/mailman/listinfo/aspectj-users
>
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com