Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Re: Differentiating between similar join points

Hi Armin,

Thanks much. I will try these suggestions.

Devon.

>===== Original Message From Armin <funkoholic@xxxxxx> =====
>Hi Devon.
>
>The pointcut language of AJ does not distinguish between two
>syntactically equal joinpoints that reside in the same context.
>
>Means: No, you can not pick out the two calls A.withdraw() separately.
>At least not statically because they look the same an their enclosing
>program element is the same (execution joinpoint of the transfer
>method).
>
>But you have at least one alternative and two workarounds:
>
>1. What you can do is distinguish them dynamically. So if you have
>any attributes of A that changes after the first call of A.withdraw()
>or the A.deposit() method you can pick out the first /second call by
>checking this attribute's values during runtime.
>
>pointcut firstCall():
>	call(A.withdraw(..)) && if(A.foo == bar);
>
>If you don't want have any appropriate attribute and you don't want
>to create a dummy attribute within A you could use a counter or a
>flag within your aspect. As long as you have static calls to
>A.withdraw() this is sufficient.
>
>2. The ugly one: Wrap the two calls with two dummy methods that
>differ syntactically.
>	A.withdraw1(); //calls A.withdraw()
>	A.deposit();
>	A.withdraw2();  //calls A.withdraw()
>
>3. I've never tried this but probably you can use @annotations to
>distinguish the two calls.
>	@firstcall A.withdraw();
>	A.deposit();
>	@secondCall A.withdraw();
>
>cheers,
>Armin
>
>
>
>
>> Hi All,
>>
>> Given the following three calls:
>>
>> public void transfer(..) {
>> //some code
>> A.withdraw(..);
>> A.deposit(..);
>> A.withdraw(..);
>> //some code
>> }
>>
>> How do I pick out the first and last call join points separately?
>>
>> Thanks.
>>
>> Devon.
>
>
>_______________________________________________
>aspectj-users mailing list
>aspectj-users@xxxxxxxxxxx
>https://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top