[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] How to get more context information in adviceexecution() pointcut
|
This is mostly a question to the AspectJ development team. I ran into an interesting question on StackOverflow and answered it as good as I could: http://stackoverflow.com/a/24058253/1082681
I had to use some public, but undocumented functionality and several questions arose during the process:
1) When capturing adviceexecution(), sometimes thisJoinPoint.getArgs()
yields
a) { JoinPoint.StaticPart }
for before() or after() advice,
b) { AroundClosure, JoinPoint.StaticPart }
for some around() advice,
c) { AroundClosure }
for other around() advice.
I wonder why sometimes it is 1b, at opther times 1c. I think maybe
1b could be the result for nested around() advice, but I am not sure.
2) I was kind of disappointed because on one hand I could get the
information mentioned in 1 via tjp.getArgs(), but on the other hand
was unable to bind it to parameters via args(). Does it make sense
to change/improve that?
3) When capturing adviceexecution(), I want to have a defined way of
getting access to the joinpoint targeted by the underlying advice,
so I can decide what to do in my advice, e.g. based on the method
call/execution that was just captured. Is that possible or can
AspectJ be enhanced to make it possible?
4) While I found an undocumented way of calling proceed() in the
captured advice without actually ececuting the advice itself (which
is a way of dynamically deactivating/circumventing advice execution,
but still calling the original application code targeted by the
advice), I found no documented one. How stable is this way (cf.
sample code on StackOverflow)? Can it be documented or exposed via
JoinPoint API?
5) I also had to use AroundClosure.getState() for my stunt in 4, but
the method is also undocumented. It seems to yield an obect array
the first element of which seems to be the captured advice's target,
the remaining elements seem to be the underlying method's
parameters, regardless of whether they are bound via args() or not.
Could this be documented or exposed to the API more clearly?
6) I wish there was a way to restrict adviceexecution() by being able
to specify which advice to capture, e.g. using a syntax like
adviceexecution(execution(* foo.bar.MyClass.myMethod(..))). This
might be a real big feature request, but I am asking anyway. :-)
Sorry for so many questions, but I think when doing serious business with adviceexecution() sooner or later these questions arise.
--
Alexander Kriegisch
http://scrum-master.de