Class DefaultFileReplicator
java.lang.Object
org.apache.commons.vfs.provider.AbstractVfsComponent
org.apache.commons.vfs.impl.DefaultFileReplicator
- All Implemented Interfaces:
FileReplicator, TemporaryFileStore, VfsComponent
public class DefaultFileReplicator
extends AbstractVfsComponent
implements FileReplicator, TemporaryFileStore
A simple file replicator and temporary file store.
- Version:
- $Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Wed, 29 Nov 2006) $
- Author:
- Adam Murdoch
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultFileReplicator(File tempDir) constructor to set the location of the temporary directory -
Method Summary
Modifier and TypeMethodDescriptionprotected voidallocateFile(String baseName) Allocates a new temporary file.voidclose()Closes the replicator, deleting all temporary files.protected FilecreateAndAddFile(File parent, String basename) protected FilecreateFile(File parent, String name) create the temporary fileprotected StringcreateFilename(String baseName) create the temporary file nameprotected voiddeleteFile(File file) physically deletes the file from the filesystemprotected longvoidinit()Initialises this component.protected Objectremoves a file from the copies list.protected voidremoveFile(Object file) removes a instance from the list of copiesreplicateFile(FileObject srcFile, FileSelector selector) Creates a local copy of the file, and all its descendents.Methods inherited from class AbstractVfsComponent
getContext, getLogger, setContext, setLogger
-
Constructor Details
-
DefaultFileReplicator
constructor to set the location of the temporary directory- Parameters:
tempDir-
-
DefaultFileReplicator
public DefaultFileReplicator()
-
-
Method Details
-
init
Initialises this component.- Specified by:
initin interfaceVfsComponent- Overrides:
initin classAbstractVfsComponent- Throws:
FileSystemException
-
close
public void close()Closes the replicator, deleting all temporary files.- Specified by:
closein interfaceVfsComponent- Overrides:
closein classAbstractVfsComponent
-
deleteFile
physically deletes the file from the filesystem -
removeFile
removes a file from the copies list. Will be used for cleanup.
Notice: The system awaits that the returning object can be cast to a java.io.File -
removeFile
removes a instance from the list of copies -
allocateFile
Allocates a new temporary file.- Specified by:
allocateFilein interfaceTemporaryFileStore- Parameters:
baseName- The name of the file.- Throws:
FileSystemException
-
createAndAddFile
- Throws:
FileSystemException
-
addFile
-
getFilecount
protected long getFilecount() -
createFilename
-
createFile
create the temporary file- Throws:
FileSystemException
-
replicateFile
Creates a local copy of the file, and all its descendents.- Specified by:
replicateFilein interfaceFileReplicator- Parameters:
srcFile- The file to copy.selector- Selects the files to copy.- Returns:
- The local copy of the source file.
- Throws:
FileSystemException- If the source files does not exist, or on error copying.
-