Class FileSystemResourcesController
- java.lang.Object
-
- com.microej.kf.util.control.fs.FileSystemResourcesController
-
public class FileSystemResourcesController extends java.lang.ObjectThe file system resources controller.It controls the numbers of opened files, the storage size and the file system bandwidth. By default, there are no limits on the file system usage.
When an application tries to perform a file system operation (open/read/write), the controller checks if a file system limit setting is defined for the application and denies the operation if its execution will lead to exceeding one of the limits.
It also notifies the registered listeners when an operation is denied or when a limit is reached.
-
-
Constructor Summary
Constructors Constructor Description FileSystemResourcesController(ej.kf.Module module)Creates an instance of the File System controller.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetMaxOpenedFiles()longgetMaxStorageSize()java.io.File[]getOpenedFiles()Returns the current opened files.longgetStorageSize()Returns the current storage size.voidonEnd(SandboxedModule module, CloseFile closeFile, boolean withSuccess)Called when the execution of the given close file action is finished.voidonEnd(SandboxedModule module, DeleteFile deleteFile, boolean withSuccess)Called when the execution of the given delete file action is finished.voidonEnd(SandboxedModule module, OpenFile openFile, boolean withSuccess)Called when the execution of the given open file action is finished.voidonEnd(SandboxedModule module, SetLengthRandomAccessFile setLengthFile, boolean withSuccess)Called when the execution of the given write file action is finished.voidonEnd(SandboxedModule module, WriteFile writeFile, boolean withSuccess)Called when the execution of the given write file action is finished.voidonEnd(SandboxedModule module, WriteRandomAccessFile writeFile, boolean withSuccess)Called when the execution of the given write file action is finished.voidonStart(SandboxedModule module, CloseFile closeFile)Called when the execution of the close file action is about to start.voidonStart(SandboxedModule module, DeleteFile deleteFile)Called when the execution of the delete file action is about to start.voidonStart(SandboxedModule module, OpenFile openFile)Called when the execution of the open file action is about to start.voidonStart(SandboxedModule module, SetLengthRandomAccessFile setLengthFile)Called when the execution of the write file action is about to start.voidonStart(SandboxedModule module, WriteFile writeFile)Called when the execution of the write file action is about to start.voidonStart(SandboxedModule module, WriteRandomAccessFile writeFile)Called when the execution of the write file action is about to start.voidreset()Resets the controller.voidsetMaxOpenedFiles(int maxOpenFiles)Sets the maximum number of files allowed to be opened.voidsetMaxStorageSize(long maxStorageSize)Sets the maximum file system storage size (in bytes) allowed.
-
-
-
Method Detail
-
reset
public void reset()
Resets the controller.
-
onStart
public void onStart(SandboxedModule module, OpenFile openFile) throws java.lang.SecurityException
Called when the execution of the open file action is about to start.It checks if the action is allowed to be executed.
- Parameters:
module- the module which performs the action.openFile- the open file action.- Throws:
java.lang.SecurityException- if the action is not allowed to be performed.
-
onEnd
public void onEnd(SandboxedModule module, OpenFile openFile, boolean withSuccess)
Called when the execution of the given open file action is finished.- Parameters:
module- the module which performs the given open file action.openFile- the open file action.withSuccess- true if the execution of the action was ended with success; false otherwise.
-
onStart
public void onStart(SandboxedModule module, CloseFile closeFile) throws java.lang.SecurityException
Called when the execution of the close file action is about to start.It checks if the action is allowed to be executed.
- Parameters:
module- the module which performs the action.closeFile- the close file action.- Throws:
java.lang.SecurityException- if the action is not allowed to be performed.
-
onEnd
public void onEnd(SandboxedModule module, CloseFile closeFile, boolean withSuccess)
Called when the execution of the given close file action is finished.- Parameters:
module- the application which performs the given close file action.closeFile- the close file action.withSuccess- true if the execution of the action was ended with success; false otherwise.
-
onStart
public void onStart(SandboxedModule module, WriteFile writeFile) throws java.lang.SecurityException
Called when the execution of the write file action is about to start.It checks if the action is allowed to be executed and throttles (delays) it if needed.
- Parameters:
module- the module which performs the write file action.writeFile- the write file action.- Throws:
java.lang.SecurityException- if the action is not allowed to be performed.
-
onEnd
public void onEnd(SandboxedModule module, WriteFile writeFile, boolean withSuccess)
Called when the execution of the given write file action is finished.- Parameters:
module- the module which performs the given write file action.writeFile- the write file action.withSuccess- true if the execution of the action was ended with success; false otherwise.
-
onStart
public void onStart(SandboxedModule module, SetLengthRandomAccessFile setLengthFile) throws java.lang.SecurityException
Called when the execution of the write file action is about to start.It checks if the action is allowed to be executed and throttles (delays) it if needed.
- Parameters:
module- the module which performs the write file action.setLengthFile- the write file action.- Throws:
java.lang.SecurityException- if the action is not allowed to be performed.
-
onEnd
public void onEnd(SandboxedModule module, SetLengthRandomAccessFile setLengthFile, boolean withSuccess)
Called when the execution of the given write file action is finished.- Parameters:
module- the module which performs the given write file action.setLengthFile- the write file action.withSuccess- true if the execution of the action was ended with success; false otherwise.
-
onStart
public void onStart(SandboxedModule module, WriteRandomAccessFile writeFile) throws java.lang.SecurityException
Called when the execution of the write file action is about to start.It checks if the action is allowed to be executed and throttles (delays) it if needed.
- Parameters:
module- the module which performs the write file action.writeFile- the write file action.- Throws:
java.lang.SecurityException- if the action is not allowed to be performed.
-
onEnd
public void onEnd(SandboxedModule module, WriteRandomAccessFile writeFile, boolean withSuccess)
Called when the execution of the given write file action is finished.- Parameters:
module- the module which performs the given write file action.writeFile- the write file action.withSuccess- true if the execution of the action was ended with success; false otherwise.
-
onStart
public void onStart(SandboxedModule module, DeleteFile deleteFile) throws java.lang.SecurityException
Called when the execution of the delete file action is about to start.It checks if the action is allowed to be executed.
- Parameters:
module- the module which performs the delete file actiondeleteFile- the delete file action- Throws:
java.lang.SecurityException- if the action is not allowed to be performed.
-
onEnd
public void onEnd(SandboxedModule module, DeleteFile deleteFile, boolean withSuccess)
Called when the execution of the given delete file action is finished.- Parameters:
module- the module which performs the given delete file action.deleteFile- the delete file action.withSuccess- true if the execution of the action was ended with success; false otherwise.
-
setMaxStorageSize
public void setMaxStorageSize(long maxStorageSize)
Sets the maximum file system storage size (in bytes) allowed.- Parameters:
maxStorageSize- the maximum file system storage size. A negative value means there is no limit.
-
setMaxOpenedFiles
public void setMaxOpenedFiles(int maxOpenFiles)
Sets the maximum number of files allowed to be opened.- Parameters:
maxOpenFiles- the maximum number of files allowed to be opened. A negative value means there is no limit.
-
getStorageSize
public long getStorageSize()
Returns the current storage size.- Returns:
- the current storage size.
-
getOpenedFiles
public java.io.File[] getOpenedFiles()
Returns the current opened files.- Returns:
- the current opened files.
-
getMaxStorageSize
public long getMaxStorageSize()
- Returns:
- the maximum storage size in bytes. A negative value means there is no limit.
-
getMaxOpenedFiles
public int getMaxOpenedFiles()
- Returns:
- the maximum number of files allowed to be opened. A negative value means there is no limit.
-
-