Re: [aspectwerkz-user] Intercepting parameters with run-time aspect deployment.
"Alexandre Vasseur" <[email protected]> Thu, 8 Mar 2007 22:27:44 +0100
| Newsgroups | gmane.comp.java.aspectwerkz.user |
|---|---|
| Message-ID | <[email protected]> |
sounds to me that your deployment scope is within(MyClass) and then your hot deployed advice is boud to pointcut call(MyClass.something). The deployment scope must be a superset of the pointcut where you deploy later so that does not seem good. That said you are using in the sample MyClass.main to call MyClass.X to call Y so this should work (though a bit confusing) I see that in the build time test you are using execution pointcut so this is not consistent. Alex On 3/8/07, Udo Fritzke Jr. <[email protected]> wrote: > > Hi, > > We are trying to intercept the actual parameters and return values > of a class method call, defining "args" pointcuts. It works fine > when the weaving is done statically with a build file. However, it > does not work when we dynamically deploy an aspect. The application > compiles and runs, but the advice does take effect at all. > > Does someone could explain if there is some guideline or implementation > detail we are missing? > > A sample code follows. > > Thanks in advance, > Udo. > > ****************************** > aop.xml > ****************************** > <aspectwerkz> > > <system id="AW.MyAspect"> > <package name="AW"> > <aspect class="MyAspect"> > > <deployment-scope name="response_time"> > within(AW.MyClass) > </deployment-scope> > > <!-- used only for static weaving > > <pointcut name="pc1" expression="execution(* AW.MyClass.Y(..))"/> > <advice name="advice1(int ret, int arg)" type="after returning(ret)" > bind-to="pc1 AND args(arg)"/> > --> > > </aspect> > </package> > </system> > </aspectwerkz> > > ****************************** > MyAspect.class > ****************************** > package AW; > > public class MyAspect > { > public void advice1(int ret, int arg) > { > //ret eh o retorno do metodo Y > System.out.println("Aspect: "+ret); > > // arg eh o argumento passado em Y > System.out.println("Aspect: "+arg); > > } > } > > ****************************** > MyClass.class > ****************************** > package AW; > > public class MyClass > { > public void X() > { > int arg = 4; > int ret = Y(arg); > System.out.println("Aplicacao"+ret); > } > > public int Y(int arg) > { > System.out.println("Aplicacao"+arg); > return 2; > } > > > public static void main(String Argumentos[]) > { > MyClass obj = new MyClass(); > > String xmlDef = "<aspect class='MyAspect'> " + > "<pointcut name='pc1' expression='call(* > AW.MyClass.Y(..))'/>" + > "<advice name='advice1(int ret, int arg)' > type='after > returning(ret)' " + > " bind-to='pc1 AND args(arg)'/> " + > "</aspect>"; > Deployer.deploy(MyAspect.class, xmlDef); > obj.X(); > } > } > > > > > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > >