Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » Restrict weaver to only certain packages
Restrict weaver to only certain packages [message #483727] Wed, 02 September 2009 17:52 Go to next message
No real name is currently offline No real nameFriend
Messages: 19
Registered: July 2009
Junior Member
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 #483748 is a reply to message #483727] Wed, 02 September 2009 19:40 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 77
Registered: July 2009
Member
If you use the "within" pointcut, you will tell the weaver not to look in
any other classes/packages than what is specified in your pointcut. This
should help in your situation.


On 02/09/09 10:52 AM, in article
0716c8e7a4197ff34cbafd1f43e41a18$1@www.eclipse.org, "JS" <joel@mentics.com>
wrote:

> 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 #483765 is a reply to message #483748] Wed, 02 September 2009 20:56 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 19
Registered: July 2009
Junior Member
>> 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?
Andrew Eisenberg wrote:
> If you use the "within" pointcut, you will tell the weaver not to look in
> any other classes/packages than what is specified in your pointcut. This
> should help in your situation.

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 #483797 is a reply to message #483765] Thu, 03 September 2009 05:15 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 77
Registered: July 2009
Member
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 #486766 is a reply to message #483765] Sat, 19 September 2009 03:47 Go to previous messageGo to next message
Andrew Clement is currently offline Andrew ClementFriend
Messages: 162
Registered: July 2009
Senior Member
"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
Re: Restrict weaver to only certain packages [message #600656 is a reply to message #483727] Wed, 02 September 2009 19:40 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 77
Registered: July 2009
Member
If you use the "within" pointcut, you will tell the weaver not to look in
any other classes/packages than what is specified in your pointcut. This
should help in your situation.


On 02/09/09 10:52 AM, in article
0716c8e7a4197ff34cbafd1f43e41a18$1@www.eclipse.org, "JS" <joel@mentics.com>
wrote:

> 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 #600664 is a reply to message #483748] Wed, 02 September 2009 20:56 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 19
Registered: July 2009
Junior Member
>> 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?
Andrew Eisenberg wrote:
> If you use the "within" pointcut, you will tell the weaver not to look in
> any other classes/packages than what is specified in your pointcut. This
> should help in your situation.

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 05:15 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 77
Registered: July 2009
Member
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] Sat, 19 September 2009 03:47 Go to previous message
Andrew Clement is currently offline Andrew ClementFriend
Messages: 162
Registered: July 2009
Senior Member
"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
Previous Topic:Load Time Weaving
Next Topic:Method with Aspect getting called twice
Goto Forum:
  


Current Time: Thu Apr 25 09:00:26 GMT 2024

Powered by FUDForum. Page generated in 0.03939 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top