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

Alexandre Vasseur <[email protected]>
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
Hi

In the given code, the MyCustomJoinPoint is a static inner interface
of MyAspect2  so its name is not testAOP.MyCustomJoinPoint.

It is more testAOP.MyAspect2$MyCustomJoinPoint
as printed by a Class.forName(....).getName();

Alex


On 4/19/05, Hindin, Avi <[email protected]> wrote:
>  
>  
> 
> Hi Alex, 
> 
>   
> 
> This is the code that I'm trying: 
> 
>   
> 
> <aspectwerkz> 
> 
>   
> 
>   <system id="AspectWerkzExample"> 
> 
>   
> 
>     <package name="testAOP"> 
> 
>   
> 
>        <aspect class="MyAspect2"> 
> 
>   
> 
>           <!--pointcut name="greetMethodPCut" expression="execution(*
> testAOP.HelloWorld.greet(..)) && args(arg0, arg1)"/--> 
> 
>   
> 
>           <pointcut name="greetMethodPCut" expression="execution(public *
> testAOP.HelloWorld.greet(..))"/> 
> 
>   
> 
>              <advice name="aroundGreeting(testAOP.MyCustomJoinPoint jp)"
> type="around" bind-to="greetMethodPCut"/> 
> 
>   
> 
>        </aspect> 
> 
>   
> 
>     </package> 
> 
>   
> 
>   </system> 
> 
>   
> 
> </aspectwerkz> 
> 
>   
> 
>   
> 
> package testAOP; 
> 
>   
> 
> import org.codehaus.aspectwerkz.joinpoint.JoinPoint; 
> 
> import org.codehaus.aspectwerkz.joinpoint.MethodRtti; 
> 
>   
> 
> public class MyAspect2 { 
> 
>   
> 
>     // we could inherit StaticJoinPoint instead 
> 
>     public static interface MyCustomJoinPoint extends JoinPoint { 
> 
>         Object proceed(String arg0, String arg1); 
> 
>     } 
> 
>   
> 
>     public Object aroundGreeting(MyCustomJoinPoint jp)
> throws Throwable 
> 
>     { 
> 
>        // lets change the args : 
> 
>        return jp.proceed("new arg0", "new arg1"); 
> 
>     } 
> 
> } 
> 
>   
> 
> package testAOP; 
> 
>   
> 
> public class HelloWorld { 
> 
>   
> 
>     public static void main(String args[]) { 
> 
>         HelloWorld world = new HelloWorld(); 
> 
>         world.greet(null, null); 
> 
>     } 
> 
>   
> 
>     public void greet(String s1,String s2) 
> 
>     { 
> 
>         System.out.println(">>>>>>>>>>> <" + s1 + ">, <"+ s2 + ">"); 
> 
>     } 
> 
> } 
> 
>   
> 
> Thanks, 
> 
> Avi. 
> 
>   
> 
> -----Original Message-----
>  From: Alexandre Vasseur [mailto:[email protected]] 
>  Sent: Tuesday, April 19, 2005 3:41 PM
>  To: Hindin, Avi
>  Cc: [email protected]; [email protected]
>  Subject: Re: FW: [aspectwerkz-user] RE: Initializing references from a
> "before " aspect 
> 
>   
> 
> can you send me the code snip (custom jp, aspect and aop.xml file) 
> 
> Send it to me directly. I ll post my feedback on the list. 
> 
>   
> 
> Thanks 
> 
> Alex 
> 
>   
> 
> On 4/19/05, Hindin, Avi <[email protected]> wrote: 
> 
> >  
> 
> >  
> 
> > 
>  
> 
> > Hi Alex, 
> 
> > 
> 
> >   
> 
> > 
> 
> > I try it and I'm getting this error: 
> 
> > 
> 
> > <advice name="aroundGreeting(testAOP.MyCustomJoinPoint jp)" type="around" 
> 
> > bind-to="greetMethodPCut"/> 
> 
> > 
> 
> >   
> 
> > 
> 
> > org.codehaus.aspectwerkz.exception.DefinitionException: 
> 
> > could not find advice method [aroundGreeting(testAOP.MyCustomJoinPoint
> jp)] 
> 
> > in [testAOP.MyAspect2] (are you using a compiler extension that you have
> not 
> 
> > registered?) (are you using XML defined advice, with StaticJoinPoint 
> 
> > bindings without specifying the fullsource like signature?) 
> 
> > 
> 
> >   
> 
> > 
> 
> > Thanks, 
> 
> > 
> 
> > Avi. 
> 
> > 
> 
> >   
> 
> > 
> 
> > -----Original Message----- 
> 
> >  From: Alexandre Vasseur [mailto:[email protected]] 
> 
> >  Sent: Tuesday, April 19, 2005 11:50 AM 
> 
> >  To: [email protected] 
> 
> >  Subject: Re: [aspectwerkz-user] RE: Initializing references from a
> "before" 
> 
> > aspect 
> 
> > 
> 
> >   
> 
> > 
> 
> > Hi 
> 
> > 
> 
> >   
> 
> > 
> 
> > I know our doc is bad on that part. 
> 
> > 
> 
> > When the advice signature is not just "(JoinPoint anyName)" or 
> 
> > 
> 
> > "(StaticJoinPoint anyName)" you have to write it entirely in the XML 
> 
> > 
> 
> > using full qualified names. 
> 
> > 
> 
> >   
> 
> > 
> 
> > <advice name="aroundGreeting(YOUR.PACKAGE.MyCustomJoinPoint jp)" 
> 
> > 
> 
> > type="around" bind-to="greetMethodPCut"/> 
> 
> > 
> 
> >   
> 
> > 
> 
> >   
> 
> > 
> 
> >   
> 
> > 
> 
> > (doc snip - to be fixed) 
> 
> > 
> 
> > #  name - [mandatory] the name of the advice is the name of the method 
> 
> > 
> 
> > in the aspect class that implements the advice, with an optional 
> 
> > 
> 
> > method signature if pointcut with signature are used. Abbreviations 
> 
> > 
> 
> > can be used in this signature, including for the JoinPoint or 
> 
> > 
> 
> > StaticJoinPointparameter. The signature must name its parameters (as 
> 
> > 
> 
> > if it was some source code) like advice3(JoinPoint jp, int i). The 
> 
> > 
> 
> > method defined this way must exist with the same signature in the 
> 
> > 
> 
> > aspect class hierarchy. 
> 
> > 
> 
> >   
> 
> > 
> 
> >   
> 
> > 
> 
> > Alex 
> 
> > 
> 
> >
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.