This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 169892
Collapse All | Expand All

(-)a/core.startup/nbproject/project.xml (-1 / +1 lines)
Lines 60-66 Link Here
60
                    <build-prerequisite/>
60
                    <build-prerequisite/>
61
                    <compile-dependency/>
61
                    <compile-dependency/>
62
                    <run-dependency>
62
                    <run-dependency>
63
                        <specification-version>7.19</specification-version>
63
                        <specification-version>7.23</specification-version>
64
                    </run-dependency>
64
                    </run-dependency>
65
                </dependency>
65
                </dependency>
66
                <dependency>
66
                <dependency>
(-)a/core.startup/src/org/netbeans/core/startup/layers/ModuleLayeredFileSystem.java (-2 / +13 lines)
Lines 137-144 Link Here
137
        List<FileSystem> l = new ArrayList<FileSystem>(fs2s.length + 2);
137
        List<FileSystem> l = new ArrayList<FileSystem>(fs2s.length + 2);
138
        l.add(fs1);
138
        l.add(fs1);
139
        if (addLookup) {
139
        if (addLookup) {
140
            Collection<? extends FileSystem> fromLookup = result.allInstances();
140
            for (FileSystem f : result.allInstances()) {
141
            l.addAll(fromLookup);
141
                if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N
142
                    continue;
143
                }
144
                l.add(f);
145
            }
142
        }
146
        }
143
        l.addAll(Arrays.asList(fs2s));
147
        l.addAll(Arrays.asList(fs2s));
144
        l.add(fs3);
148
        l.add(fs3);
Lines 175-180 Link Here
175
                err.log(Level.WARNING, "Setting layer URLs: " + layerUrls, x);
179
                err.log(Level.WARNING, "Setting layer URLs: " + layerUrls, x);
176
            }
180
            }
177
        }
181
        }
182
        if (addLookup) {
183
            for (FileSystem f : result.allInstances()) {
184
                if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N
185
                    l.add(f);
186
                }
187
            }
188
        }
178
        return l.toArray(new FileSystem[l.size()]);
189
        return l.toArray(new FileSystem[l.size()]);
179
    }
190
    }
180
191
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/layers/SystemFileSystemTest.java (+58 lines)
Lines 63-68 Link Here
63
import org.openide.filesystems.FileRenameEvent;
63
import org.openide.filesystems.FileRenameEvent;
64
import org.openide.filesystems.FileSystem;
64
import org.openide.filesystems.FileSystem;
65
import org.openide.filesystems.FileUtil;
65
import org.openide.filesystems.FileUtil;
66
import org.openide.filesystems.LocalFileSystem;
66
import org.openide.modules.ModuleInfo;
67
import org.openide.modules.ModuleInfo;
67
import org.openide.util.Lookup;
68
import org.openide.util.Lookup;
68
import org.openide.util.lookup.InstanceContent;
69
import org.openide.util.lookup.InstanceContent;
Lines 230-235 Link Here
230
        assertTrue("Still valid", global.isValid());
231
        assertTrue("Still valid", global.isValid());
231
        assertEquals("fileone", read(global));
232
        assertEquals("fileone", read(global));
232
    }
233
    }
234
235
    public void testDynamicSystemsCanAlsoBeBehindLayers() throws Exception {
236
        ModuleManager mgr = Main.getModuleSystem ().getManager();
237
        mgr.mutexPrivileged().enterWriteAccess();
238
        Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
239
        FileObject global;
240
        try {
241
            assertEquals(Collections.EMPTY_SET, m1.getProblems());
242
            mgr.enable(m1);
243
            global = FileUtil.getConfigFile("foo/file2.txt");
244
            assertNotNull("File Object installed: " + global, global);
245
            assertEquals("base contents", read(global));
246
247
            final LocalFileSystem lfs1 = new LocalFileSystem();
248
            File dir1 = new File(getWorkDir(), "dir1");
249
            dir1.mkdirs();
250
            lfs1.setRootDirectory(dir1);
251
            lfs1.getRoot().setAttribute("fallback", Boolean.TRUE);
252
            assertEquals("Position attribute is there", -1, lfs1.getRoot().getAttribute("fallback"));
253
            fs1 = lfs1;
254
255
            FileObject fo1 = FileUtil.createData(fs1.getRoot(), global.getPath());
256
            fo1.setAttribute("one", 1);
257
            write(fo1, "fileone");
258
259
            FileObject fo11 = FileUtil.createData(fs1.getRoot(), "test-fs-is-there.txt");
260
            write(fo11, "hereIam");
261
262
            FileObject fo2 = FileUtil.createData(fs2.getRoot(), global.getPath());
263
            fo2.setAttribute("two", 2);
264
            write(fo2, "two");
265
266
            events.clear();
267
268
269
            MainLookup.register(fs1, this);
270
            MainLookup.register(fs2, this);
271
272
            Iterator<? extends FileSystem> it = Lookup.getDefault().lookupAll(FileSystem.class).iterator();
273
            assertTrue("At least One", it.hasNext());
274
            assertEquals("first is fs1", fs1, it.next());
275
            assertTrue("At least two ", it.hasNext());
276
            assertEquals("first is fs2", fs2, it.next());
277
278
            assertEquals("two", read(global));
279
        } finally {
280
            mgr.disable(m1);
281
            mgr.delete(m1);
282
            mgr.mutexPrivileged().exitWriteAccess();
283
        }
284
        assertTrue("Still valid", global.isValid());
285
        assertEquals("two", read(global));
286
287
        FileObject fo = FileUtil.getConfigFile("test-fs-is-there.txt");
288
        assertNotNull("File found", fo);
289
        assertEquals("Text is correct", "hereIam", read(fo));
290
    }
