I have written two simple codes..one java code to print a Hello World statement and other a aspect code to be weaven into it..
My hello world code is
// HelloWorld.java
public class HelloWorld {
public static void main(String args[]){
say("Hello world");
}
public static void say(String message) {
S开发者_如何学JAVAystem.out.println(message);
}
public static void sayToPerson(String message, String name) {
System.out.println(name + ", " + message);
}
}
and my aspect code is..
public aspect MannersAspect {
pointcut callSayMessage() : call(public static void HelloWorld.say*(..));
before() : callSayMessage() {
System.out.println("Good day!");
}
after() : callSayMessage() {
System.out.println("Thank you!");
}
}
I have saved both into HelloWorld.java and MannersAspect.java and have compiled it using ajc *.java
It has given me two classes HelloWorld.class and MannersAspect.class
Now the major question for me is "HOW TO RUN IT"?
Please help me with this.I am stuck.Thanks in advance..
I figured It out..:P:P
I saw it on a website and it was like..
ajc -argfile <fullpath>\myList.lst
where myList.lst contained both files like this
HelloWorld.java
MannersAspect.java
And then doing java HelloWorld
Cheers
精彩评论