Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] generic access to method arguments

Dan,
 
Although you can not put it into your advice directly, within the around body you could do something like:
 
Object around(MyAnnotation myAnnotation) : withMyAnnotation(myAnnotation) {

// This will reflectively get you a list of all the arguments passed in
Object[] args = thisJoinPoint.getArgs();
// Do what you need to do with the arguments
}
 
See the API documents for more details.
 
http://www.eclipse.org/aspectj/doc/released/runtime-api/index.html <http://www.eclipse.org/aspectj/doc/released/runtime-api/index.html> 
 
Ron

________________________________

From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Abramovich, Dan
Sent: Wed 9/6/2006 4:22 PM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] generic access to method arguments 





Hi,

I have a pointcut that is picking out all methods that have a particular annotation. This works fine.

         public pointcut withMyAnnotation(MyAnnotation myAnnotation) :
                execution(@MyAnnotation  * *(..)) && @annotation(myAnnotation);

            Object around(MyAnnotation myAnnotation) : withMyAnnotation(myAnnotation) {


What I don't know how to do is have access to the method arguments without restricting what the arguments are. I'd like to have a list of all the arguments (maybe empty) that were actually passed in to the advised method without knowing/limiting which methods are advised. Something like: (I know it doesn't work, but I think it expresses the sentiment).

         public pointcut withMyAnnotation(MyAnnotation myAnnotation, Object[] arguments) :
                execution(@MyAnnotation  * *(..)) && @annotation(myAnnotation) && args(arguments);

            Object around(MyAnnotation myAnnotation, Object[] arguments) : withMyAnnotation(myAnnotation, arguments) {


Any help? Is this possible?

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


<<winmail.dat>>


Back to the top