[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] [Newbie] Pick out a call / execution only in the hierarchy leafs
|
Hi again,
Thanks. I have already tried it, but this pointcut definition fails in
capturing what I need (Am I doing something wrong?):
/*****************************/
public pointcut getOptionsPointcut(OptionHandler targetObject) :
call(public String[] OptionHandler.getOptions())
&& target(targetObject)
&& target(Randomizable+)
;
/*****************************/
The only partial solution I have found is using a combination of
execution and cflowbelow:
/*****************************/
public pointcut getOptionsPointcut(OptionHandler targetObject) :
execution(public String[] OptionHandler.getOptions())
&& within(targetObject);
String[] around(OptionHandler targetObject) :
getOptionsPointcut(targetObject) &&
!cflowbelow(getOptionsPointcut(OptionHandler)){
showJPInfo("Around GET", thisJoinPoint);
return WekaUtils.appendOptions(getOption(targetObject),
proceed(targetObject));
}
/*****************************/
But that don't works, because although it solves the chained advised
problem described in the first post, it adds the following problem when
I have aggregated Randomizable & OptionHandler objects and I want to
retrive its options.:
/*****************************/
class A implements OptionHandler, Randomizable{
private A anotherA;
...
String[] getOptions(){
super.getOptions()
...
anotherA.getOptions(); //<==This call is not adviced and I want to!!.
}
}
/*****************************/
This is giving me a serious headache.
Best regards
Santi
Bruno Feurer wrote:
sorry, use "target" instead of "withincode"! we don't have a method
pattern here...
-----Original Message-----
From: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Bruno Feurer
Sent: Thursday, July 22, 2004 11:09
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] [Newbie] Pick out a call /
execution only in the hierarchy leafs
Hi Petecan,
try ...
public pointcut getOptionsPointcut() :
call(public String[] OptionHandler.getOptions())
&& withincode(Randomizable+)
;
As stated in the Programming Guide
(http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspec
tj-home/do
c/progguide/language-joinPoints.html#d0e1288) calls should
not capture super calls.
Bruno
-----Original Message-----
From: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Petecan
Sent: Thursday, July 22, 2004 11:30
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] [Newbie] Pick out a call / execution
only in the hierarchy leafs
Hi all,
I have the following two interfaces:
/*****************************/
public Interface OptionHandler{
...
String[] getOptions();
}
public Interface Randomizable{
...
}
/*****************************/
And I want to advice all calls to the
OptionHandler.getOptions method
within Randomizable & OptionHandler implementing classes. I use the
following pointcut and advice:
/*****************************/
public pointcut getOptionsPointcut() :
execution(public String[] OptionHandler.getOptions())
&& within(Randomizable+)
;
String[] around() : getOptionsPointcut(){
return Utils.appendOptions(getOption(), proceed());
}
/*****************************/
Now, given the following hierarchy:
/*****************************/
class A implements OptionHandler, Randomizable{
String[] getOptions(){
...
}
}
class B extends A{
String[] getOptions(){
super.getOptions();
...
}
}
/*****************************/
The poincut captures both the getOptions() execution in A and
B, and I
want it to capture only the execution in the "leaf" class of the
hierarchy (class B, in this case). In other words, the
A.getOptions must
be picked out only if it is directly invoked but not if it
is called
from a redefining method via the super reference. How can I
do that?.
Is there a better or more elegant way of defining the pointcut to
capture these joint points?.
Best Regards
Santi.
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspect> j-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users