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("Ravi" ,
"Wonderful Technology");
}
}
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,
Ravi