[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [aspectj-users] Binding pointcut arguments to static values
|
- From: Andy Clement <andrew.clement@xxxxxxxxx>
- Date: Thu, 14 May 2009 11:48:02 -0700
- Delivered-to: aspectj-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=p3RU6uE1Wnb08mGAbyiQMpOJpnTfbcmuRrOvoe5+vUI=; b=rGNKshCgC/MTL6Qdr43vsjGLLMwSZY5Ky8D9+rcHYohDbxq/QDfhAN7VJ08+17PqEy VhCY7BhcwtPtT4EsHElNi4Y65hhnI3Sh/KjPuRkaqn3ishMUJhJpqYZGUi24Eja26KSu qFL4qP5Yahgp7L7xRjqH0rh5ejOs2vWjK5oks=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=FLmVkwcWKCngyrk1C2up3XTqcx3SXJYGBfgNaP9HWSbs8xm/RemXWu7mKkceO0uCK/ kwZTtygZTwaJ7PhWTlD69F+4AzrbYvsbK0ZHyyrsMi1viTBgYTdKJ//TY/CI+GNFbm0I 3OOy//XKDXjDHSN//kxAis01ZO5EYDnwK++To=
I don't think you can express that in quite the way you wish, but this
would work in the case you have:
pointcut foo() : call(public void HelloWorld.foo());
pointcut bar() : call(public void HelloWorld.bar());
pointcut interesting() : foo() || bar();
before() : interesting() {
String name =(( CodeSignature)
thisJoinPoint.getSignature()).getMethod().getName();
String typename =(( CodeSignature)
thisJoinPoint.getSignature()).getMethod().getDeclaringClass().getName();
System.out.println("Going to call method " + name+ " on type
"+typename);
}
If the data (FOO or BAR) were in an annotation attached to foo() or
bar() you might be able to get closer to your desired syntax, but that
doesn't seem a good solution.
Andy
2009/5/14 Binil Thomas <binil.thomas.public@xxxxxxxxx>:
>
> Hi all,
>
> I am trying to get help with a pointcut I have to write.
>
> Suppose I have two pointcuts:
> pointcut foo() : call(public void HelloWorld.foo());
> pointcut bar() : call(public void HelloWorld.bar());
>
> Furthermore, I have this advice:
> pointcut interesting(String name) : ...
> before(String name) : interesting(name) {
> System.out.println("Going to call method of type " + name);
> }
>
> I want to write the pointcut as (in pseduo-code):
> pointcut interesting(String name) : foo() && name="FOO" || bar() &&
> name="BAR";
> i.e. when a joinpoint picked out by foo() is encountered I want the name
> argument of interesting() to be "FOO".
>
> How do I go about expressing this?
>
> Thanks,
> Binil
> --
> View this message in context: http://www.nabble.com/Binding-pointcut-arguments-to-static-values-tp23545841p23545841.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>