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/cflow pointcuts withthird-party jars

Hi Neil,

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.

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*(..));


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..*);

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Neil Redding
Sent: Friday, August 18, 2006 10:54 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] Question about using within/cflow pointcuts
withthird-party jars


Hi,

I'm new to AspectJ, and have run into the following problem:

I want to create a pointcut that excludes all joinpoints within classes
contained by a package root (in this case org.hibernate), as well as
within code called by those classes. So, I've created the following set
of pointcuts, where the first two support the third:

	pointcut hibernate(): within(org.hibernate..*);
	pointcut calledByHibernate(): cflow(hibernate());

	pointcut setterNotCalledByHibernate():
		!calledByHibernate() && execution(* *.set*(..));

The above works as expected when the TypePattern supplied to within()
matches my own classes, but not when it matches classes in this
third-party library. Given what I know about how AspectJ works, I don't
believe any weaving of the org.hibernate classes needs to happen - in
any case, I confirmed that the hibernate jars are in the classpath and
inpath at iajc (compile) time, but no luck. 

Anyone have experience with this type of situation? Is there some reason
this won't work? 

Thanks,
Neil

------------
Neil Redding
Director
Lab49, Inc.

Phone: 646.291.2868
Email: nredding@xxxxxxxxx
Web  : www.lab49.com
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top