This series Article Navigation
Apache VFS (1): Basic Introduction
Apache VFS (2): file monitoring and monitoring
Apache VFS (3): file filter and Selector
Apache VFS (4): Events
Apache VFS (5): use it!
Apache VFS (6): several important conceptual Interfaces
Apache VFS (7): File Manager File Parsing Method
It is very important to understand the conceptual interfaces of Apache VFS, because there are too few examples of Apache VFS. If you do not study them carefully, it is not clear to them:
Vfscomponent Interface
This interface is called to manage the lifecycle of all VFS components. The method is relatively simple:
- Init is used to initialize components.
- Close is used to close components.
- Setcontext (vfscomponentcontext CTX) settingsComponent Context
, Note that it maintainsComponent context: vfscomponentcontext
- Setlogger
An abstract class implements this interface.Abstractvfscomponent
Abstract class. This abstract class adds the getcontext () method to obtain the component context. The abstractvfscomponent abstract class is very important. There are several important classes that inherit it:
- Abstractfilescache
- Abstractfilesystem
- Abstractvfscontainer
- Defaultfilereplicator
Vfscomponentcontext Interface
This interface allows VFS components to access the services they need, such
Filereplicator Interface
The task of this interface is to create a local copy of the file. Only one methodReplicatefile (fileobject SRC, fileselector SEL)
, Returns a file object. There are two classes to implement this interface:
- Defaultfilereplicator is a simple file replicaset and temporary file warehouse. It also implements the filereplicator interface, temporaryfilestore interface, and vfscomponent interface.
- Priviledgedfilereplicator is the packaging class of a file replicaset that accepts a file replicaset as a parameter. This packaging class can execute certain actions that require Permissions
Temporaryfilestore Interface
This interface is used to manage the local temporary file warehouse. There is only one implementation class, that is, the defaultfilereplicator class. There is only one method
Allocatefile (string basename)
Accepts a string and returns a file object. This method will allocate a temporary file. When the Warehouse is closed, the temporary file and all the sub-files will be deleted.
Fileprovider Interface
Each fileprovider file provider is responsible for processing special types of Uri modes, such as FTP and HTTP.
Source: http://alartin.javaeye.com/blog/92412