Package org.jboss.vfs
Class TempFileProvider
java.lang.Object
org.jboss.vfs.TempFileProvider
- All Implemented Interfaces:
Closeable
,AutoCloseable
A provider for temporary physical files and directories.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ScheduledExecutorService
private static final String
private static final String
private final AtomicBoolean
private final File
private static final int
private static final Random
private static final File
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
TempFileProvider
(File providerRoot, ScheduledExecutorService executor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this provider and delete any temp files associated with it.static TempFileProvider
create
(String providerType, ScheduledExecutorService executor) Create a temporary file provider for a given type.static TempFileProvider
create
(String providerType, ScheduledExecutorService executor, boolean cleanExisting) Create a temporary file provider for a given type.createTempDir
(String originalName) Create a temp directory, into which temporary files may be placed.private static File
createTempDir
(String prefix, String suffix, File root) (package private) static String
createTempName
(String prefix, String suffix) (package private) void
Deletes any temp files associated with this providerprotected void
finalize()
(package private) File
-
Field Details
-
JBOSS_TMP_DIR_PROPERTY
- See Also:
-
JVM_TMP_DIR_PROPERTY
- See Also:
-
TMP_ROOT
-
RETRIES
private static final int RETRIES- See Also:
-
open
-
providerRoot
-
executor
-
rng
-
-
Constructor Details
-
TempFileProvider
-
-
Method Details
-
create
public static TempFileProvider create(String providerType, ScheduledExecutorService executor) throws IOException Create a temporary file provider for a given type. This is the same as callingcreate(final String providerType, final ScheduledExecutorService executor, false)
- Parameters:
providerType
- the provider type string (used as a prefix in the temp file dir name)executor
- the executor- Returns:
- the new provider
- Throws:
IOException
- if an I/O error occurs
-
create
public static TempFileProvider create(String providerType, ScheduledExecutorService executor, boolean cleanExisting) throws IOException Create a temporary file provider for a given type.- Parameters:
providerType
- The provider type string (used as a prefix in the temp file dir name)executor
- Executor which will be used to manage temp file provider tasks (like cleaning up/deleting the temp files when needed)cleanExisting
- If this is true, then this method will *try* to delete the existing temp content (if any) for theproviderType
. The attempt to delete the existing content (if any) will be done in the background and this method will not wait for the deletion to complete. The method will immediately return back with a usableTempFileProvider
. Note that thecleanExisting
will just act as a hint for this method to trigger the deletion of existing content. The method may not always be able to delete the existing contents.- Returns:
- The new provider
- Throws:
IOException
- if an I/O error occurs
-
getProviderRoot
File getProviderRoot() -
createTempDir
Create a temp directory, into which temporary files may be placed.- Parameters:
originalName
- the original file name- Returns:
- the temp directory
- Throws:
IOException
- for any error
-
createTempDir
- Throws:
IOException
-
createTempName
-
close
Close this provider and delete any temp files associated with it.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
finalize
protected void finalize() -
delete
Deletes any temp files associated with this provider- Throws:
IOException
-