Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Can I determine method objects or names in advice?

Sounds about right to use the thisJoinPoint to get this information. I think Wez has posted something along these lines on the list recently. If you missed that then let me kow and I'll post it through to you direct.

Cheers,

Russ
 
On Friday, February 06, 2004, at 02:18PM, John M. Adams <jmadams@xxxxxxxxx> wrote:

>Russell Miles <russellmiles@xxxxxxx> writes:
>
>> Hi John,
>>
>> Sounds fair enough. I think if I understand you correctly you want to
>> know that the method aMethod was called and that bf is being accessed
>> then the an approach is possibly like the following aspect definition?
>> :
>>
>> public aspect TraceReadOfBf
>> {
>> 	public pointcut readingBfInaMethod() : execution(int A.aMethod());
>> 	public pointcut readingbf() : call(int B.getBf()) &&
>> 	cflow(readingBfInaMethod());
>> 	
>> 	before() : readingbf()
>> 	{
>> 		System.out.println("bf Accessed from: " +
>> 		thisJoinPoint.getStaticPart().getSourceLocation());
>> 		
>> 	}
>> }
>>
>> Give me a shout if there's something I've missed ... and good luck :-)
>>
>> You could also allow aspect oriented monitoring of the variable if you
>> aren't doing that in a way that is intrusive?
>
>Hi and thanks for the reply.  Getting the SourceLocation doesn't seem
>very interesting as I need to reinvoke the method.
>
>However, the JoinPoint Signature is interesting in this respect.  If I
>inspect that in two advices, one at call and one at get, I think that
>gives me what I need.
>
>Thanks again,
>
>>
>> On 5 Feb 2004, at 21:03, John M. Adams wrote:
>>
>>> Dear Friends,
>>>
>>> Is it possible to access either the name of the calling method or the
>>> method object in some advice?  I would like to implement something
>>> like the following: Let a be an instance of A and b an instance B.
>>> Let bf be a field of B.  and aMeth be method on A.  If aMethod reads
>>> bf, I want to record that fact so as to reinvoke it later if bf is
>>> updated.
>>>
>
>-- 
>John M. Adams
>
>_______________________________________________
>aspectj-users mailing list
>aspectj-users@xxxxxxxxxxx
>http://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top