3 Replies Latest reply on Jan 4, 2006 11:25 PM by Joe Reger

    JBossCache AOP and JDK 5.0 annotations

    Mirko Nasato Newbie

      I've been playing with TreeCacheAop a little bit, trying to use JDK 5.0 annotations with it.

      Here's what I've done

      1. downloaded JBossCache 1.2.4
      2. downloaded JBoss AOP 1.3.4
      3. replaced JBossCache/lib/jboss-aop.jar with jboss-aop_1.3.4/lib-50/jboss-aop-jdk50.jar
      4. created a simple annotation

      package demo.cache.aop;
      
      import ...;
      
      @Target({ElementType.TYPE})
      public @interface Cacheable { }

      5. created a jboss-aop.xml
      <aop>
       <prepare expr="field(* $instanceof{@demo.cache.aop.Cacheable}->*)"/>
      </aop>

      6. marked my POJOs as Cacheable, precompiled them with aopc and ran some tests

      and everything seem to work just fine. Tested loadtime weaving as well.

      But I read that JBossCache will support JDK 5.0 only from version 1.3, so I'd like to know if there's anything I'm missing?
      Any reasons why I shouldn't be using JDK 5.0 features with JBossCache right now?


        • 1. Re: JBossCache AOP and JDK 5.0 annotations
          Ben Wang Master

          Yes, you can do that. But we need to support oth JDK 1.4 and JDK 1.5. So it needs some extra work. Besides, I want to hide the xml from the user totally.

          -Ben

          • 2. Re: JBossCache AOP and JDK 5.0 annotations
            Joe Reger Newbie

            Hi mnasato!

            Can you give an example of how you marked up your POJOs as Cacheable? I'm fairly new to AOP. I have:

            @Cacheable
            public class Banner {
            ...
            }


            I'm getting some trouble with the apoc ant task. It's likely a misconfiguration of the ant task, but I wanted to see if I could rule out bad annotation first. Here's what's in my ant script, for reference:

            <aopc compilerclasspathref="lib.classpath" verbose="true">
             <classpath path="${compiled.files}"/>
             <src path="${compiled.files}"/>
             <include name="**/*.class"/>
             <aoppath path="${sourcedir}/WEB-INF/jboss-aop.xml"/>
             </aopc>


            The error is:

            Exception in thread "main" java.lang.NoSuchFieldError: doPruning
            at org.jboss.aop.AOPClassPool.<clinit>(AOPClassPool.java:34)
            at org.jboss.aop.AspectManager.registerClassLoader(AspectManager.java:552)
            ...


            Thanks for any help,

            Joe

            • 3. Re: JBossCache AOP and JDK 5.0 annotations
              Joe Reger Newbie

              Looks like the javassist.jar I had was missing the javassist.ClassPool.doPruning property. I believe I had an old version. I downloaded the latest from jboss.org. Sorry for the trouble... it appears to be compiling properly now. As mnsato said, very easy to do... if you have the right libraries installed :)