[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] How to log both the caller object and the executing object of a setter pointcut
|
On 14 March 2010 13:56, rstyle <ekinrf@xxxxxxx> wrote:
> I am trying to write a logger, and need to log both the caller object and
> the executing object of a setter call. I used a field set point cut,
> however, found no caller's context can be obtained from the 'thisJoinPoint.'
> Can anyone please give me some hints to solve the problem?
I only see thisJoinPoint.getThis() return null when the calling
context is a static method - where is your field set join point?
Sometimes thisEnclosingJoinPoint may be useful as that will give you
the surrounding join point containing the field set.
> Is there a way to access caller's context with a execution join point?
no (other than introspecting the thread stack). Perhaps you could
construct something ugly with cflow but it wouldn't perform well.
Obtaining the caller and instance built at a constructor call site:
after() returning (Foo newInstance): call(Foo.new(..)) {
System.out.println("New instance "+newInstance);
System.out.println("From "+thisJoinPoint.getThis());
}
again, getThis will be null if the caller is a static context.
Andy