[jboss-user] [JBoss AOP] - AOPC compiler seems to run successfully without Aspectizing

mayureshk do-not-reply at jboss.com
Fri Feb 1 02:44:31 EST 2008


I recently got introduced to JBOSS AOP and was able to try out the sample code. 
Thanks to the development team for all their efforts.

My development environment is Windows XP, JDK build 1.6.0_03-b05 and JBoss-AOP_1.5.6.GA

I am facing a interesting issue while using the AOPC compiler. The compiler runs successfully and completes its execution in approx 200ms without actually aspectizing any code or reporting any errors.

My project directory structure is as follows:
ProjectDir
 |- src
 |- lib
 |- bin
 
I am trying to Aspectize a class called DBSession.java in the package com.wills.db (i.e. com.wills.db.DBSession). This class provides an API called getConn() that returns a java.sql.Connection. To intercept the getConn() method I have written an Aspect called ConnDetectorAspect.java and provided binding in the jboss-aop.xml as follows


  | <?xml version="1.0" encoding="UTF-8"?>
  | <aop>   
  |    <bind pointcut="execution(public java.sql.Connection com.wills.db.DBSession->getConn())">
  |        <interceptor class="my.aspects.ConnDetectorAspect"/>
  |    </bind>
  | </aop>
  | 
After compiling the classes using javac (ANT task) the class file com.wills.db.DBSession.class and my.aspects.ConnDetectorAspect.class are generated in the bin directory.

Here are some snippets from my ANT build file

  |     <!-- Contains jar files required by AOPC compiler -->
  |     <path id="jboss.aop.classpath">
  |         <fileset dir="${jboss.aop.lib50}">
  |             <include name="*.jar"/>
  |         </fileset>
  |     </path>
  |     
  |     <!-- Contains jars required by aopc compiler to work (compilerclasspath or compilerclasspathref) -->
  |     <path id="classpath50">        
  |         <path refid="jboss.aop.classpath" />
  |         <pathelement path="${bin.dir}" />
  |     </path> 
  |     
  |     <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="jboss.aop.classpath"/>
  | 
  |     <target name="compile-aop" > 
  |         <echo message="Source files in ${src.dir}" />
  |         <echo message="Files to be AOPed in ${bin.dir}" />
  |         <echo message="" />
  |         
  |         <pathconvert pathsep="${line.separator}`-- " property="echo.classpath50" refid="classpath50">
  |         </pathconvert>
  |         <echo message="$-- Class path used by AOP" />
  |         <echo message="|    " />
  |         <echo message="`-- ${echo.classpath50}" />
  |         <echo message="" />            
  | 
  |         <aopc compilerclasspathref="classpath50" classpathref="classpath50" verbose="true">
  |             <classpath path="${bin.dir}" />
  |             <src path="${src.dir}" />
  |             <aoppath path="${resource.jboss-aop.xml}" />
  |         </aopc>        
  |     </target>    
  | 
After running the compile-aop ANT task I get the following output indicating successful run of the compiler   

  | compile-aop:
  |      [echo] Source files in C:\ProjectDir\src
  |      [echo] Files to be AOPed in C:\ProjectDir\bin
  |      [echo]
  |      [echo] $-- Class path used by AOP
  |      [echo] |
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\concurrent.jar
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\javassist.jar
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\jboss-aop-jdk50-client.jar
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\jboss-aop-jdk50.jar
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\jboss-aspect-jdk50-client.jar
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\jboss-aspect-library-jdk50.jar
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\jboss-common.jar
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\jrockit-pluggable-instrumentor.jar
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\pluggable-instrumentor.jar
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\qdox.jar
  |      [echo] `-- C:\Tools\jboss-aop_1.5.6.GA\lib-50\trove.jar
  |      [echo] `-- C:\ProjectDir\bin
  |      [echo]
  |      [aopc] [debug] Passed in instrumentor: null
  |      [aopc] [debug] Defaulting instrumentor to: org.jboss.aop.instrument.ClassicInstrumentor
  |      [aopc] [debug] jboss.aop.class.path is NULL
  |      [aopc] [debug] jboss.aop.search.classpath: 'null' true
  |      [aopc] [debug] jboss.aop.path: C:\ProjectDir\build\jboss-aop.xml
  |      [aopc] jboss.aop.path[0]: C:\ProjectDir\build\jboss-aop.xml
  |      [aopc] [deploying] file:/C:/ProjectDir/build/jboss-aop.xml
  |      [aopc] AspectXMLLoader using managerorg.jboss.aop.AspectManager at 133f1d7
  |      [aopc] Build Successful: 187ms
  | 
As you can see the compiler did not Aspectize the DBSession class as anticipated and there are no errors. 
I have verified that the correct jboss-aop.xml is getting picked up.

Am I missing something obvious. Any suggestion is appreciated.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125391#4125391

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4125391



More information about the jboss-user mailing list