Package org.apache.jackrabbit.util
Class TransientFileFactory
- java.lang.Object
-
- org.apache.jackrabbit.util.TransientFileFactory
-
public class TransientFileFactory extends java.lang.Object
TheTransientFileFactory
utility class can be used to create transient files, i.e. temporary files that are automatically removed once the associatedFile
object is reclaimed by the garbage collector.File deletion is handled by a low-priority background thread.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.File
createTransientFile(java.lang.String prefix, java.lang.String suffix, java.io.File directory)
Same asFile.createTempFile(String, String, File)
except that the newly-created file will be automatically deleted once the returnedFile
object has been gc'ed.static TransientFileFactory
getInstance()
Returns the singletonTransientFileFactory
instance.static void
shutdown()
Shuts this factory down removing all temp files and removes shutdown hook.
-
-
-
Method Detail
-
getInstance
public static TransientFileFactory getInstance()
Returns the singletonTransientFileFactory
instance.
-
createTransientFile
public java.io.File createTransientFile(java.lang.String prefix, java.lang.String suffix, java.io.File directory) throws java.io.IOException
Same asFile.createTempFile(String, String, File)
except that the newly-created file will be automatically deleted once the returnedFile
object has been gc'ed.- Parameters:
prefix
- The prefix string to be used in generating the file's name; must be at least three characters longsuffix
- The suffix string to be used in generating the file's name; may benull
, in which case the suffix".tmp"
will be useddirectory
- The directory in which the file is to be created, ornull
if the default temporary-file directory is to be used- Returns:
- the newly-created empty file
- Throws:
java.io.IOException
- If a file could not be created
-
shutdown
public static void shutdown()
Shuts this factory down removing all temp files and removes shutdown hook.Warning!!!
This should be called by a web-application IF it is unloaded AND IF jackrabbit-jcr-commons.jar had been loaded by the webapp classloader. This must be called after all repositories had been stopped, so use with great care!
See http://issues.apache.org/jira/browse/JCR-1636 for details.
-
-