Class TempFileCache

  • public class TempFileCache
    extends Object
    • Constructor Detail

      • TempFileCache

        public TempFileCache()
        Create the getTempDir()
    • Method Detail

      • initSingleton

        public static boolean initSingleton()
        Documented way to kick off static initialization
        true is static initialization was successful
      • destroy

        public void destroy()
        Delete the getTempDir() recursively and remove it's reference.
      • isValid

        public boolean isValid​(boolean forExecutables)
        forExecutables - if true, method also tests whether the underlying getBaseDir() is suitable to load native libraries or launch executables
        true if static and object initialization was successful
        See Also:
        #isTempExecutable(), #isValid()
      • getBaseDir

        public static File getBaseDir()
        Base temp directory used by TempFileCache.

        Lifecycle: For one user's concurrently running JVMs and ClassLoader

        This is set to:
      • getRootDir

        public static File getRootDir()
        Root temp directory for this JVM instance. Used to store individual directories.

        This directory is a sub-folder to getBaseDir().

        Lifecycle: For one user's concurrently running JVMs and ClassLoader


        Use Case: Per ClassLoader files, eg. native libraries.

        Old temp directories are cleaned up the next time a JVM is launched that uses TempFileCache.

      • getTempDir

        public File getTempDir()
        Temporary directory for individual files (eg. native libraries of one ClassLoader instance).

        This directory is a sub-folder to getRootDir().

        Lifecycle: Within each JVM .. use case dependent, ie. per ClassLoader and per TempFileCache instance!

        The directory name is:

        where jlnMMMMM is the unique filename created by File.createTempFile() without the ".tmp" extension.