3 Replies Latest reply on Mar 25, 2008 2:53 PM by Ales Justin

    AnnotatedClassFilter is wrong + AOP

    Adrian Brock Master

      The AnnotatedClassFilter has a number of problems.

      1) It doesn't understand about "subdeployments" or in this particular case
      that WEB-INF and WEB-INF/classes are in the classpath

      e.g.

      2008-03-25 18:17:10,505 DEBUG [org.jboss.classloader.spi.base.BaseClassLoader] (RMI TCP Connection(16)-127.0.0.1) Created BaseClassLoader@1e3b325{vfsfile:/home/ejort/j
      boss-head/testsuite/output/lib/aop-scopedear1.ear/aop-scopedear1.war} with policy
      ...
      JarEntryContents@27626654[path=aop-scopedear1.war/WEB-INF/classes JarEntryContents@28507864[path=aop-scopedear1.war/WEB-INF
      ...
      


      It tries to load each class twice

      2008-03-25 18:17:10,594 ERROR [STDERR] (RMI TCP Connection(16)-127.0.0.1) [error] Error converting class .. Do verbose mode if you want full stack trace.
      2008-03-25 18:17:10,595 DEBUG [org.jboss.deployment.AnnotatedClassFilter] (RMI TCP Connection(16)-127.0.0.1) Incomplete class: classes.org.jboss.test.aop.scoped.ear.se
      rvlet.EarExampleServlet, NCDFE: java.lang.NoClassDefFoundError: classes/org/jboss/test/aop/scoped/ear/servlet/EarExampleServlet (wrong name: org/jboss/test/aop/scoped/
      ear/servlet/EarExampleServlet)
      


      Also, I don't think it understands how AOP is done?

      2) With AOP there is also an in memory virtual file to store classes
      that AOP has weaved. I think this is going to lead to the classes getting
      processed twice? Once using the non-weaved version then using the
      weaved version?

      Which brings up another unrelated issue in that at the moment,
      I believe the in memory virtual file is after the unweaved virtual file in the classpath?

      3) The current way of scanning classes for annotations is not scalable
      (or even extensible).
      It loads a collection of all classes found then runs each class through
      the processors. This should be a true visitor pattern otherwise a deployment
      with thousands of classes is possibly going to run out memory?

      4) It doesn't take into account the classloading policy in that some parts of
      the classpath could be excluded by filters.

        • 1. Re: AnnotatedClassFilter is wrong + AOP
          Adrian Brock Master

          I think the best way to fix this is to provide some generic class scanning
          from the classloading module.

          Only it has all the information about what is really in the classloader
          e.g. it isn't necessarily everything reachable from the vfs roots, especially
          when there is "subdeployment" within one of those roots.

          Also there should be a way for other annotation parsers to plugin to the process
          such that it is only done once rather repeating the task of parsing annotations
          multiple times.

          e.g. ejb3, servlet, webservices, aop, pojo, (jmx in future?), etc.
          and creating the metadata such that some other deployer can potentially override it

          Ales already has an open issue to create a generic annotation parsing deployer
          http://jira.jboss.com/jira/browse/JBDEPLOY-13

          • 2. Re: AnnotatedClassFilter is wrong + AOP
            Kabir Khan Master

             

            "adrian@jboss.org" wrote:

            2) With AOP there is also an in memory virtual file to store classes
            that AOP has weaved. I think this is going to lead to the classes getting
            processed twice? Once using the non-weaved version then using the
            weaved version?

            Which brings up another unrelated issue in that at the moment,
            I believe the in memory virtual file is after the unweaved virtual file in the classpath?


            AFAICR only new classes that did not exist before are added to the memory virtual file. Existing classes are not, so they should just be processed once. I'll take a better look if you want me to

            • 3. Re: AnnotatedClassFilter is wrong + AOP
              Ales Justin Master

               

              "adrian@jboss.org" wrote:

              Ales already has an open issue to create a generic annotation parsing deployer
              http://jira.jboss.com/jira/browse/JBDEPLOY-13

              OK, I'll start this work in Classloading module and provide proper hooks in the deployers.