4 Replies Latest reply on Oct 19, 2009 9:57 AM by dmlloyd

    Missing VirtualFile::isFile?

    alesj

      What was the reason again the we don't have VirtualFile::isFile method?

      OK, VirtualFile::isLeaf makes complete sense,
      as you would like to diff jars vs. plain files.

      But having VirtualFile::isFile would be useful.
      My use case would be 'hasBeenModified' / hot deployment,
      where in the case of (isFile == true) I wouldn't go into
      the file even though it would be 'isLeaf == false' (the file is a jar).

      Or is true/false isFile too narrow for other types of VirtualFileHandler.
      e.g. Memort, Assembled, ...
      And would getType make a better fit?
      e.g. FILE, DIRECTORY, NONE, ...

        • 1. Re: Missing VirtualFile::isFile?
          starksm64

          The reasoning was that it was too much of a file system notion that did not have a useful meaning in general while isLeaf does. Why would hotdeployment not check a jar when it would check the corresponding unpacked form of the jar as a directory?

          The thing we did consider was an isArchive notion for a compressed directory.

          • 2. Re: Missing VirtualFile::isFile?
            alesj

             

            "scott.stark@jboss.org" wrote:
            The reasoning was that it was too much of a file system notion that did not have a useful meaning in general while isLeaf does.

            Sure.
            But I'm saying that only isLeaf is not enough.
            See the usage in next paragraph.

            "scott.stark@jboss.org" wrote:
            Why would hotdeployment not check a jar when it would check the corresponding unpacked form of the jar as a directory?

            I'm not saying you wouldn't check it.

            There is just no need to go and check the META-INF/*.xml changes,
            since the change would already reflect on the root's lastModifiedTime.
            But in order to know not to go 'in', is the isFile/isArchive directive.

            "scott.stark@jboss.org" wrote:

            The thing we did consider was an isArchive notion for a compressed directory.

            JarHandler/ZipContextHandler::isArchive==true, everybody else == false?

            • 3. Re: Missing VirtualFile::isFile?
              starksm64

               

              "alesj" wrote:

              JarHandler/ZipContextHandler::isArchive==true, everybody else == false?

              Yes, but there could be other archive schemes in the future like tar.

              • 4. Re: Missing VirtualFile::isFile?
                dmlloyd

                In VFS3, VFS doesn't know (or care) if a file is an archive, unless a deployer has mounted it. VFS3's "isLeaf()" is deprecated and just returns "! isDirectory()". However, isDirectory() only returns true if the entry is known to be a directory; a false value might mean that yes it's a directory but it's not accessible for some reason (permissions etc.). So I think I will add an isFile() method and make isLeaf() call that instead... or maybe simply remove isLeaf() altogether.

                A getType() would be the best API of all, but Java gives us no way to guarantee we have the right answer in a consistent and race-free manner. Maybe with JDK7...