[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Is there a direct way to get the variable name of a pointcut matched
|
Hi,
> I'm trying to catch methods of a certain Class type to mock them later on. I
> achieved nicely to catch all method calls of a certain Type like eg User
> with all the static information looking with
> <code>
> pointcut methodWithReturnValue() : (execution(!void
> *.*(..))&&(!within(org.automock.tools.*)) &&(!within(junit.*)));
>
> after() returning(Object returnedObject) : methodWithReturnValue() {
> </code>
Glad this works for you.
> But I would also need to know the variable name. Eg if there were two User
> objects like User admin and User guest, there should be two mocks dedicated
> to the these to control their exact behaviour.
Something like this might work. Since you are only dealing with
executions, it should always be a MethodSignature.
public aspect SignatureTests {
public static void main(String[] args) {
}
before() : execution(public static void main(String[])) {
System.out.println(((MethodSignature)
thisJoinPoint.getSignature()).getParameterNames()[0]);
}
}