|
org.openide.filesystems 7.38.2 | |||||||||
PREV NEXT | FRAMES NO FRAMES |
See:
Description
File System API | |
---|---|
org.openide.filesystems | NetBeans internally uses the concept of a virtual filesystem. |
org.openide.filesystems.annotations | Support for writing annotation processors which generate XML layer fragments. |
NetBeans internally uses the concept of a virtual filesystem. This module provide APIs for accessing such virtual files as well as some support classes to make writing of custom vitual filesystems easier.
MultiFileSystem
overrides
MultiFileSystem
s will now interpret a special
file attribute weight
to determine how to
resolve otherwise ambiguous overrides. For example, in the
system filesystem, module XML layers can use this attribute.
Suppose a generic infrastructure module declares:
<filesystem> <folder name="my-snippets"> <file name="common.xml" url="generic-snippet.xml"/> </folder> </filesystem>
If another module wishes to override this declaration, it can do so by specifying:
<filesystem> <folder name="my-snippets"> <file name="common.xml" url="special-snippet.xml"> <attribute name="weight" intvalue="100"/> </file> </folder> </filesystem>
This override will work even if the module system happens to load the specializing module before the infrastructure module (as could happen if there is no module dependency between them). The weight attribute also makes it clear that something is being overridden.
New variant of addRecursiveListener
method
that allows the caller to control the process enumerating
files in subtree and stop it.
New constructor for JarFileSystem
that initializes everything without opening the underlaying
JAR file.
MIMEResolver.UIHelpers
Several internal methods were added to nested class
of MIMEResolver
- UIHelpers
for use from other parts of the NetBeans Platform. Use from
other modules is not supported.
One can register a recursive listener on a file object by calling FileObject.addRecursiveListener(FileChangeListener).
Many of the usecases are described at the overall documentation, in a way how to register a mime type. Some of the additional usecases are covered here.
Since version 7.1 there is a way to change the content of system file system in a dynamic way. As system file systems contains various definitions (in NetBeans Platform menus, toolbars, layout of windows, etc.) it de-facto allows global change to these settings for example when user logs into some system.
First thing to do is to create an implementation of filesystem. It can be created either from scratch, or by subclassing AbstractFileSystem, or MultiFileSystem. In this example we will subclass the MultiFileSystem:
public class LoginFileSystem extends MultiFileSystem { private static LoginFileSystem INSTANCE; public LoginFileSystem() { // let's create the filesystem empty, because the user // is not yet logged in INSTANCE = this; } public static void assignURL(URL u) throws SAXException { INSTANCE.setDelegates(new XMLFileSystem(u)); } }
It is necessary to register this instance in lookup by creating the file:
META-INF/services/org.openide.filesystems.FileSystem
with a single line containing the full
name of your filesystem - e.g. your.module.LoginFileSystem
.
When done, the system will find out your registration of the filesystem
on startup and will merge the content of the filesystem into the
default system file system. You can show a dialog letting the user
to log in to some system anytime later, and when the user is successfully
in, just call LoginFileSystem.assignURL(url)
where the
URL is an XML file in the same format
as used for regular layer files inside of many NetBeans modules.
The system will notice the change in the content and notify all the
config file listeners accordingly.
Of course, instead of XMLFileSystem you can use for example memory file system, or any other you write yourself.
Since version 7.23 you can use Boolean.TRUE
from call
to fs.getRoot().getAttribute("fallback")
you can place your filesystem behind all layers provided
by standard modules and form a kind of fallback
|
|
|
|
The sources for the module are in the NetBeans Mercurial repositories.
XXX no answer for deploy-dependencies
Read more about the implementation in the answers to architecture questions.
|
org.openide.filesystems 7.38.2 | |||||||||
PREV NEXT | FRAMES NO FRAMES |