[aspectwerkz-user] Re: Initializing references from a "before" aspect

Jonas Bonér <[email protected]>
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
Hi there.

If I understand you correctly, you want to modify the value of a
parameter that is passed to the method you are advising.

If so I would use an around advice and make use of the custom join
point (see  http://aspectwerkz.codehaus.org/new_features_in_2_0.html#Strongly_typed_proceed
for details) to change the parameter value and pass the modified
parameter value on.

Does this help?

/Jonas

On  hi there4/17/05, Hindin, Avi <[email protected]> wrote:
> Hi guys,
> 
>  
> 
>  My aim is to write a "before" aspect that initializes a reference passed
> to
> the original method as null.
> 
>  
> 
>  That is, what I logically want to do in the aspect is:
> 
>       myMethod(String str)
> 
>       {
> 
>            // "before" aspect should do the following:
> 
>             If(str==null) 
> 
>                      str = "abc";
> 
>  
> 
>  
> 
>            // applicative logic here ....
> 
>       }
> 
>  
> 
> All this is well, but, of course, does not work. Why? Because AspectWerkz
> implements "before" aspects by calling
> 
> an automatically generated method to do the work (example below) and you
> cannot, of course, initialize a reference 
> 
> within a method.
> 
>  
> 
>  But is there a workaround?    Please notice that such a workaround cannot
> involve attaching the aspect
> 
>  to code _callng_ the method, since that code is not available to me.
> 
>  
> 
>  Your help will be highly appreciated!
> 
>  
> 
> Avi Hindin
> 
> BMC Software
> 
>  
> 
>  
> 
>  
> 
> 
> 

-- 
/Jonas
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.