--- a/core.startup/src/org/netbeans/core/startup/layers/BinaryFS.java Sat Dec 27 20:14:31 2008 +0100
+++ a/core.startup/src/org/netbeans/core/startup/layers/BinaryFS.java Tue Jan 06 21:31:08 2009 +0100
@@ -385,7 +385,7 @@
ThreadLocal> attrAskedFileObject = ThreadLocal.class.cast(field.get(null));
topFO = (FileObject)attrAskedFileObject.get();
- attrAskedFileObject.set(null);
+ //attrAskedFileObject.set(null);
} catch (Exception e) {
Exceptions.printStackTrace(e);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ d536b9e45a9a Tue Jan 06 21:31:08 2009 +0100
@@ -0,0 +1,105 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+
+package org.netbeans.core.startup.layers;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Arrays;
+import junit.framework.Test;
+import org.netbeans.junit.NbTestSuite;
+import org.openide.filesystems.AttributesTestHidden;
+import org.openide.filesystems.FileObjectTestHid;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.FileSystemFactoryHid;
+import org.openide.filesystems.FileSystemTestHid;
+import org.openide.filesystems.MultiFileSystem;
+import org.openide.filesystems.TestUtilHid;
+import org.openide.filesystems.XMLFileSystem;
+import org.openide.filesystems.XMLFileSystemTestHid;
+
+/**
+ *
+ * @author Radek Matous
+ */
+public class BinaryFSBehindMultiFSTest extends FileSystemFactoryHid
+implements XMLFileSystemTestHid.Factory {
+ public BinaryFSBehindMultiFSTest(Test test) {
+ super(test);
+ }
+
+ public static Test suite() {
+ NbTestSuite suite = new NbTestSuite();
+ suite.addTestSuite(FileSystemTestHid.class);
+ suite.addTestSuite(FileObjectTestHid.class);
+ suite.addTestSuite(AttributesTestHidden.class);
+ suite.addTestSuite(XMLFileSystemTestHid.class);
+
+ return new BinaryFSBehindMultiFSTest(suite);
+ }
+
+ protected FileSystem[] createFileSystem(String testName, String[] resources) throws IOException {
+ XMLFileSystem xfs = (XMLFileSystem)TestUtilHid.createXMLFileSystem(testName, resources);
+ LayerCacheManager bm = LayerCacheManager.manager(true);
+ return new FileSystem[] {BinaryCacheManagerTest.store(bm, Arrays.asList(xfs.getXmlUrls()))};
+ }
+
+ protected void destroyFileSystem(String testName) throws IOException {
+ }
+
+ private File getWorkDir() {
+ String workDirProperty = System.getProperty("workdir");//NOI18N
+ workDirProperty = (workDirProperty != null) ? workDirProperty : System.getProperty("java.io.tmpdir");//NOI18N
+ return new File(workDirProperty);
+ }
+
+ public FileSystem createLayerSystem(String testName, URL[] layers) throws IOException {
+ LayerCacheManager bm = LayerCacheManager.manager(true);
+ return new MultiFileSystem(new FileSystem[] {
+ BinaryCacheManagerTest.store(bm, Arrays.asList(layers))
+ });
+ }
+
+ public boolean setXmlUrl(FileSystem fs, URL[] layers) throws IOException {
+ return false;
+ }
+}
--- a/openide.filesystems/src/org/openide/filesystems/MultiFileObject.java Sat Dec 27 20:14:31 2008 +0100
+++ a/openide.filesystems/src/org/openide/filesystems/MultiFileObject.java Tue Jan 06 21:31:08 2009 +0100
@@ -814,9 +814,9 @@
private Object getAttribute(FileObject fo, String attrName, String path) {
Object o;
- FileObject topFO = attrAskedFileObject.get();
+ FileObject previousFO = attrAskedFileObject.get();
- if (topFO == null) {
+ if (previousFO == null || !previousFO.getPath().equals(getPath())) {
attrAskedFileObject.set(this);
}
@@ -829,10 +829,8 @@
o = fo.getAttribute(attrName);
}
} finally {
- if (topFO == null) {
- attrAskedFileObject.set(null);
+ attrAskedFileObject.set(previousFO);
}
- }
if (o != null) {
getAttributeCache().setDelegate(fo);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ d536b9e45a9a Tue Jan 06 21:31:08 2009 +0100
@@ -0,0 +1,110 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+
+package org.openide.filesystems;
+
+import java.beans.PropertyVetoException;
+import java.io.IOException;
+import java.net.URL;
+import junit.framework.Test;
+import org.netbeans.junit.*;
+
+/**
+ *
+ * @author rm111737
+ * @version
+ */
+public class MultiFileSystemXMLTest extends FileSystemFactoryHid
+implements XMLFileSystemTestHid.Factory {
+
+ /** Creates new XMLFileSystemTest */
+ public MultiFileSystemXMLTest(Test test) {
+ super(test);
+ }
+
+ public static Test suite() {
+ NbTestSuite suite = new NbTestSuite();
+ suite.addTestSuite(FileSystemTestHid.class);
+ suite.addTestSuite(FileObjectTestHid.class);
+ suite.addTestSuite(XMLFileSystemTestHid.class);
+
+ return new MultiFileSystemXMLTest(suite);
+ }
+
+ protected void destroyFileSystem(String testName) throws IOException {}
+
+ protected FileSystem[] createFileSystem(String testName, String[] resources) throws IOException {
+ return new FileSystem[] {TestUtilHid.createXMLFileSystem(testName, resources)};
+ }
+
+ public FileSystem createLayerSystem(String testName, URL[] layers) throws IOException {
+ MFS mfs = new MFS();
+ try {
+ mfs.xfs.setXmlUrls(layers);
+ } catch (PropertyVetoException ex) {
+ throw (IOException)new IOException().initCause(ex);
+ }
+ return mfs;
+ }
+
+ public boolean setXmlUrl(org.openide.filesystems.FileSystem fs, URL[] layers) throws IOException {
+ MFS mfs = (MFS)fs;
+ try {
+ mfs.xfs.setXmlUrls(layers);
+ } catch (PropertyVetoException ex) {
+ throw (IOException)new IOException().initCause(ex);
+ }
+ return true;
+ }
+
+
+ private static final class MFS extends MultiFileSystem {
+ private XMLFileSystem xfs;
+ public MFS() {
+ this(new XMLFileSystem());
+ }
+
+ private MFS(XMLFileSystem fs) {
+ super(new FileSystem[] { fs });
+ this.xfs = fs;
+ }
+ }
+}
--- a/openide.filesystems/test/unit/src/org/openide/filesystems/XMLFileSystemTest.java Sat Dec 27 20:14:31 2008 +0100
+++ a/openide.filesystems/test/unit/src/org/openide/filesystems/XMLFileSystemTest.java Tue Jan 06 21:31:08 2009 +0100
@@ -46,7 +46,6 @@
import junit.framework.*;
import java.io.*;
import org.netbeans.junit.*;
-import org.openide.util.Exceptions;
/**
*
--- a/openide.filesystems/test/unit/src/org/openide/filesystems/XMLFileSystemTestHid.java Sat Dec 27 20:14:31 2008 +0100
+++ a/openide.filesystems/test/unit/src/org/openide/filesystems/XMLFileSystemTestHid.java Tue Jan 06 21:31:08 2009 +0100
@@ -487,6 +487,22 @@
assertNotNull("Value returned", obj);
assertEquals("works for bundle key", "Hello World!", obj);
}
+ public void testPeerAttribute() throws Exception {
+ URL fsURLDef = XMLFileSystemTestHid.class.getResource("data/Attributes.xml");
+ assertTrue ("Cannot create XML FS for testing purposes", fsURLDef != null);
+ FileSystem fs = FileSystemFactoryHid.createXMLSystem(getName(), this, fsURLDef);
+ root = fs.getRoot();
+ FileObject fo = fs.findResource("peer/base");
+ FileObject peer = fs.findResource("peer/snd");
+ assertTrue ("Cannot acces FileObject named testMethodValue", fo != null);
+
+ Object obj = fo.getAttribute("testPeer");
+ assertNotNull("methodValue failed", obj);
+ assertEquals(Data.class, obj.getClass());
+ Data data = (Data)obj;
+ assertEquals("it is the top most fileobject", peer, data.peer);
+
+ }
public void testChangeOfAnAttributeInLayerIsFiredIfThereIsRealChange() throws Exception {
@@ -730,5 +746,16 @@
return attrs.get("value1") + attrName;
}
+ private static FileObject root;
+ public static final class Data {
+ Object peer;
+ public Data() {
+ FileObject fo = root.getFileObject("peer/snd");
+ peer = fo.getAttribute("testPeer");
+ }
+ }
+ private static Object getFO(FileObject fo) {
+ return fo;
+ }
}
--- a/openide.filesystems/test/unit/src/org/openide/filesystems/data/Attributes.xml Sat Dec 27 20:14:31 2008 +0100
+++ a/openide.filesystems/test/unit/src/org/openide/filesystems/data/Attributes.xml Tue Jan 06 21:31:08 2009 +0100
@@ -21,4 +21,12 @@
+
+
+
+
+
+
+
+