+ 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. +
++ XXX no answer for arch-quality +
++ XXX no answer for arch-time +
++ 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 { + public LoginFileSystem() { + // let's create the filesystem empty, because the user + // is not yet logged in + super(new FileSystem[0]); + } + + public static void assignURL(URL u) { + LoginFileSystem lfs = Lookup.getDefault().lookup(LoginFileSystem.class); + XMLFileSystem xmlFS = new XMLFileSystem(u); + lfs.setDelegates(new FileSystem[] { xmlFS }); + } +} ++ +
+ It is necessary to register this instance in lookup by creating two files: +
+META-INF/services/org.openide.filesystems.FileSystem
META-INF/services/your.module.LoginFileSystem
+ and filling these files 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. +
++ XXX no answer for compat-deprecation +
++ XXX no answer for deploy-dependencies +
++ XXX no answer for exec-ant-tasks +
++ XXX no answer for exec-threading +
++ XXX no answer for perf-spi +
++ XXX no answer for resources-preferences +
++ XXX no answer for security-grant +
++ XXX no answer for security-policy +
++ Repository.getDefaultFileSystem's content can now be + influenced by adding own + FileSystems + into global + Lookup.getDefault(). + This is supposed to work in a standalone mode as well + as inside NetBeans Platform. The tutorial is available + in the usecases section of achitecture description. +
+FileUtil.createData
Index: openide/fs/manifest.mf
===================================================================
RCS file: /shared/data/ccvs/repository/openide/fs/manifest.mf,v
retrieving revision 1.8
diff -u -r1.8 manifest.mf
--- openide/fs/manifest.mf 31 May 2006 15:42:10 -0000 1.8
+++ openide/fs/manifest.mf 7 Mar 2007 16:33:11 -0000
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
OpenIDE-Module: org.openide.filesystems
-OpenIDE-Module-Specification-Version: 7.0
+OpenIDE-Module-Specification-Version: 7.1
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
Index: openide/fs/src/org/openide/filesystems/ExternalUtil.java
===================================================================
RCS file: /shared/data/ccvs/repository/openide/fs/src/org/openide/filesystems/ExternalUtil.java,v
retrieving revision 1.7
diff -u -r1.7 ExternalUtil.java
--- openide/fs/src/org/openide/filesystems/ExternalUtil.java 28 Oct 2006 21:57:38 -0000 1.7
+++ openide/fs/src/org/openide/filesystems/ExternalUtil.java 7 Mar 2007 16:33:11 -0000
@@ -18,10 +18,14 @@
*/
package org.openide.filesystems;
+import java.util.ArrayList;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
+import org.openide.util.LookupEvent;
+import org.openide.util.LookupListener;
/** Contains utility methods to deal with repository and error manager,
@@ -120,7 +124,30 @@
if (repository == null) {
// if not provided use default one
- repository = new Repository(FileUtil.createMemoryFileSystem());
+ repository = new Repository(new MainFS());
}
}
+
+ private static final class MainFS extends MultiFileSystem implements LookupListener {
+ private static final Lookup.Result