This content has been marked as final.
Show 3 replies
-
1. Re: Metadata not getting picked up for all invocations.
kabirkhan Jan 20, 2005 8:49 AM (in response to sushmam)Hi there,
Sorry about the delay :-) Can you please provide a small example?
Thanks,
Kabir -
2. Re: Metadata not getting picked up for all invocations.
sushmam Jan 27, 2005 1:26 AM (in response to sushmam)Hi,
Here is the sample test code. I have modified the metadata example of jboss-aop_1.0.0-FINAL distribution:
Interceptor:public class BillingInterceptor implements Interceptor { public String getName() { return "BillingInterceptor"; } public Object invoke(Invocation invocation) throws Throwable { InvocationBase invocationBase = (InvocationBase) invocation; System.out.println("BillingInterceptor --> " + invocationBase.getClass().getSuperclass()); System.out.println("my-attribute : " + invocation.getMetaData("mdTest", "my-attribute")); return invocation.invokeNext(); } }
Driver:public class Driver { public static void main(String[] args) { System.out.println("--- new TEST(); ---"); TEST test = new TEST(); test.secondMethod(567); } }
Test.javapublic class TEST { public TEST() { System.out.println("testcons"); } public void secondMethod(int newfoo) { System.out.println("in second Method --> " + newfoo); secondCall(); } public void secondCall(){ System.out.println("SecondCall called by second method"); } }
jboss-aop.xml<?xml version="1.0" encoding="UTF-8"?> <aop> <metadata tag="mdTest" class="TEST"> <method name="secondMethod"> <my-attribute>secondMethod</my-attribute> </method> </metadata> <metadata tag="mdTest" class="TEST"> <method name="secondCall"> <my-attribute>* SecondCALL *</my-attribute> </method> </metadata> <bind pointcut="execution(* TEST->secondMethod(..))"> <interceptor class="BillingInterceptor"/> </bind> <bind pointcut="call(* TEST->secondCall())"> <interceptor class="BillingInterceptor"/></bind> </aop>
Program Output:Buildfile: /Users/sushma/work/workArea/eclipseWorkspace/TestMetaData/build.xml prepare: compile: [annotationc] Working directory ignored when same JVM is used. run: [java] --- new TEST(); --- [java] testcons [java] BillingInterceptor --> class org.jboss.aop.joinpoint.MethodInvocation [java] my-attribute : secondMethod [java] in second Method --> 567 [java] BillingInterceptor --> class org.jboss.aop.joinpoint.MethodCalledByMethodInvocation [java] my-attribute : null [java] SecondCall called by second method BUILD SUCCESSFUL Total time: 7 seconds
For MethodInvocation, metadata (secondMethod) is getting picked up. But, for MethodCalledByMethodInvocation, metadata( * SecondCALL *) is not getting picked up. I'm using jboss-3.2.6RC2.
Thanks,
Sushma. -
3. Re: Metadata not getting picked up for all invocations.
kabirkhan Feb 7, 2005 6:25 AM (in response to sushmam)Hi,
Sorry, but caller side metadata is not yet implemented. I have added it as a task to our JIRA:
http://jira.jboss.com/jira/browse/JBAOP-74