JBossAOP Metadata Question
sushmam Jan 4, 2005 6:51 AMHi,
I'm able to obtain the metadata (defined in jboss-aop.xml) only in case of MethodInvocation.
For ConstructorCalledByConstructorInvocation, ConstructorCalledByMethodInvocation, MethodCalledByMethodInvocation, I'm not able to get the metadata.
Why isn't the metadata getting picked up for the above mentioned invocations?
I looked into the jboss-aop sources, and found that in MethodInvocation.java, getMetadata method, if the threadlocal variable returns a null value for the metadata, we try and get the metadata from the ClassAdvisor.
In case of ConstructorCalledByConstructorInvocation, no such attempt is made. If the threadlocal variable returns a null value for the metadata, the same is returned from the getMetadata method. Is there a specific reason for doing so?
Can anyone throw some light on this please?
(I'm using JBossAOP 1.0 Final)
========================================
Here is how i'm defining the metadata in jboss-aop.xml
<metadata tag="mname" class="xyz"> <method expr="void send(boolean)"> <method_name>MetaOne</method_name> </method> </metadata> <metadata tag="mname" class="abc"> <constructor expr="abc(byte\[\], boolean)"> <method_name>MetaTwo</method_name> </constructor> </metadata> <!-- MethodCalledByMethodInvocation --> <bind pointcut="withincode(public void xyz->send()) AND call(* xyz->send(boolean))"> <interceptor class="TestMetricsInterceptor"/> </bind> <!-- ConstructorCalledByMethodInvocation --> <bind pointcut="call(public abc->new(..))"> <interceptor class="TestMetricsInterceptor"/> </bind>
The invoke() of interceptor where I'm trying to get the meta-data is:
public Object invoke(Invocation invocation) throws Throwable { InvocationBase invocationBase = (InvocationBase) invocation; System.out.println("Metadata ******** " + invocation.getMetaData("mname", "method_name")); }
Only if the invocation is of type MethodInvocation, I'm able to get a valid metadata. For the other invocations, I get metadata as null.
========================================
Thanks,
Sushma.