[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Aspect association question
|
In the case of a call pointcut the "this" represents the caller side: meaning the object instance
from where the constructor is invoked.
Following, on the same call pointcut, the "target" should represent the callee side (the
AccountViewer); _but_ at the moment of constructor pointcut there is no target instance (the target
object is just to be created, so it doesn't really exist).
To conclude: in a constructor call "target" is always not bound, meaning you will never be able to
match and/or expose the new-to-be-created object instance through target.
hth,
./alex
--
.w( the_mindstorm )p.
#: Zepeda, Herbey changed the world a bit at a time by saying on 11/25/2005 7:39 AM :#
Hi,
I am trying to associate one aspect per object instantiated the
following way following the guidelines of [1]. However I am not
obtaining the desired results on the "call" event.
Note: this code does run as expected when I use the "execution" event as
in
pointcut captureOnInstance():execution(AccountViewer.new());
+ My question is why wouldn't it run with the "call" event?
The aspect I want associated to each new instance of my 'AccountViewer'
class is the following:
public aspect LabelAspect perthis(captureOnInstance())
{
public LabelAspect(){
System.out.println("Instantitating aspect itself");
}
pointcut captureOnInstance():call(AccountViewer.new());
before(): captureOnInstance(){
System.out.println("HelloAspectWorld!!!!!!");
}
}
There is no output, i.e. it seems as though the advice is not executing.
Also, the message in the constructor is not executing.
When I remove the perthis association, the advice does execute when new
instances of the AccountViewer Class are created, however, in this
latter case, I don't fulfill my goal of associating an aspect instance
with each new AccountViewer Instance.
Again, if I switch call for execution, the code works.
[1] Raminvas Laddad, "AspectJ in Action"
------------------------------------------------------------------------
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users