[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-dev] Fwd: static context/pointcuts (was [aspectj-users] Object Graph using aspectj)
|
On Dec 16, 2008, at 23:33 , Ramnivas Laddad wrote:
Consider a more typical use of this(). Binding this to null (or the
class object) will make it difficult to write advice and pointcuts.
For example, currently I can write:
after(Account acc) returning : execution(* Account.set*(..)) &&
this(acc) {
acc.setDirty();
}
Instead of:
after(Account acc) returning : execution(* Account.set*(..)) &&
this(acc) {
if (acc != null) {
acc.setDirty();
}
}
or
after(Account acc) returning : execution(!static * Account.set*(..))
&& this(acc) {
acc.setDirty();
}
I would personally think that this last solution makes a lot of sense,
because there are no "surprises" (like the one described in the
original mail on the aspectj-users list), and the intention is really
explicit. If I'm interesting in join points in any context, then I
should be prepared to have this bound to null (or the class), while if
not, then I specify it explicitly in the pointcut. In neither cases do
I have do define two sets of pointcuts, as advised in the case at stake.
I guess what I'm really struggling with is the fact that binding
'this' in the pointcut is really semantically different from obtaining
'this' using thisJoinPoint.getThis(), since the former implies not
matching at all in static context, while the latter does.
But I see your point, and it's true that "in most cases" the current
design is "ok".
-- Éric