5 Replies Latest reply on Jul 16, 2010 1:45 AM by beve

    MemoryFileFactory in jboss-vfs 3.0.0.CR5

    beve

      Hi,

       

      we've been using org.jboss.virtual.MemoryFileFactory using version 2.1.2.GA of jboss-vfs. I noticed when upgrading to 3.0.0.CR5 that a few package names have changed and corrected them, but I can't seem to find where MemoryFileFactory class has gone.

      Has MemoryFileFactory been deleted in favor of a different class perhaps?

       

      Thanks,

       

      /Daniel

        • 1. Re: MemoryFileFactory in jboss-vfs 3.0.0.CR5
          alesj
          Has MemoryFileFactory been deleted in favor of a different class perhaps?

          Yeah, the in-memory stuff was removed in VFS3.

          See the "port" in our resurrected in-memory deployer:

          * http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java

          • 2. Re: MemoryFileFactory in jboss-vfs 3.0.0.CR5
            beve

            Hi Ales,

             

            thanks for the quick reply!

            I'll check out the in-memory deployer.

             

            Regards,

             

            /Daniel

            • 3. Re: MemoryFileFactory in jboss-vfs 3.0.0.CR5
              beve

              Just wanted to verify my understanding of using the InMemoryClassesDeployer...

               

              The MemoryFileFactory class has been replaced with a InMemoryClassesDeployer which is a deployer targeted at the DESCRIBE stage. What it does is that is mounts a temporary file system (by default in the servers tmp/vfs directory) that other deployments can add things to. In the ESB case, things like a generated servlets class, a wsdl file, and schema files would be added.
              So our deployers we would do somethings like this:
              VirtualFile inMemRootDir = unit.getAttachment(InMemoryClassesDeployer.DYNAMIC_CLASS_KEY, VirtualFile.class);
              VirtualFile wsdlFile = VFS.getChild(inMemRootDir.getPathName() + "/" + serviceInfo.getWSDLFileName());
              final String wsdl = generateWsdl();
              VFSUtils.writeFile(wsdlFile, wsdl.getBytes());
              unit.appendMetaDataLocation(wsdlFile);
              

               

              Is this the intended usage of the InMemoryClassesDeployer?

               

              Now our deployer do not need to do any clean up in their undeploy methods as this is done by the InMemoryClassesDeployer which will remove the filesystem when the deployment is undeployed.

               

              Regards,

               

              /Daniel

              • 4. Re: MemoryFileFactory in jboss-vfs 3.0.0.CR5
                alesj
                The MemoryFileFactory class has been replaced with a InMemoryClassesDeployer which is a deployer targeted at the DESCRIBE stage.

                I wouldn't say replaced, the deployer used to use MFF, but now used different approach,

                with temp file locations, instead of keeping bytes in-memory.

                What it does is that is mounts a temporary file system (by default in the servers tmp/vfs directory) that other deployments can add things to. In the ESB case, things like a generated servlets class, a wsdl file, and schema files would be added.
                So our deployers we would do somethings like this:
                VirtualFile inMemRootDir = unit.getAttachment(InMemoryClassesDeployer.DYNAMIC_CLASS_KEY, VirtualFile.class);
                VirtualFile wsdlFile = VFS.getChild(inMemRootDir.getPathName() + "/" + serviceInfo.getWSDLFileName());
                final String wsdl = generateWsdl();
                VFSUtils.writeFile(wsdlFile, wsdl.getBytes());
                unit.appendMetaDataLocation(wsdlFile);

                Is this the intended usage of the InMemoryClassesDeployer?

                Yes, the IMCD's intent is to create a new temp classpath root.

                 

                VirtualFile wsdlFile = VFS.getChild(inMemRootDir.getPathName() + "/" + serviceInfo.getWSDLFileName());

                --> VirtualFile wsdlFile = inMemoryRootDir.getChild(serviceInfo.getWSDLFileName());

                 

                For "unit::appendMetaDataLocation", you should append file's owner directory, not the file itself.

                Now our deployer do not need to do any clean up in their undeploy methods as this is done by the InMemoryClassesDeployer which will remove the filesystem when the deployment is undeployed.

                Yes.

                • 5. Re: MemoryFileFactory in jboss-vfs 3.0.0.CR5
                  beve

                  Thanks for clarifying and for the code pointers!

                   

                  Regards,

                   

                  /Daniel