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.properties (-1 / +1 lines)
Lines 37-43 Link Here
37
# Version 2 license, then the option applies only if the new code is
37
# Version 2 license, then the option applies only if the new code is
38
# made subject to such option by the copyright holder.
38
# made subject to such option by the copyright holder.
39
39
40
spec.version.base=1.16.0
40
spec.version.base=1.17.0
41
javadoc.arch=${basedir}/arch.xml
41
javadoc.arch=${basedir}/arch.xml
42
javac.compilerargs=-Xlint -Xlint:-serial
42
javac.compilerargs=-Xlint -Xlint:-serial
43
javac.source=1.5
43
javac.source=1.5
(-)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 (-13 / +21 lines)
Lines 88-94 Link Here
88
    /** other layers */
88
    /** other layers */
89
    private final FileSystem[] otherLayers;
89
    private final FileSystem[] otherLayers;
90
    /** addLookup */
90
    /** addLookup */
91
    private final boolean addLookup;
91
    private final boolean addLookupBefore;
92
92
93
    /** Create layered filesystem based on a supplied writable layer.
93
    /** Create layered filesystem based on a supplied writable layer.
94
     * @param userDir is this layer for modules from userdir or not?
94
     * @param userDir is this layer for modules from userdir or not?
Lines 116-122 Link Here
116
        this.writableLayer = writableLayer;
116
        this.writableLayer = writableLayer;
117
        this.otherLayers = otherLayers;
117
        this.otherLayers = otherLayers;
118
        this.cacheLayer = cacheLayer;
118
        this.cacheLayer = cacheLayer;
119
        this.addLookup = addLookup;
119
        this.addLookupBefore = addLookup;
120
        
120
        
121
        // Wish to permit e.g. a user-installed module to mask files from a
121
        // Wish to permit e.g. a user-installed module to mask files from a
122
        // root-installed module, so propagate masks up this high.
122
        // root-installed module, so propagate masks up this high.
Lines 126-144 Link Here
126
        
126
        
127
        urls = null;
127
        urls = null;
128
128
129
        if (addLookup) {
129
        result.addLookupListener(this);
130
            result.addLookupListener(this);
130
        result.allItems();
131
            result.allItems();
132
        }
133
        
134
    }
131
    }
135
    
132
    
136
    private static FileSystem[] appendLayers(FileSystem fs1, boolean addLookup, FileSystem[] fs2s, FileSystem fs3, boolean addClasspathLayers) {
133
    private static FileSystem[] appendLayers(FileSystem fs1, boolean addLookupBefore, FileSystem[] fs2s, FileSystem fs3, boolean addClasspathLayers) {
137
        List<FileSystem> l = new ArrayList<FileSystem>(fs2s.length + 2);
134
        List<FileSystem> l = new ArrayList<FileSystem>(fs2s.length + 2);
138
        l.add(fs1);
135
        l.add(fs1);
139
        if (addLookup) {
136
        if (addLookupBefore) {
140
            Collection<? extends FileSystem> fromLookup = result.allInstances();
137
            for (FileSystem f : result.allInstances()) {
141
            l.addAll(fromLookup);
138
                if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N
139
                    continue;
140
                }
141
                l.add(f);
142
            }
142
        }
143
        }
143
        l.addAll(Arrays.asList(fs2s));
144
        l.addAll(Arrays.asList(fs2s));
144
        l.add(fs3);
145
        l.add(fs3);
Lines 175-180 Link Here
175
                err.log(Level.WARNING, "Setting layer URLs: " + layerUrls, x);
176
                err.log(Level.WARNING, "Setting layer URLs: " + layerUrls, x);
176
            }
177
            }
177
        }
178
        }
179
        if (!addLookupBefore) {
180
            for (FileSystem f : result.allInstances()) {
181
                if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N
182
                    l.add(f);
183
                }
184
            }
185
        }
178
        return l.toArray(new FileSystem[l.size()]);
186
        return l.toArray(new FileSystem[l.size()]);
179
    }
187
    }
180
188
Lines 246-252 Link Here
246
            }
254
            }
247
            cacheLayer = manager.store(cacheLayer, urls);
255
            cacheLayer = manager.store(cacheLayer, urls);
248
            err.log(Level.FINEST, "changing delegates");
256
            err.log(Level.FINEST, "changing delegates");
249
            setDelegates(appendLayers(writableLayer, addLookup, otherLayers, cacheLayer, false));
257
            setDelegates(appendLayers(writableLayer, addLookupBefore, otherLayers, cacheLayer, false));
250
            err.log(Level.FINEST, "delegates changed");
258
            err.log(Level.FINEST, "delegates changed");
251
        }
259
        }
252
        
260
        
Lines 278-284 Link Here
278
    
286
    
279
    /** Refresh layers */
