10 Replies Latest reply on Mar 27, 2008 10:39 AM by kabirkhan

    Deployment ClassPath and AOP

      While looking at something else, this occurred to me.

      In the updated version of the classloading spi the creation of the in memory
      vfs url is now in a deployer so it can be customised
      http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java?revision=70666&view=markup

      But it adds the virtual file to the end of the classpath.
      I think this should really be at the beginning of the classpath
      otherwise it is going to see the unweaved classes before the weaved classes?

      Also I don't understand why the deployers are passing you the root url
      and then you have to add "classes" onto it. Surely it should just be a case
      that the "classes" url is what gets passed to you? You don't care that the classes
      go in a directory called classes, it could be called something else?

        • 1. Re: Deployment ClassPath and AOP
          kabirkhan

          I am not sure/can't remember why I made the "classes" bit. Maybe I was thinking there could be another for resources or something?

          • 2. Re: Deployment ClassPath and AOP
            kabirkhan

            Regarding the ordering of classpath, I agree it should be at the start of the classpath. Although, as I mentioned somewhere else, this is not a problem in practice since only generated classes are written there. Woven classes are already in the classloader/classpools

            • 3. Re: Deployment ClassPath and AOP

              So can we change it such that Module.getTempURL()
              returns vfsmemory://guid/classes
              that way somebody can decide the url comes from some other mechanism
              that might not put things in a classes folder.

              Also, I don't know whether you saw my comment, but the way
              the vfsmemory handler is handling URL is brokens.
              e.g.

              URL directory = new URL("vfsmemory://guid");
              URL classes = new URL(directory, "classes");
              
              URL classes2 = new URL("directory + "/classes");
              


              classes.equals(classes2) is false which is wrong.
              classes is actually the same as directory????

              I think this is because you are doing your own manual parsing of the URL
              instead of using the api as its meant to be used?

              • 4. Re: Deployment ClassPath and AOP

                 

                "kabir.khan@jboss.com" wrote:
                Regarding the ordering of classpath, I agree it should be at the start of the classpath. Although, as I mentioned somewhere else, this is not a problem in practice since only generated classes are written there. Woven classes are already in the classloader/classpools


                Ok, I'll change this, it will come through in the next deployers release.

                • 5. Re: Deployment ClassPath and AOP
                  kabirkhan

                   

                  "adrian@jboss.org" wrote:

                  Also, I don't know whether you saw my comment, but the way
                  the vfsmemory handler is handling URL is brokens.


                  I just commited the following to the MemoryTestCase, and it passes:
                   public void testUrlHandling()throws Exception
                   {
                   URL directory = new URL("vfsmemory://guid");
                   URL classes = new URL(directory, "classes");
                  
                   URL classes2 = new URL(directory + "/classes");
                  
                   assertEquals(classes, classes2);
                   assertTrue(classes.equals(classes2));
                   }
                  

                  Did you mean something else? This test looks "weird" :-)

                  "adrian@jboss.org" wrote:

                  I think this is because you are doing your own manual parsing of the URL
                  instead of using the api as its meant to be used?


                  Sorry, please elaborate a bit?



                  • 6. Re: Deployment ClassPath and AOP

                     


                    I just commited the following to the MemoryTestCase, and it passes:
                     public void testUrlHandling()throws Exception
                     {
                     URL directory = new URL("vfsmemory://guid");
                     URL classes = new URL(directory, "classes");
                    
                     URL classes2 = new URL(directory + "/classes");
                    
                     assertEquals(classes, classes2);
                     assertTrue(classes.equals(classes2));
                     }
                    

                    Did you mean something else? This test looks "weird" :-)


                    Ok sorry. The problem is not subdirectories, it is the top directory.
                    i.e.
                    URL directory = new URL(new URL("vfsmemory://"), "guid");

                    Try changing this class
                    http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java?revision=71306&view=markup
                    to do:
                     URL vfsMemory = new URL("vfsmemory://");
                     URL dynamicClassRoot = new URL(vfsMemory, new GUID().toString());
                    


                    • 7. Re: Deployment ClassPath and AOP
                      kabirkhan

                      This fails as well

                      URL httpA = new URL("http://classes");
                      URL httpB = new URL(new URL("http://"), "classes");
                      assertEquals(httpA, httpB);
                      



                      junit.framework.AssertionFailedError: expected:<http://classes> but was:<http:/classes>
                      at junit.framework.Assert.fail(Assert.java:47)
                      at junit.framework.Assert.failNotEquals(Assert.java:282)
                      at junit.framework.Assert.assertEquals(Assert.java:64)
                      at junit.framework.Assert.assertEquals(Assert.java:71)


                      • 8. Re: Deployment ClassPath and AOP

                        Ok, I'll test it with the single slash when I can get it to build, see the other thread on
                        the CR8 pom.

                        • 9. Re: Deployment ClassPath and AOP

                          I see what the problem is, it's my misunderstanding.
                          You expect the GUID to be a host name in the url.

                          I've changed it to this and now it works. ;-)

                           // protocol, host, file
                           URL dynamicClassRoot = new URL("vfsmemory", new GUID().toString(), "");
                          


                          • 10. Re: Deployment ClassPath and AOP
                            kabirkhan

                            Cool :-)