I recently started using AspectJ LTW. I use Eclipse with the AJDT. I basically use the "outjar" option to create my "AspectJ Library (.jar file)" with the compiled .aj files.
Next step is to use this jar file within a "normal" Eclipse Java project which just works perfect if I have the aspectjweaver.jar library on the javaagent path:
-javaagent:lib/aspectjweaver.jar
My next goal is to use a second aop.xml file within this "normal" java project. Even this works good if the META-INF/aop.xml
file is located on the class loader search path. Now I discovered this:
http://www.eclipse.org/aspectj/doc/released/README-1612.html
(scroll down to "More flexible pointcut/code wiring in aop.xml")
The following XML specification works without problems:
<aspectj>
<aspects>
<concrete-aspect name="MyAspect">
<before pointcut="set(* *.myStringField) AND args(message)"
invokeClass="my.package.SomeRegularJavaClass" invokeMethod="someMethod(JoinPoint tjp, java.lang.String message)" />
</concrete-aspect>
</aspects>
</aspectj>
But what I'm actually interested in, is to "pass" my own argument/variable/message to the method someMethod
. Something like:
<aspectj>
<aspects>
<concrete-aspect name="MyAspect">
<before pointcut="set(* *.myStringField) AND args(message)"
invokeClass="my.package.SomeRegularJavaClass" invokeMethod="someMethod(JoinPoint tjp, java.lang.String message, java.lang.String "customMessage")" />
</concrete-aspect>
</aspects>
</aspectj>
So is there a way to pass a string (for example) to the method someMethod
? Or are there any other options available?