FileSystem component provides a set of operations that are performed on files, directories and abstract pathnames, including: file reading, writing (streams, byte[], String), random access (read, write, rewinding), atomic creation, deletion and renaming; directory creation, deletion, renaming and listings; path name normalisation and basename / directory name splitting and creation of java.net.URL objects that can be used to access the component's functionality.
The biggest strength of this component is that it's functionality is delegated to one or more providers that are specific to particural kind of storage media. The providers are accessed in order of registration, and the first one that has the requested file or directory performs the operation. For consistency reasons it is recommended that only the first registered provider is write-enabled.
These are the two typical setups of the component:
LocalFileSystemProvider, ClasspathFileSystemProviderLocalFileSystemProvider, ServletFileSystemProvider,
ClasspathFileSystemProviderThe first setup is used in command line applications. It allows them to write logs and teporary files to the local disk, and read their configuration data from the jar files. The user may override the configuration settings present in the jar files by copying relevant files out of the jar onto the disk and modyfiing them as necessary.
The second setup is used in web applications (the ServletFileSystemProvideris hosted in ObjectLedge web module). A web application is typically composed of a number of jar files. A jar file with application components can contain configuration files with factory default settings. The Application Assembler (as defined by J2EE) extracts configuration files that need to be customized and puts them into the war archive. Further, the Application Deployer may extract configuration files from the war archive, and jar archives within, customized them and put them into a directory on the server machine, should deployment time adjustments prove necessary.
LocalFileSystemProvider
This is the basic implementation of the FileSystemProvider interaface
operating over local file system. It supports read and write operations. Stat operations
(size, modification time) and directory listings are reported from actual data.
ClasspathFileSystemProvider
This is an implementation of the FileSystemProvider that delegates it's functionality
to the java.lang.Classloader.getResource(String) calls. Stat operations,
directory existence checking and listings are supported only if there are listing files
available. The ObjectLedge Maven plugin is able to generate these files automatically.
| required components | one or more FileSystemProvider implementations. |
|---|---|
| required libraries | none |
| position | type | descritpion |
|---|---|---|
| 1 | org.objectledge.filesystem.FileSystemProvider[] |
an array of FileSystemProvider components to use |
| 2 | int |
the size of buffers (in bytes) used for reading and writing files. Value between 4k and 64k is recommended. |
| 3 | int |
the maximum size of the file that will be loaded into memory as a single chunk. This is a security intensive setting, setting it too high may make the system vulnerable to a DOS attack. A value between 16k and 1M is recommended, depending on the size of files you need. |