public final class TempFileProvider
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
TempFileProvider.DeleteTask |
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.ScheduledExecutorService |
executor |
private static java.lang.String |
JBOSS_TMP_DIR_PROPERTY |
private static java.lang.String |
JVM_TMP_DIR_PROPERTY |
private java.util.concurrent.atomic.AtomicBoolean |
open |
private java.io.File |
providerRoot |
private static int |
RETRIES |
private static java.util.Random |
rng |
private static java.io.File |
TMP_ROOT |
| Modifier | Constructor and Description |
|---|---|
private |
TempFileProvider(java.io.File providerRoot,
java.util.concurrent.ScheduledExecutorService executor) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close this provider and delete any temp files associated with it.
|
static TempFileProvider |
create(java.lang.String providerType,
java.util.concurrent.ScheduledExecutorService executor)
Create a temporary file provider for a given type.
|
static TempFileProvider |
create(java.lang.String providerType,
java.util.concurrent.ScheduledExecutorService executor,
boolean cleanExisting)
Create a temporary file provider for a given type.
|
TempDir |
createTempDir(java.lang.String originalName)
Create a temp directory, into which temporary files may be placed.
|
private static java.io.File |
createTempDir(java.lang.String prefix,
java.lang.String suffix,
java.io.File root) |
(package private) static java.lang.String |
createTempName(java.lang.String prefix,
java.lang.String suffix) |
(package private) void |
delete(java.io.File root)
Deletes any temp files associated with this provider
|
protected void |
finalize() |
(package private) java.io.File |
getProviderRoot() |
private static final java.lang.String JBOSS_TMP_DIR_PROPERTY
private static final java.lang.String JVM_TMP_DIR_PROPERTY
private static final java.io.File TMP_ROOT
private static final int RETRIES
private final java.util.concurrent.atomic.AtomicBoolean open
private final java.io.File providerRoot
private final java.util.concurrent.ScheduledExecutorService executor
private static final java.util.Random rng
private TempFileProvider(java.io.File providerRoot,
java.util.concurrent.ScheduledExecutorService executor)
public static TempFileProvider create(java.lang.String providerType, java.util.concurrent.ScheduledExecutorService executor) throws java.io.IOException
create(final String providerType, final ScheduledExecutorService executor, false)providerType - the provider type string (used as a prefix in the temp file dir name)executor - the executorjava.io.IOException - if an I/O error occurspublic static TempFileProvider create(java.lang.String providerType, java.util.concurrent.ScheduledExecutorService executor, boolean cleanExisting) throws java.io.IOException
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 the providerType. 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 usable TempFileProvider. Note that the
cleanExisting 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.java.io.IOException - if an I/O error occursjava.io.File getProviderRoot()
public TempDir createTempDir(java.lang.String originalName) throws java.io.IOException
originalName - the original file namejava.io.IOException - for any errorprivate static java.io.File createTempDir(java.lang.String prefix,
java.lang.String suffix,
java.io.File root)
throws java.io.IOException
java.io.IOExceptionstatic java.lang.String createTempName(java.lang.String prefix,
java.lang.String suffix)
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionprotected void finalize()
finalize in class java.lang.Objectvoid delete(java.io.File root)
throws java.io.IOException
java.io.IOException