java - Aspectj ltw aop.xml -
how can utilize aop.xml define pointcuts in plain java code? sample code in trying define pointcut in aop.xml-> 1)this java class
package testaop; public class helloworld { public static void main(string[] args) { helloworld app = new helloworld(); app.say("hello world!"); app.add(11, 22); } private int add(int i, int j) { homecoming + j; } public void say(string message) { system.out.println(message); } }
2)my aspect class
package testaop; abstract aspect myaspect { protected abstract pointcut publicmethod(); object around() : publicmethod() { system.out.println(thisjoinpointstaticpart); homecoming proceed(); } }
3)have created meta-inf folder in main project directory folder i.e. in bundle testaop->meta-inf consists of aop.xml
<?xml version="1.0" encoding="utf-8"?> <aspectj> <aspects> <concrete-aspect name="testaop.concreteaspect" extends="testaop.myaspect" > <pointcut name="publicmethod" expression="execution(public * testaop.helloworld.*(..))" /> </concrete-aspect> </aspects> <weaver options="-verbose"> <weaver options="-showweaveinfo"/> </weaver> </aspectj>
have added metainf folder having aop.xml
java build path , in run configurations aspectj load-time weaving have set next properties:
what did miss? why not recognizing pointcuts?
was able solve problem, aop.xml missing in bin folder , there version mismatch aspectjrt , aspect-weaver
java eclipse
No comments:
Post a Comment