@Service public class DefaultFileManager extends Object implements FileManager, org.springframework.roo.file.undo.UndoListener
FileManager.| Constructor and Description |
|---|
DefaultFileManager() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
activate(org.osgi.service.component.ComponentContext context) |
void |
clear()
Discards proposed changes to the disk that an implementation may have
elected to defer.
|
void |
commit()
Commits actual changes to the disk that an implementation may have
elected to defer.
|
org.springframework.roo.file.monitor.event.FileDetails |
createDirectory(String fileIdentifier)
Attempts to create a new directory on the disk.
|
MutableFile |
createFile(String fileIdentifier)
Attempts to create a zero-byte file on the disk.
|
void |
createOrUpdateTextFileIfRequired(String fileIdentifier,
String newContents,
boolean writeImmediately)
Provides a simple way to create or update a file, skipping any
modification if the file's contents match the proposed contents.
|
void |
createOrUpdateTextFileIfRequired(String fileIdentifier,
String newContents,
String descriptionOfChange,
boolean writeImmediately)
Provides a simple way to create or update a file, skipping any
modification if the file's contents match the proposed contents.
|
protected void |
deactivate(org.osgi.service.component.ComponentContext context) |
void |
delete(String fileIdentifier)
Attempts to delete a file or directory on the disk.
|
void |
delete(String fileIdentifier,
String reasonForDeletion)
Attempts to delete a file or directory on the disk.
|
boolean |
exists(String fileIdentifier)
Indicates whether the file identified by the passed canonical path
exists.
|
SortedSet<org.springframework.roo.file.monitor.event.FileDetails> |
findMatchingAntPath(String antPath)
Delegates to
FileMonitorService.findMatchingAntPath(String). |
org.springframework.roo.file.monitor.NotifiableFileMonitorService |
getFileMonitorService() |
org.springframework.roo.file.undo.FilenameResolver |
getFileNameResolver() |
InputStream |
getInputStream(String fileIdentifier)
Obtains an input stream for the indicated file identifier, which must be
a file (not a directory) and must exist at the time the method is called.
|
ProcessManager |
getProcessManager() |
org.springframework.roo.file.undo.UndoManager |
getUndoManager() |
void |
onUndoEvent(org.springframework.roo.file.undo.UndoEvent event) |
org.springframework.roo.file.monitor.event.FileDetails |
readFile(String fileIdentifier)
Obtains an already-existing file for reading.
|
int |
scan()
Delegates to
FileMonitorService.scanAll() or
NotifiableFileMonitorService.scanNotified() if available. |
MutableFile |
updateFile(String fileIdentifier)
Provides an updatable representation of a file on the disk.
|
protected static final Logger LOGGER
protected void activate(org.osgi.service.component.ComponentContext context)
public void clear()
FileManagerclear in interface FileManagerpublic void commit()
FileManagercommit in interface FileManagerpublic org.springframework.roo.file.monitor.event.FileDetails createDirectory(String fileIdentifier)
FileManagerThe requested file identifier path must not already exist. It should be in canonical file name format.
Parent directories must also be created automatically by this method. Any created parent directories should be removed as part of the undo behaviour.
An exception will be thrown if the path already exists.
createDirectory in interface FileManagerfileIdentifier - a path to be created that does not already exist
(required)public MutableFile createFile(String fileIdentifier)
FileManagerThe requested fileIdentifier path must not already exist. It should be in canonical file name format.
Implementations guarantee to FileManager.createDirectory(String) as required
to create any required parent directories.
An exception will be thrown if the path already exists.
createFile in interface FileManagerfileIdentifier - a path to be created that does not already exist
(required)public void createOrUpdateTextFileIfRequired(String fileIdentifier, String newContents, boolean writeImmediately)
FileManagerThis mechanism also automatically deletes an unwanted file if the new contents are zero bytes. If deleting, the existence of the file need not be considered in advance (it will only delete if the file is present, but it will not fail if the file does not exist or has been separately deleted).
Implementations guarantee to FileManager.createDirectory(String) as required
to create any required parent directories.
Implementations are required to observe the FileManager.commit() and
FileManager.clear() semantics defined in the type-level JavaDocs.
createOrUpdateTextFileIfRequired in interface FileManagerfileIdentifier - the file to create or update as appropriate
(required)newContents - the replacement contents (required, but can be zero
bytes if the file should be deleted)writeImmediately - forces immediate write of the file to disk (false
means it can be deferred, as recommended)public void createOrUpdateTextFileIfRequired(String fileIdentifier, String newContents, String descriptionOfChange, boolean writeImmediately)
FileManagerThis mechanism also automatically deletes an unwanted file if the new contents are zero bytes. If deleting, the existence of the file need not be considered in advance (it will only delete if the file is present, but it will not fail if the file does not exist or has been separately deleted).
Implementations guarantee to FileManager.createDirectory(String) as required
to create any required parent directories.
Implementations are required to observe the FileManager.commit() and
FileManager.clear() semantics defined in the type-level JavaDocs.
createOrUpdateTextFileIfRequired in interface FileManagerfileIdentifier - the file to create or update as appropriate
(required)newContents - the replacement contents (required, but can be zero
bytes if the file should be deleted)descriptionOfChange - the additional information about a change (can
be null)writeImmediately - forces immediate write of the file to disk (false
means it can be deferred, as recommended)protected void deactivate(org.osgi.service.component.ComponentContext context)
public void delete(String fileIdentifier)
FileManagerIf the path refers to a directory, contents of the directory will be recursively deleted.
If a delete fails, an exception will be thrown.
delete in interface FileManagerfileIdentifier - the file to delete; can be blank to do nothing, otherwise
should be a valid pathname as per
File.File(String)public void delete(String fileIdentifier, String reasonForDeletion)
FileManagerIf the path refers to a directory, contents of the directory will be recursively deleted.
If a delete fails, an exception will be thrown.
delete in interface FileManagerfileIdentifier - the file to delete; can be blank to do nothing, otherwise
should be a valid pathname as per
File.File(String)reasonForDeletion - the reason why the file is being deleted (can be
blank)public boolean exists(String fileIdentifier)
FileManagerexists in interface FileManagerfileIdentifier - the file or directory to locate (required, in
canonical path format)public SortedSet<org.springframework.roo.file.monitor.event.FileDetails> findMatchingAntPath(String antPath)
FileManagerFileMonitorService.findMatchingAntPath(String).findMatchingAntPath in interface FileManagerantPath - the Ant path to evaluate, as per the canonical file path
format (required)public InputStream getInputStream(String fileIdentifier)
FileManagerFileManager.getInputStream in interface FileManagerfileIdentifier - the file to read (required, in canonical path
format)public void onUndoEvent(org.springframework.roo.file.undo.UndoEvent event)
onUndoEvent in interface org.springframework.roo.file.undo.UndoListenerpublic org.springframework.roo.file.monitor.event.FileDetails readFile(String fileIdentifier)
FileManagerreadFile in interface FileManagerfileIdentifier - the file to read that already exists (required)public int scan()
FileManagerFileMonitorService.scanAll() or
NotifiableFileMonitorService.scanNotified() if available.scan in interface FileManagerpublic MutableFile updateFile(String fileIdentifier)
FileManagerThe file identifier must refer to a file (not directory) that already exists. A violation of this requirement will result in an exception. The identifier should be in canonical file name format.
Refer to the documentation for MutableFile for important
restrictions on usage.
updateFile in interface FileManagerfileIdentifier - the file to update (must be a file that already
exists, required)public org.springframework.roo.file.monitor.NotifiableFileMonitorService getFileMonitorService()
public ProcessManager getProcessManager()
public org.springframework.roo.file.undo.FilenameResolver getFileNameResolver()
public org.springframework.roo.file.undo.UndoManager getUndoManager()
Copyright © 2009–2016. All rights reserved.