233
    
291
    
234
    public void testCanHideFilesFromModules() throws Exception {
292
    public void testCanHideFilesFromModules() throws Exception {
235
        ModuleManager mgr = Main.getModuleSystem ().getManager();
293
        ModuleManager mgr = Main.getModuleSystem ().getManager();
(-)a/openide.filesystems/apichanges.xml (-1 / +19 lines)
Lines 46-52 Link Here
46
        <apidef name="filesystems">Filesystems API</apidef>
46
        <apidef name="filesystems">Filesystems API</apidef>
47
    </apidefs>
47
    </apidefs>
48
    <changes>
48
    <changes>
49
        <change id="FileObject.asText">
49
         <change id="add-fallback-content-to-sfs">
50
            <api name="filesystems"/>
51
            <summary>Allow modules to dynamically add/remove layer content</summary>
52
            <version major="7" minor="23"/>
53
            <date day="12" month="8" year="2009"/>
54
            <author login="jtulach"/>
55
            <compatibility addition="yes" binary="compatible" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
56
            <description>
57
                <p>
58
                    One can provide <q>fallback</q>
59
                    <a href="@TOP@/architecture-summary.html#answer-arch-usecases">content of system filesystem</a> by
60
                    returning <code>Boolean.TRUE</code> from call
61
                    to <code>fs.getRoot().getAttribute("fallback")</code>.
62
                </p>
63
            </description>
64
            <class package="org.openide.filesystems" name="Repository"/>
65
            <issue number="169892"/>
66
        </change>
67
       <change id="FileObject.asText">
50
            <api name="filesystems"/>
68
            <api name="filesystems"/>
51
            <summary>Read files with asText(), asBytes() and asLines()</summary>
69
            <summary>Read files with asText(), asBytes() and asLines()</summary>
52
            <version major="7" minor="21"/>
70
            <version major="7" minor="21"/>
(-)a/openide.filesystems/arch.xml (-1 / +11 lines)
Lines 370-376 Link Here
370
    is provided for applications where a history of recently used directories is a
370
    is provided for applications where a history of recently used directories is a
371
    security concern.
371
    security concern.
372
    </li>
372
    </li>
373
    </ul>
373
</ul>
374
</answer>
374
</answer>
375
375
376
376
Lines 909-914 Link Here
909
          <a href="@TOP@/org/openide/filesystems/FileUtil.html#createMemoryFileSystem()">memory file system</a>,
909
          <a href="@TOP@/org/openide/filesystems/FileUtil.html#createMemoryFileSystem()">memory file system</a>,
910
          or any other you write yourself.
910
          or any other you write yourself.
911
      </p>
911
      </p>
912
913
      <p>
914
          Since version 7.23 you can use <api name="SystemFileSystem.fallback" group="property"
915
          type="export" category="stable">
916
              By returning <code>Boolean.TRUE</code> from call
917
                    to <code>fs.getRoot().getAttribute("fallback")</code>
918
                    you can place your filesystem behind all layers provided
919
                    by standard modules and form a kind of <q>fallback</q>
920
         </api>
921
      </p>
912
  </usecase>
922
  </usecase>
913
 </answer>
923
 </answer>
914
924
(-)a/openide.filesystems/nbproject/project.properties (-1 / +1 lines)
Lines 44-47 Link Here
44
javadoc.main.page=org/openide/filesystems/doc-files/api.html
44
javadoc.main.page=org/openide/filesystems/doc-files/api.html
45
javadoc.arch=${basedir}/arch.xml
45
javadoc.arch=${basedir}/arch.xml
46
javadoc.apichanges=${basedir}/apichanges.xml
46
javadoc.apichanges=${basedir}/apichanges.xml
47
spec.version.base=7.22.0
47
spec.version.base=7.23.0

Return to bug 169892