Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] A question about pointcut

Does this help?:

aspect A {

   before(): call(* *(..)) && !within(A) {
		Object[] lArgs;
		lArgs = thisJoinPoint.getArgs();

		for(int lCounter = 0;
			lCounter<lArgs.length;
			lCounter++){

			if(lArgs[lCounter] instanceof java.lang.String){
				System.out.println(lArgs[lCounter]);
		}	}
   }
}

this matches every method signature, except the calls within the aspect. if you don't do this you will have an infinite loop when you call println, the pointcut is matched, and will call println, and on , and on.

Now you can check the args for their type.. I can't seem to find a way to only specify matching during the pointcut of one or more paramaters, and that have a specific type... Have you found a different way yet?

- Nathan








From: Charles Zhang <czhang@xxxxxxxxxxxxxxxx>
Reply-To: aspectj-users@xxxxxxxxxxx
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] A question about pointcut
Date: Fri, 7 Mar 2003 00:05:06 -0500 (EST)

Consider the scenario that I want to define a generic advice to check the
string encoding of all string arguments of all methods. How would I write
my code? Can anyone shed some light? Thanks.

Charles Zhang 		(http://www.eecg.utoronto.ca/~czhang)
Graduate Student, Middleware Systems Research Group,
Dept. of Elec. & Comp. Engineering,  University of Toronto
" Yawn!!"

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


_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail



Back to the top