Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Question about using within/cflowpointcutswiththird-party jars

LTW can be somewhat expensive if you weave into everything (at least there's
additional weaving time and memory use). By scoping your aspects to work
within Hibernate types you'll reduce that (which you already did). You can
also reduce the overhead further by restricting the scope of weaving for
your aspect with an include clause, e.g.,

<aspectj>
   <weaver>
       <include within="org.hibernate..*"/>
   </weaver>
...

If you do this, make sure you have inclusions to support any other aspects
that you are weaving in. I am planning to write a blog entry about this
topic: how to minimize overhead when deploying aspects for load-time
weaving. The other way to keep overhead down is to deploy the aspects with
the smallest scope possible (e.g., if you deploy hibernate.jar to a single
app, you can limit the weaving to that one app instead of weaving into all
apps).

Sorry there was a typo in my last pointcut: it should say execution(new(..))
NOT execution(* new(..)). This pointcut refers to execution of constructors,
which have a different form than methods (notably no return type).

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Neil Redding
Sent: Friday, August 18, 2006 11:39 AM
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] Question about using
within/cflowpointcutswiththird-party jars


Thanks Ron - a couple followup questions below:

> To weave within the hibernate classes, you would need 
> Hibernate to be on your inpath (i.e., to weave the Hibernate 
> jars). One way you might do this without building a modified 
> version of Hibernate would be load-time weaving.

I've been assuming LTW is expensive - is it not? I think I'll give it a
go, since I don't want to modify Hibernate unless I have to. 

> Another option would be to use cflow of calls into Hibernate. 
> The calls from your code into Hibernate can be woven without 
> weaving into Hibernate. E.g.,
> 
> 	pointcut callHibernate(): 
> 		call(* org.hibernate..*(..)) ||
> call(org.hibernate..*.new(..));
> 	pointcut inHibernate(): cflow(callHibernate());
> 
> 	pointcut setterNotCalledByHibernate():
> 		!calledByHibernate() && execution(* *.set*(..));

Right; the issue is that I need to exclude Hibernate joinpoints
regardless of where they're called from - it's not always from "my
code". 

> Also, note that your original pointcut is rather expensive 
> (it would weave into *all join points* in Hibernate such as 
> field get/set, handler etc). If you were going to weave into 
> Hibernate you'd want something like:
> 
> 	pointcut hibernate(): 
> 		(execution(* *(..)) || execution(* new(..))) &&
> 		within(org.hibernate..*);

Thanks, I was a bit method-invocation-myopic there for a moment - didn't
consider the other joinpoint types. :-)

Dumb question (?): Why "execution(* new(..))" in the pointcut
immediately above - isn't this covered by "execution(* *(..))"?

Cheers,
Neil
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top