3 Replies Latest reply on Sep 6, 2004 5:41 AM by drstrangevibes

    Simple Interceptor Question

    drstrangevibes

      Im trying to use AOP to intercept all methods of a class contained in an ear file

      I use ant primarily 'aop' my class file here is the script
      ignore the '<' foibles
      'The source names have been changed to protect the instance!'

      '<'target name="wcbd-aopcompile" depends="">


      <!-- these system properties are needed by the code -->
      '<'jvmarg value="-Djboss.aop.path=${aopxml.file}" />
      '<'jvmarg value="-DDIFFTESTCONFIGDIR=${dxxxxx.root}" />
      '<'classpath>
      '<'path refid="jbossaop.classpath.for.compile" />
      '<'pathelement location="${dxxxx.dist}/Dxxxxx.jar" />
      '<'path refid="dxxxx.classpath" />
      '<'/classpath>
      '<'arg value= "${wc.userapp}/build/main/classes/Wxxxxxxxx.class" />
      '<'arg value="-report" />
      '<'arg value="-verbose" />
      '<'/java>
      '<'/target>

      Here is the jboss-aop.xml file

      '<'?xml version="1.0" encoding="UTF-8"?>
      '<'aop>
      '<'bind pointcut="call(* com.sxxxxxxx.wxxxxx.user.web.Wxxxxxx->testAOP(int))">
      '<'interceptor class="com.smxxxxxm.dxxxx.BusinessDelegateInterceptor" singleton="true"/>
      '<'/bind>
      '<'/aop>

      Here is the interceptor

      package com.sxxxxxx.dxxxxxxxx;


      import java.lang.reflect.Method;

      import org.jboss.aop.advice.Interceptor;
      import org.jboss.aop.joinpoint.Invocation;
      import org.jboss.aop.joinpoint.InvocationResponse;
      import org.jboss.aop.joinpoint.MethodInvocation;

      public class BusinessDelegateInterceptor implements Interceptor {



      public BusinessDelegateInterceptor() {

      dbdiffprops = DBDiffProperties.getInstance();

      }

      /**
      *
      */
      public String getName() {
      return this.getClass().getName();
      }


      public Object invoke(Invocation invocation) throws Throwable {
      System.out.println(" About to intercept ");

      .......

      InvocationResponse rsp = (InvocationResponse) invocation.invokeNext();
      System.out.println("AOP Intercepted Complete");
      return rsp;
      }
      }

      after aop preparation the class file is repackaged into the jar and ear, but running it later produces no response. The aop-report is blank , is it possilbe that my class path is too long during aopcompilation?


      Greg