Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » aspectj : how to compile only required files using (how to compile only required files )
aspectj : how to compile only required files using [message #1074024] Fri, 26 July 2013 00:23 Go to next message
Milan Shrestha is currently offline Milan ShresthaFriend
Messages: 5
Registered: July 2013
Junior Member
Hi,
I am new to AspectJ. I am working on a legacy web project which has hundreds of file. I have written an aspect to capture the query call. So, I require to weave only DAO class. Is there any way I can instruct the aspectj compiler to only weave the required files.
For example, i want have the dao weave under different dao pakes as below:
com.xyx.p1.dao
com.xyz.p2.dao
com.zzz.p3.dao

So is there any way that i can write the expression so that asjpectj compiler would weave only the files within the package ending with *.dao

Re: aspectj : how to compile only required files using [message #1074059 is a reply to message #1074024] Fri, 26 July 2013 02:34 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
You should use the within pointcut for this:

pointcut targetPackages() : within(com.xyx.p1.dao..*.*) || 
        within(com.xyx.p2.dao..*.*) || <etc...>;


And then use this pointcut with your other advice to ensure that the compiler scopes the target of other advice properly. Kind of like this:

before() : targetPackages() && <someotherpointcuts> {
  // do sumpin
}
Re: aspectj : how to compile only required files using [message #1074309 is a reply to message #1074059] Fri, 26 July 2013 13:26 Go to previous messageGo to next message
Milan Shrestha is currently offline Milan ShresthaFriend
Messages: 5
Registered: July 2013
Junior Member
Thanks Andrew for the reply. But I want to do something as below:
Match the package Starting with say "com.xyz" and followed by anything and then ending with "dao". Can I write expression for such case in the pointcut.
Re: aspectj : how to compile only required files using [message #1074361 is a reply to message #1074309] Fri, 26 July 2013 15:12 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
True, the pointcut could be simplified like this

ointcut targetPackages() : within(com..*.dao..*.*);
Re: aspectj : how to compile only required files using [message #1074455 is a reply to message #1074361] Fri, 26 July 2013 20:57 Go to previous messageGo to next message
Milan Shrestha is currently offline Milan ShresthaFriend
Messages: 5
Registered: July 2013
Junior Member
Hi,
I tried with that and it works. But even with this AspectJ compiler tries to weave all the classes present in the src directory. Is there any way I can specify compiler to weave only the required packages and skip trying to weave others.
Re: aspectj : how to compile only required files using [message #1074457 is a reply to message #1074455] Fri, 26 July 2013 21:04 Go to previous message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
What is the problem with trying to weave all classes? If aspects don't apply to them, they will not be changed. Is it taking too long?
Previous Topic:Demand base logging on production
Next Topic:Plug-in to send data to excel?
Goto Forum:
  


Current Time: Thu Apr 25 15:37:46 GMT 2024

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

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

Back to the top