Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Use of aop.xml

Hi,

If your aspects are 'ready to go' (i.e. non-abstract), you can just
define a trivial aop.xml that lists them:

<aspectj>
 <aspects>
  <aspect name="com.foo.MyAspect"/>
 </aspects>
</aspectj>

In face you can create that file automatically if you compile with
-outxml specified, it will create a suitable aop.xml listing all the
aspects you are compiling.

If you want to be more flexible in the wiring, it is possible to
define the pointcuts in aop.xml, and wire them to Java methods that
get treated like advice.  For example:

<aspectj>
  <aspects>
<concrete-aspect name="MyAspect">
  <before pointcut="execution(* Hello.say2(..)) AND args(message)"
   invokeClass="SomeRegularJavaClass"
   invokeMethod="someMethod(JoinPoint tjp, java.lang.String message)"/>
  <after pointcut="execution(* Hello.say2(..)) AND args(message)"
   invokeClass="SomeRegularJavaClass"
   invokeMethod="someOtherMethod(JoinPoint tjp, java.lang.String message)"/>
</concrete-aspect>
  </aspects>
</aspectj>

This kind of usage is discussed in detail in here:
http://www.eclipse.org/aspectj/doc/released/README-1612.html

cheers,
Andy

On 23 May 2012 03:45, Bhavuk soni <bhavuksoni@xxxxxxxxx> wrote:
> Hi,
>
> I am working on a similar solution like yours, where i have to weave an
> aspect during execution of a method.
> I am working on a solution where mock dependencies for junits are done with
> AspectJ(without spring)
> and during execution of a test method those dependencies should be weaved so
> that the real calls to the classes/ DB can be replaced by mock classes.
>
> I am done with my aspect code, but i am unable to weave this aspect to the
> code, point is that i have to do this using aop.xml.
>
> The project structure is like that
>
> 1.Aspects- Here all the aspects are written, they are not ABSTRACT, as the
> requirement is like that
>
> 2.Tests - Here all the tests are written
>
> The test project .classpath has refrences to aspects and the code base
> project.
>
> If you can help with a small snippet , it would be great.
>
> Thanks,
> Bhavuk
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top