diff -r 893c55cd168d core.startup/nbproject/project.xml
--- a/core.startup/nbproject/project.xml Wed Aug 05 06:31:25 2009 +0400
+++ b/core.startup/nbproject/project.xml Wed Aug 05 14:26:46 2009 +0200
@@ -60,7 +60,7 @@
- 7.19
+ 7.23
diff -r 893c55cd168d core.startup/src/org/netbeans/core/startup/layers/ModuleLayeredFileSystem.java
--- a/core.startup/src/org/netbeans/core/startup/layers/ModuleLayeredFileSystem.java Wed Aug 05 06:31:25 2009 +0400
+++ b/core.startup/src/org/netbeans/core/startup/layers/ModuleLayeredFileSystem.java Wed Aug 05 14:26:46 2009 +0200
@@ -137,8 +137,12 @@
List l = new ArrayList(fs2s.length + 2);
l.add(fs1);
if (addLookup) {
- Collection extends FileSystem> fromLookup = result.allInstances();
- l.addAll(fromLookup);
+ for (FileSystem f : result.allInstances()) {
+ if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N
+ continue;
+ }
+ l.add(f);
+ }
}
l.addAll(Arrays.asList(fs2s));
l.add(fs3);
@@ -175,6 +179,13 @@
err.log(Level.WARNING, "Setting layer URLs: " + layerUrls, x);
}
}
+ if (addLookup) {
+ for (FileSystem f : result.allInstances()) {
+ if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N
+ l.add(f);
+ }
+ }
+ }
return l.toArray(new FileSystem[l.size()]);
}
diff -r 893c55cd168d core.startup/test/unit/src/org/netbeans/core/startup/layers/SystemFileSystemTest.java
--- a/core.startup/test/unit/src/org/netbeans/core/startup/layers/SystemFileSystemTest.java Wed Aug 05 06:31:25 2009 +0400
+++ b/core.startup/test/unit/src/org/netbeans/core/startup/layers/SystemFileSystemTest.java Wed Aug 05 14:26:46 2009 +0200
@@ -63,6 +63,7 @@
import org.openide.filesystems.FileRenameEvent;
import org.openide.filesystems.FileSystem;
import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.LocalFileSystem;
import org.openide.modules.ModuleInfo;
import org.openide.util.Lookup;
import org.openide.util.lookup.InstanceContent;
@@ -230,6 +231,63 @@
assertTrue("Still valid", global.isValid());
assertEquals("fileone", read(global));
}
+
+ public void testDynamicSystemsCanAlsoBeBehindLayers() throws Exception {
+ ModuleManager mgr = Main.getModuleSystem ().getManager();
+ mgr.mutexPrivileged().enterWriteAccess();
+ Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
+ FileObject global;
+ try {
+ assertEquals(Collections.EMPTY_SET, m1.getProblems());
+ mgr.enable(m1);
+ global = FileUtil.getConfigFile("foo/file2.txt");
+ assertNotNull("File Object installed: " + global, global);
+ assertEquals("base contents", read(global));
+
+ final LocalFileSystem lfs1 = new LocalFileSystem();
+ File dir1 = new File(getWorkDir(), "dir1");
+ dir1.mkdirs();
+ lfs1.setRootDirectory(dir1);
+ lfs1.getRoot().setAttribute("fallback", Boolean.TRUE);
+ assertEquals("Position attribute is there", -1, lfs1.getRoot().getAttribute("fallback"));
+ fs1 = lfs1;
+
+ FileObject fo1 = FileUtil.createData(fs1.getRoot(), global.getPath());
+ fo1.setAttribute("one", 1);
+ write(fo1, "fileone");
+
+ FileObject fo11 = FileUtil.createData(fs1.getRoot(), "test-fs-is-there.txt");
+ write(fo11, "hereIam");
+
+ FileObject fo2 = FileUtil.createData(fs2.getRoot(), global.getPath());
+ fo2.setAttribute("two", 2);
+ write(fo2, "two");
+
+ events.clear();
+
+
+ MainLookup.register(fs1, this);
+ MainLookup.register(fs2, this);
+
+ Iterator extends FileSystem> it = Lookup.getDefault().lookupAll(FileSystem.class).iterator();
+ assertTrue("At least One", it.hasNext());
+ assertEquals("first is fs1", fs1, it.next());
+ assertTrue("At least two ", it.hasNext());
+ assertEquals("first is fs2", fs2, it.next());
+
+ assertEquals("two", read(global));
+ } finally {
+ mgr.disable(m1);
+ mgr.delete(m1);
+ mgr.mutexPrivileged().exitWriteAccess();
+ }
+ assertTrue("Still valid", global.isValid());
+ assertEquals("two", read(global));
+
+ FileObject fo = FileUtil.getConfigFile("test-fs-is-there.txt");
+ assertNotNull("File found", fo);
+ assertEquals("Text is correct", "hereIam", read(fo));
+ }
public void testCanHideFilesFromModules() throws Exception {
ModuleManager mgr = Main.getModuleSystem ().getManager();
diff -r 893c55cd168d openide.filesystems/apichanges.xml
--- a/openide.filesystems/apichanges.xml Wed Aug 05 06:31:25 2009 +0400
+++ b/openide.filesystems/apichanges.xml Wed Aug 05 14:26:46 2009 +0200
@@ -46,7 +46,25 @@
Filesystems API
-
+
+
+ Allow modules to dynamically add/remove layer content
+
+
+
+
+
+
+ One can provide fallback
+ content of system filesystem by
+ returning Boolean.TRUE
from call
+ to fs.getRoot().getAttribute("fallback")
.
+
+
+
+
+
+
Read files with asText(), asBytes() and asLines()
diff -r 893c55cd168d openide.filesystems/arch.xml
--- a/openide.filesystems/arch.xml Wed Aug 05 06:31:25 2009 +0400
+++ b/openide.filesystems/arch.xml Wed Aug 05 14:26:46 2009 +0200
@@ -370,7 +370,7 @@
is provided for applications where a history of recently used directories is a
security concern.
-
+
@@ -909,6 +909,16 @@
memory file system,
or any other you write yourself.
+
+
+ Since version 7.23 you can use
+ By returning 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
+
+
diff -r 893c55cd168d openide.filesystems/nbproject/project.properties
--- a/openide.filesystems/nbproject/project.properties Wed Aug 05 06:31:25 2009 +0400
+++ b/openide.filesystems/nbproject/project.properties Wed Aug 05 14:26:46 2009 +0200
@@ -44,4 +44,4 @@
javadoc.main.page=org/openide/filesystems/doc-files/api.html
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml
-spec.version.base=7.22.0
+spec.version.base=7.23.0