287
    /** Refresh layers */
280
    public void resultChanged(LookupEvent ev) {
288
    public void resultChanged(LookupEvent ev) {
281
        setDelegates(appendLayers(writableLayer, addLookup, otherLayers, cacheLayer, false));
289
        setDelegates(appendLayers(writableLayer, addLookupBefore, otherLayers, cacheLayer, false));
282
    }
290
    }
283
    
291
    
284
    private static void setStatusText (String msg) {
292
    private static void setStatusText (String msg) {
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/layers/BinaryCacheManagerTest.java (+6 lines)
Lines 126-131 Link Here
126
        InputSource is = m.resolveEntity(pubid, sysid);
126
        InputSource is = m.resolveEntity(pubid, sysid);
127
        assertNotNull("DTD Filesystem 1.2 not resolved.", is);
127
        assertNotNull("DTD Filesystem 1.2 not resolved.", is);
128
    }
128
    }
129
    public void testJustAttributes() throws SAXException, IOException {
130
        BinaryCacheManager m = new BinaryCacheManager();
131
        List<URL> urls = new ArrayList<URL>(Arrays.asList(BinaryCacheManagerTest.class.getResource("data/attribsonly.xml")));
132
        FileSystem fs = store(m, urls);
133
        assertEquals(Boolean.TRUE, fs.getRoot().getAttribute("myAttr"));
134
    }
129
    
135
    
