Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Annotations weaving into a jar


Hi,

I presume you are passing the code for the 'JCO.Table' code into the compiler so that it can be woven?  Try compiling with '-showWeaveInfo' to check if the declare @method is adding the annotation to what you expect.

What is the retention policy for the AccessControl annotation?

Here is my example that works:

import java.lang.annotation.*;

@interface Blue {}

public class A {
  public void m() {}

  public static void main(String[]argv) {
    new A().m();
  }
}

aspect Y {
  declare @method: void A.m(..) : @Blue;

  before(): within(A) && call(@Blue * *(..)) {
    System.err.println(thisJoinPoint);
  }
}

C:\aspectj1.5.0-dev>ajc -1.5 A.aj -showWeaveInfo
'public void A.m()' (A.aj:6) is annotated with @Blue method annotation from 'Y' (A.aj:14)
Type 'A' (A.aj:9) advised by before advice from 'Y' (A.aj:16)

C:\aspectj1.5.0-dev>java A
call(void A.m())

My example isn't binary weaving of course (with inpath) but it should work the same...

Andy.



"Sesques, Laurent" <laurent.sesques@xxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx

15/06/2005 15:43

Please respond to
aspectj-users@xxxxxxxxxxx

To
<aspectj-users@xxxxxxxxxxx>
cc
Subject
[aspectj-users] Annotations weaving into a jar





Hello,

I am encountering problems trying to use annotations with AspectJ.
I have a jar library which provides me with all the tools I need to
connect to a back-end.
For access control purposes, I want to protect the calls performed with
this tool according to information concerning the current user.

I have this annotating aspect:

public aspect AnnotateAccessControl {
                declare @method : JCO.Table JCO.ParameterList.getTable(..):
@AccessControl; //database request
}

And this advice testing the catching of the methods annotated like
above:

before(): within(CallingClass) && call( @AccessControl *
*.getTable(..)){
                System.out.println("This should be controlled!");
}

I use AspectJ Compiler DEVELOPMENT built on Friday Jun 3, 2005 at
12:16:27 GMT

I use the -injars option for the compilation.

Here is the output of the compilation:

C:\Project\src\foo\AccessControl.aj:15 [warning] advice defined in
foo.AccessControl has not been applied [Xlint:adviceDidNotMatch]

Then at runtime, as expected due to the compilator's message, nothing is
caught. (running on Sun's JVM 1.5.0_02)

Is there something I did wrong ?

Thanks in advance,
Laurent
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top