3 Replies Latest reply on Feb 7, 2005 6:25 AM by kabirkhan

    Metadata not getting picked up for all invocations.

    sushmam

      Hi,

      I'm able to obtain the metadata (that is defined in jboss-aop.xml) only in case of MethodInvocation.

      For ConstructorCalledByConstructorInvocation, ConstructorCalledByMethodInvocation, MethodCalledByMethodInvocation, I'm not able to get the metadata. I'm using JBossAOP 1.0 Final.

      Can anyone throw some light on this issue please?

      Thanks,
      Sushma.

        • 1. Re: Metadata not getting picked up for all invocations.
          kabirkhan

          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

            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.java
            public 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

              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