Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
FW: [aspectj-dev] Trying to capture a method on a nested class


Kevin,
 
       Sorry about the iterative process but I am new to aspects and the
code I am trying to police. Perhaps the structure will make it clear what I
am trying to do 
          

Hugh McBride
Curam Software


-----Original Message-----
From: Keven Ring [mailto:keven@xxxxxxxxx] 
Sent: 06 April 2005 14:29
To: HMcBride@xxxxxxxxxxxxxxxxx
Subject: Re: [aspectj-dev] Trying to capture a method on a nested class

Hugh McBride wrote:

>Kevin,
>
> The code was a bit unclear it should read
>
> CookieRecipe.getCookieObject().setValue(new CookieObject());
> CookieRecipe.getRaisinObject().setValue(new RaisinObject());
> CookieRecipe.getFlourObject().setValue(new FlourObject());
>
> Which will set the CookieObject on the CookieRecipe in the
>CookierRecipeLoader class 
>
>
>Thanks for the reply 
>
>  
>
It doesn't matter...  The semantics are still the same...  You are 
invoking the setValue method on the object returned by the 
getCookieObject method....

What does getCookieObject return?  an instance of CookieObject?  If so, 
then your code appears to be incorrect.  What you would do is 
CookieRecipe.setCookieObject(new CookieObject());

Then, anyone can invoke the CookieRecipe.getCookieObject() method, which 
returns the cookie object set in some other code (say the constructor 
for CookieRecipe, or similar).

Your pointcut

CookieRecipe.get*.setValue(..)



really says:  If there are any invocations of the setValue method (with 
any number of parameters) from any field defined in CookieRecipe that 
starts with "get"

the method getCookieObject() is a method, not a field, and so the 
pointcut will *not* match....

Is this clearer?

>Hugh McBride
>Curam Software
>
>
>-----Original Message-----
>From: Keven Ring [mailto:keven@xxxxxxxxx] 
>Sent: 06 April 2005 13:06
>To: AspectJ developer discussions
>Subject: Re: [aspectj-dev] Trying to capture a method on a nested class
>
>Hugh McBride wrote:
>
>  
>
>>To all
>>
>>I have a series of classes i.e CookieObject, RaisinObject,  FlourObject,
>>ButterObject etc that are contained in another class called CookieRecipe
>>    
>>
>and
>  
>
>>are set like so 
>>
>>public class CookieRecipeLoader
>>{
>> 
>>CookieRecipe.getCookie().setValue(new CookieObject());
>>CookieRecipe.getRaisin().setValue(new RaisinObject());
>>CookieRecipe.getFlour().setValue(new FlourObject());
>>
>>
>>}
>>
>>
>>
>>I am trying to generate a error when the setValue is called on any
>>Of the getters i.e. getCookie(), getRaisin() etc
>>
>> 
>>
>>    
>>
>Um, your semantics are incorrect - you are not invoking the setValue 
>method on any of the getter methods, rather, you are invoking the 
>setValue method on the /return value/ from the getter methods.
>
>That is, your statements above are semantically equivelant to:
>Cookie c = CookieRecipe.getCookie();
>c.setValue(new CookieObject());
>
>  
>
>>Have tried the code below 
>>
>>declare error: call((* CookieRecipe.get*.setValue(..) ) &&
>>!within(CookieRecipeLoader)): "Illegal to add Ingredient outside cookie"; 
>>
>>
>>It seems that I cant get past the getters, does anyone know the right
>>    
>>
>syntax
>  
>
>>To use , or can it be done at all 
>>
>>Thanks
>>Hugh McBride
>>
>>The information in this email is confidential and may be legally
>>    
>>
>privileged.
>  
>
>>It is intended solely for the addressee. Access to this email by anyone
>>    
>>
>else
>  
>
>>is unauthorized. If you are not the intended recipient, any disclosure,
>>copying, distribution or any action taken or omitted to be taken in
>>    
>>
>reliance
>  
>
>>on it, is prohibited and may be unlawful. If you are not the intended
>>addressee please contact the sender and dispose of this e-mail. Thank you.
>>_______________________________________________
>>aspectj-dev mailing list
>>aspectj-dev@xxxxxxxxxxx
>>https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>> 
>>
>>    
>>
>
>The information in this email is confidential and may be legally
privileged.
>It is intended solely for the addressee. Access to this email by anyone
else
>is unauthorized. If you are not the intended recipient, any disclosure,
>copying, distribution or any action taken or omitted to be taken in
reliance
>on it, is prohibited and may be unlawful. If you are not the intended
>addressee please contact the sender and dispose of this e-mail. Thank you.
>_______________________________________________
>aspectj-dev mailing list
>aspectj-dev@xxxxxxxxxxx
>https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>  
>

The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorized. If you are not the intended recipient, any disclosure,
copying, distribution or any action taken or omitted to be taken in reliance
on it, is prohibited and may be unlawful. If you are not the intended
addressee please contact the sender and dispose of this e-mail. Thank you.
  

Attachment: ISCAAssessmentHouseholdLoader.java
Description: Binary data


Back to the top