Restrict weaver to only certain packages [message #483727] |
Wed, 02 September 2009 13:52  |
Eclipse User |
|
|
|
I'm using AJDT and maven plugin in eclipse.
Is there a way to configure aspectj to only weave a certain package? We
have a large project that cannot be separated out at this time. The
weaving takes a long time. All the classes that need to be weaved are in a
single package. However, watching the progress, it appears to go through
every class to weave it. How can I limit the weaving to speed up the build?
Thanks!
|
|
|
|
|
Re: Restrict weaver to only certain packages [message #483797 is a reply to message #483765] |
Thu, 03 September 2009 01:15   |
Eclipse User |
|
|
|
So, what you have seems to be a fairly complex set statement. That *might*
be confusing AspectJ and causing it to weave more than it needs to. And if
so, then I'd suggest that you raise a bug report for that, because within()
should be restricting the weaver.
Before you do that, try simplifying the pointcut. Just use set(* *
MyType.*) and see if that changes what types are getting woven. If only the
proper class is woven, then we can be pretty sure it has something to do
with the way the pointcut is structured.
I'll be off for a couple of weeks after this, so I won't be able to reply.
I'd recommend that you post to the AspectJ users mailing list if you have
any further questions.
http://www.eclipse.org/aspectj/userlists.php
> Thank you for the response. I tried that and now have the following as my
> pointcut:
>
> pointcut fieldMutator(Object o, Object v) : set(!transient !static
> !final (byte || short || int || long || float || double || boolean || char
> || java.lang.String) (MyType).*) && this(o) && args(v) && within(MyType);
>
> I then have advice as follows:
>
> void around(Object o, Object v) : fieldMutator(o, v) {...}
>
>
> However, as I watch the progress view, it still shows "woven ..." on
> various types as it is building.
>
> So... that doesn't seem to be working. Is there something else I need to
> do?
>
>
|
|
|
|
|
|
Re: Restrict weaver to only certain packages [message #600670 is a reply to message #483765] |
Thu, 03 September 2009 01:15   |
Eclipse User |
|
|
|
So, what you have seems to be a fairly complex set statement. That *might*
be confusing AspectJ and causing it to weave more than it needs to. And if
so, then I'd suggest that you raise a bug report for that, because within()
should be restricting the weaver.
Before you do that, try simplifying the pointcut. Just use set(* *
MyType.*) and see if that changes what types are getting woven. If only the
proper class is woven, then we can be pretty sure it has something to do
with the way the pointcut is structured.
I'll be off for a couple of weeks after this, so I won't be able to reply.
I'd recommend that you post to the AspectJ users mailing list if you have
any further questions.
http://www.eclipse.org/aspectj/userlists.php
> Thank you for the response. I tried that and now have the following as my
> pointcut:
>
> pointcut fieldMutator(Object o, Object v) : set(!transient !static
> !final (byte || short || int || long || float || double || boolean || char
> || java.lang.String) (MyType).*) && this(o) && args(v) && within(MyType);
>
> I then have advice as follows:
>
> void around(Object o, Object v) : fieldMutator(o, v) {...}
>
>
> However, as I watch the progress view, it still shows "woven ..." on
> various types as it is building.
>
> So... that doesn't seem to be working. Is there something else I need to
> do?
>
>
|
|
|
Re: Restrict weaver to only certain packages [message #600693 is a reply to message #483765] |
Fri, 18 September 2009 23:47  |
Eclipse User |
|
|
|
"woven..." doesn't mean it was actually modified, it merely means it went through the weaver. A within() pointcut will ensure it is dismissed early on if it doesn't match the type pattern specified. All the components of your pointcut are sorted (the pointcut is rewritten) when processed by AspectJ to ensure the cheapest tests that can eliminate types are executed with first.
So, when you say it "doesn't appear to be working" - do you mean it still takes longer than you'd like?
Once the project is built, incremental builds should be instantaneous as long as you are not modifying the aspect. Is this the case? If those builds are not instant then there is a bug.
Open the AJDT event trace view to get more specific details about each build, including time spent in each phase.
Andy
|
|
|
Powered by
FUDForum. Page generated in 0.13507 seconds