| [aspectj-users] RE: Regarding weaving Java Programs |
|
HI all, I got the answer myself when I tried out
the same example by removing statics. Hence whether
static or not, we need to write in the same way!! AspectJ does not show a
distinction on whether static or not. It just looks for that method. Hats off
to aspectj!! Regards, -----Original Message----- Hi all, I have just started using AspectJ
and was going through the initial newbie examples: I have a class called MessageCommunicator
as follows: public class MessageCommunicator { public
static void deliver(String message) { System.out.println(message); } public
static void deliver(String person, String message) { System.out.println(person+"!,
"+ message); } } Now I have a test program: public class Test { public
static void main(String[] args) { MessageCommunicator.deliver("WELCOME
TO AOP"); MessageCommunicator.deliver(" } } Now I am weaving MessageCommunicator
with my MannersAspect as: public aspect MannersAspect { pointcut
deliverMessage() :
call(* MessageCommunicator.deliver(..)); before()
: deliverMessage() { System.out.print("Inserting
with AOP ----> "); } } Everything is working fine when I
compile with ajc and output is as expected. My question is, had the method
“deliver” in MessageCommunicator been NOT STATIC, how could I
achieve the same result, please help. Thanks Best regards, |