6 Replies Latest reply on Mar 4, 2010 8:19 AM by thomas.diesler

    How to migrate AssembledDirectory

    thomas.diesler

      How do I migrate this to VFS 3.0

       

         public VirtualFile assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
         {
            AssembledDirectory assembledDirectory = createAssembledDirectory(name, "", resourcePaths, packages);
            return assembledDirectory;
         }
      
         public Bundle deployBundle(String name, OSGiMetaData metaData, String resourcePath, Class<?>... packages) throws Exception
         {
            AssembledDirectory assembledDirectory = createAssembledDirectory(name, "", new String[] { resourcePath }, packages);
            return deployBundle(assembledDirectory, metaData);
         }
      
         public Bundle deployBundle(String name, OSGiMetaData metaData, String[] resourcePaths, Class<?>... packages) throws Exception
         {
            AssembledDirectory assembledDirectory = createAssembledDirectory(name, "", resourcePaths, packages);
            return deployBundle(assembledDirectory, metaData);
         }
      
      
      

       

      This question relates to the more general issue of VFS not beeing documented adequaltely.

       

      https://jira.jboss.org/jira/browse/JBVFS-113

        • 1. Re: How to migrate AssembledDirectory
          alesj

          How do I migrate this to VFS 3.0

          See how this was done in other projects -- CL and Deployers.

          We used this constantly there.

           

          For the Bundle protocol part in OSGi facade, perhaps you can just drop that,

          and I'll re-write it from scratch based on the new VFS3 api.

          • 2. Re: How to migrate AssembledDirectory

            For the deployers testing, John created a bridge class

            https://svn.jboss.org/repos/jbossas/projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/support/AssembledDirectory.java

            or you could just change the tests to use the new VirtualFileAssembly class directly?

            • 3. Re: How to migrate AssembledDirectory
              johnbailey

              A better long-term approach would be to move to using ShrinkWrap archives to declaratively create ear/war/jar archives.  ShrinkWrap already has fluent API to add classes/resources to an archive.

               

              JavaArchive archive = Archives.create("archive.jar", JavaArchive.class) 
                  .addClasses(MyClass.class,MyOtherClass.class) 
                  .addResource("mystuff.properties");
              

               

              I have also written a VFS3 based filesystem that uses ShrinkWrap archives for a backing.  This allows you to take an archive an mount it into the VFS wherever you like.  Once mounted you can simply deploy the VirtualFile pointing to the mounted FileSystem.

               

              JavaArchive archive = ...
              
              VirtualFile archiveFile = VFS.getChild("/vfs/path").getChild(archive.getName());
              VFS.mount(archiveFile, new ArchiveFileSystem(archive, tempDir));
              
              deploy(archiveFile);
              

               

               

               

              I need to work with Andrew to figure out where the ArchiveFileSystem should live long term, but I do think this is the best long term testing strategy for creation of test archives.  Since we are suggesting ShrinkWrap be used for customers to test through embedded, it would be a good idea to do the same where possible.  This will also reduce the number of competing implementations of the same functionality.

              • 4. Re: How to migrate AssembledDirectory

                johnbailey wrote:

                 

                A better long-term approach would be to move to using ShrinkWrap archives to declaratively create ear/war/jar archives.  ShrinkWrap already has fluent API to add classes/resources to an archive.

                 

                Not for these tests. We don't want to create an archive, although Thomas has already found a tool for doing that for OSGi called "bnd".

                 

                For these tests, we want to pass the metadata objects in explicitly (via the predetermined attachments on the deployment)

                rather than having them parsed from xml.

                 

                e.g. for testing all the different permutations of OSGi metadata

                we use an "AssembledDirectory" that filters the specified packages in the classpath and then

                we create many different OSGiMetaData objects with slight tweaks to different parameters.

                 

                Any other way would require hundreds of manifest files and slow down the tests as you have to construct the jars.

                • 5. Re: How to migrate AssembledDirectory
                  johnbailey

                  Ahh.  I should have looked deeper into the tests.  I can help out moving the tests to use the VirtualFileAssembly.

                  • 6. Re: How to migrate AssembledDirectory
                    thomas.diesler

                    I don't think we can simply migrate the framework to jboss-vfs-3.0.x

                     

                    http://community.jboss.org/thread/148932?tstart=0

                     

                    Instead, the framework testsuite should be agnostic of the actual vfs implemtation. At the end of the day I want to assemble bundles, either by a tool (e.g. bnd) or dynamically and use the standard OSGi API to install them into the framework.