130
    public void testFastReplacement() throws Exception {
136
    public void testFastReplacement() throws Exception {
131
        clearWorkDir();
137
        clearWorkDir();
(-)893c55cd168d (+157 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.core.startup.layers;
43
44
import java.io.File;
45
import java.io.IOException;
46
import java.io.OutputStream;
47
import java.util.Arrays;
48
import java.util.Iterator;
49
import junit.framework.Test;
50
import org.netbeans.core.startup.MainLookup;
51
import org.netbeans.junit.NbModuleSuite;
52
import org.netbeans.junit.NbTestCase;
53
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileSystem;
55
import org.openide.filesystems.FileUtil;
56
import org.openide.filesystems.LocalFileSystem;
57
import org.openide.util.Lookup;
58
import org.openide.util.lookup.InstanceContent;
59
60
/** Test layering of filesystems installed via lookup.
61
 *
62
 * @author Jaroslav Tulach
63
 */
64
public class DynamicSFSFallbackTest extends NbTestCase
65
implements InstanceContent.Convertor<FileSystem,FileSystem> {
66
    FileSystem fs1;
67
    FileSystem fs2;
68
    
69
    public DynamicSFSFallbackTest(String testName) {
70
        super(testName);
71
    }
72
73
    public static Test suite() {
74
        return NbModuleSuite.create(
75
            NbModuleSuite.emptyConfiguration().
76
            addTest(DynamicSFSFallbackTest.class).
77
            clusters("org-netbeans-core-ui.*")
78
        );
79
    }
80
    
81
    @Override
82
    protected void setUp() throws Exception {
83
    }
84
    
85
    @Override
86
    protected void tearDown() throws Exception {
87
        super.tearDown();
88
        MainLookup.unregister(fs1, this);
89
        MainLookup.unregister(fs2, this);
90
    }
91
    
92
93
94
    public void testDynamicSystemsCanAlsoBeBehindLayers() throws Exception {
95
        FileObject global = FileUtil.getConfigFile("Toolbars/Standard.xml");
96
        assertNotNull("File Object installed: " + global, global);
97
        if (global.asText().indexOf("<Toolbar name=") == -1) {
98
            fail("Expecting toolbar definition: " + global.asText());
99
        }
100
101
        final LocalFileSystem lfs1 = new LocalFileSystem();
102
        File dir1 = new File(getWorkDir(), "dir1");
103
        dir1.mkdirs();
104
        lfs1.setRootDirectory(dir1);
105
        lfs1.getRoot().setAttribute("fallback", Boolean.TRUE);
106
        assertEquals("Position attribute is there", Boolean.TRUE, lfs1.getRoot().getAttribute("fallback"));
107
        fs1 = lfs1;
108
        fs2 = FileUtil.createMemoryFileSystem();
109
110
        FileObject fo1 = FileUtil.createData(fs1.getRoot(), global.getPath());
111
        fo1.setAttribute("one", 1);
112
        write(fo1, "fileone");
113
114
        FileObject fo11 = FileUtil.createData(fs1.getRoot(), "test-fs-is-there.txt");
115
        write(fo11, "hereIam");
116
117
        MainLookup.register(fs1, this);
118
        MainLookup.register(fs2, this);
119
120
        Iterator<? extends FileSystem> it = Lookup.getDefault().lookupAll(FileSystem.class).iterator();
121
        assertTrue("At least One", it.hasNext());
122
        assertEquals("first is fs1", fs1, it.next());
123
        assertTrue("At least two ", it.hasNext());
124
        assertEquals("first is fs2", fs2, it.next());
125
126
        if (global.asText().indexOf("<Toolbar name=") == -1) {
127
            fail("Still Expecting toolbar definition: " + global.asText());
128
        }
129
        assertTrue("Still valid", global.isValid());
130
131
        FileObject fo = FileUtil.getConfigFile("test-fs-is-there.txt");
132
        assertNotNull("File found: " + Arrays.toString(FileUtil.getConfigRoot().getChildren()), fo);
133
        assertEquals("Text is correct", "hereIam", fo.asText());
134
    }
135
    
136
    private static void write(FileObject fo, String txt) throws IOException {
137
        OutputStream os = fo.getOutputStream();
138
        os.write(txt.getBytes());
139
        os.close();
140
    }
141
    
142
    public FileSystem convert(FileSystem obj) {
143
        return obj;
144
    }
145
146
    public Class<? extends FileSystem> type(FileSystem obj) {
147
        return obj.getClass();
148
    }
149
150
    public String id(FileSystem obj) {
151
        return obj.getDisplayName();
152
    }
153
154
    public String displayName(FileSystem obj) {
155
        return obj.getDisplayName();
156
    }
157
}
(-)893c55cd168d (+5 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
3
<filesystem>
4
    <attr name="myAttr" boolvalue="true"/>
5
</filesystem>
(-)a/ide.ergonomics/nbproject/project.xml (-1 / +1 lines)
Lines 38-44 Link Here
38
                    <compile-dependency/>
38
                    <compile-dependency/>
39
                    <run-dependency>
39
                    <run-dependency>
40
                        <release-version>1</release-version>
40
                        <release-version>1</release-version>
41
                        <specification-version>1.15</specification-version>
41
                        <specification-version>1.17</specification-version>
42
                    </run-dependency>
42
                    </run-dependency>
43
                </dependency>
43
                </dependency>
44
                <dependency>
44
                <dependency>
(-)a/ide.ergonomics/src/org/netbeans/modules/ide/ergonomics/fod/FoDFileSystem.java (-6 / +6 lines)
Lines 120-135 Link Here
120
        boolean empty = true;
120
        boolean empty = true;
121
        LOG.fine("collecting layers"); // NOI18N
121
        LOG.fine("collecting layers"); // NOI18N
122
        List<URL> urls = new ArrayList<URL>();
122
        List<URL> urls = new ArrayList<URL>();
123
        urls.add(0, FoDFileSystem.class.getResource("common.xml")); // NOI18N
123
        for (FeatureInfo info : FeatureManager.features()) {
124
        for (FeatureInfo info : FeatureManager.features()) {
124
            if (!info.isPresent()) {
125
            if (!info.isPresent()) {
125
                continue;
126
                continue;
126
            }
127
            }
127
            if (!info.isEnabled()) {
128
            LOG.finest("adding feature " + info.clusterName); // NOI18N
128
                LOG.finest("adding feature " + info.clusterName); // NOI18N
129
            if (info.getLayerURL() != null) {
129
                if (info.getLayerURL() != null) {
130
                urls.add(info.getLayerURL());
130
                    urls.add(info.getLayerURL());
131
            }
131
                }
132
            if (info.isEnabled()) {
132
            } else {
133
                empty = false;
133
                empty = false;
134
            }
134
            }
135
        }
135
        }
(-)893c55cd168d (+5 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
3
<filesystem>
4
    <attr name="fallback" boolvalue="true"/>
5
</filesystem>
(-)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
(-)a/openide.filesystems/src/org/openide/filesystems/ExternalUtil.java (-1 / +11 lines)
Lines 231-238 Link Here
231
        private static FileSystem[] computeDelegates() {
231
        private static FileSystem[] computeDelegates() {
232
            List<FileSystem> arr = new ArrayList<FileSystem>();
232
            List<FileSystem> arr = new ArrayList<FileSystem>();
233
            arr.add(MEMORY);
233
            arr.add(MEMORY);
234
            for (FileSystem f : ALL.allInstances()) {
235
                if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N
236
                    continue;
237
                }
238
                arr.add(f);
239
            }
234
            arr.add(layers);
240
            arr.add(layers);
235
            arr.addAll(ALL.allInstances());
241
            for (FileSystem f : ALL.allInstances()) {
242
                if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N
243
                    arr.add(f);
244
                }
245
            }
236
            return arr.toArray(new FileSystem[0]);
246
            return arr.toArray(new FileSystem[0]);
237
        }
247
        }
238
        
248
        
(-)893c55cd168d (+132 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.openide.filesystems;
43
44
import java.io.File;
45
import java.io.IOException;
46
import java.io.OutputStream;
47
import java.util.Arrays;
48
import org.netbeans.junit.MockServices;
49
import org.netbeans.junit.NbTestCase;
50
import org.openide.util.lookup.InstanceContent;
51
52
/** Test layering of filesystems installed via lookup.
53
 *
54
 * @author Jaroslav Tulach
55
 */
56
public class DynamicSFSFallbackTest extends NbTestCase
57
implements InstanceContent.Convertor<FileSystem,FileSystem> {
58
    public DynamicSFSFallbackTest(String testName) {
59
        super(testName);
60
    }
61
62
    @Override
63
    protected void setUp() throws Exception {
64
        MyFS1.dir = new File(getWorkDir(), "dir1");
65
        MyFS2.dir = new File(getWorkDir(), "dir2");
66
        MockServices.setServices(MyFS1.class, MyFS2.class);
67
    }
68
    
69
    @Override
70
    protected void tearDown() throws Exception {
71
        super.tearDown();
72
    }
73
74
    public static final class MyFS1 extends LocalFileSystem {
75
        static File dir;
76
77
        public MyFS1() throws Exception {
78
            dir.mkdirs();
79
            setRootDirectory(dir);
80
            getRoot().setAttribute("fallback", Boolean.TRUE);
81
82
            FileObject fo1 = FileUtil.createData(getRoot(), "test/data.txt");
83
            fo1.setAttribute("one", 1);
84
            write(fo1, "fileone");
85
            FileObject fo11 = FileUtil.createData(getRoot(), "test-fs-is-there.txt");
86
            write(fo11, "hereIam");
87
        }
88
    }
89
    public static final class MyFS2 extends LocalFileSystem {
90
        static File dir;
91
92
        public MyFS2() throws Exception {
93
            dir.mkdirs();
94
            setRootDirectory(dir);
95
            FileObject fo1 = FileUtil.createData(getRoot(), "test/data.txt");
96
            fo1.setAttribute("two", 1);
97
            write(fo1, "two");
98
        }
99
    }
100
101
    public void testDynamicSystemsCanAlsoBeBehindLayers() throws Exception {
102
        FileObject global = FileUtil.getConfigFile("test/data.txt");
103
        assertEquals("Second file system takes preceedence", "two", global.asText());
104
        assertTrue("Still valid", global.isValid());
105
106
        FileObject fo = FileUtil.getConfigFile("test-fs-is-there.txt");
107
        assertNotNull("File found: " + Arrays.toString(FileUtil.getConfigRoot().getChildren()), fo);
108
        assertEquals("Text is correct", "hereIam", fo.asText());
109
    }
110
    
111
    private static void write(FileObject fo, String txt) throws IOException {
112
        OutputStream os = fo.getOutputStream();
113
        os.write(txt.getBytes());
114
        os.close();
115
    }
116
    
117
    public FileSystem convert(FileSystem obj) {
118
        return obj;
119
    }
120
121
    public Class<? extends FileSystem> type(FileSystem obj) {
122
        return obj.getClass();
123
    }
124
125
    public String id(FileSystem obj) {
126
        return obj.getDisplayName();
127
    }
128
129
    public String displayName(FileSystem obj) {
130
        return obj.getDisplayName();
131
    }
132
}

Return to bug 169892