Index: core/settings/nbproject/project.xml
===================================================================
RCS file: /shared/data/ccvs/repository/core/settings/nbproject/project.xml,v
retrieving revision 1.16
retrieving revision 1.16.10.1
diff -u -r1.16 -r1.16.10.1
--- core/settings/nbproject/project.xml 3 Nov 2006 13:30:16 -0000 1.16
+++ core/settings/nbproject/project.xml 26 Mar 2007 12:00:15 -0000 1.16.10.1
@@ -75,7 +75,7 @@
- 7.3
+
@@ -87,45 +87,50 @@
-
-
- unit
-
- org.netbeans.modules.settings
-
-
-
-
- org.openide.actions
-
-
-
- org.netbeans.core.startup
-
-
-
-
- org.netbeans.core.ui
-
-
-
-
- org.openide.text
-
-
-
- org.netbeans.modules.progress.ui
-
-
-
- org.netbeans.modules.editor.mimelookup.impl
-
-
-
-
-
- qa-functional
-
+
+
+ unit
+
+ org.netbeans.core.startup
+
+
+
+
+ org.netbeans.core.ui
+
+
+
+
+ org.netbeans.modules.editor.mimelookup.impl
+
+
+
+
+ org.netbeans.modules.progress.ui
+
+
+
+ org.netbeans.modules.settings
+
+
+
+
+ org.openide.actions
+
+
+
+ org.openide.text
+
+
+
+ org.openide.util
+
+
+
+
+
+ qa-functional
+
org.netbeans.spi.settings
Index: core/settings/src/META-INF/services/org.netbeans.modules.openide.util.NamedServicesProvider
===================================================================
RCS file: core/settings/src/META-INF/services/org.netbeans.modules.openide.util.NamedServicesProvider
diff -N core/settings/src/META-INF/services/org.netbeans.modules.openide.util.NamedServicesProvider
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ core/settings/src/META-INF/services/org.netbeans.modules.openide.util.NamedServicesProvider 26 Mar 2007 12:00:16 -0000 1.1.2.1
@@ -0,0 +1,4 @@
+org.netbeans.modules.settings.RecognizeInstanceObjects
+#position=200
+#-org.netbeans.modules.startup.layers.RecognizeInstanceFiles
+
Index: core/settings/src/org/netbeans/modules/settings/RecognizeInstanceObjects.java
===================================================================
RCS file: core/settings/src/org/netbeans/modules/settings/RecognizeInstanceObjects.java
diff -N core/settings/src/org/netbeans/modules/settings/RecognizeInstanceObjects.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ core/settings/src/org/netbeans/modules/settings/RecognizeInstanceObjects.java 26 Mar 2007 12:00:14 -0000 1.1.2.1
@@ -0,0 +1,91 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License (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.html
+ * or http://www.netbeans.org/cddl.txt.
+ *
+ * When distributing Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at http://www.netbeans.org/cddl.txt.
+ * If applicable, add the following below the CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc.
+ *
+ * Portions Copyrighted 2007 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.settings;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.logging.Logger;
+import org.netbeans.modules.openide.util.NamedServicesProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.Repository;
+import org.openide.loaders.DataFolder;
+import org.openide.loaders.FolderLookup;
+import org.openide.util.Lookup;
+import org.openide.util.LookupEvent;
+import org.openide.util.LookupListener;
+import org.openide.util.WeakListeners;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/** Use FolderLookup to find out intances of named services.
+ *
+ * @author Jaroslav Tulach
+ */
+public final class RecognizeInstanceObjects extends NamedServicesProvider {
+ private static final Logger LOG = Logger.getLogger(RecognizeInstanceObjects.class.getName());
+
+
+ public Lookup create(String path) {
+ return new OverObjects(path);
+ }
+
+
+ private static final class OverObjects extends ProxyLookup
+ implements LookupListener {
+ private static Lookup.Result CL = Lookup.getDefault().lookupResult(ClassLoader.class);
+
+ private final String path;
+
+ public OverObjects(String path) {
+ super(delegates(path));
+ this.path = path;
+ CL.addLookupListener(WeakListeners.create(LookupListener.class, this, CL));
+ }
+
+ @SuppressWarnings("deprecation")
+ private static Lookup[] delegates(String path) {
+ Collection extends ClassLoader> allCL = CL.allInstances();
+ ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+ if (ccl != null) {
+ allCL = Collections.singleton(ccl);
+ } else {
+ if (allCL.isEmpty()) {
+ allCL = Collections.singleton(RecognizeInstanceObjects.class.getClassLoader());
+ }
+ }
+ try {
+ FileObject fo = FileUtil.createFolder(Repository.getDefault().getDefaultFileSystem().getRoot(), path);
+ FolderLookup l = new FolderLookup(DataFolder.findFolder(fo));
+ return new Lookup[] { l.getLookup(), Lookups.metaInfServices(allCL.iterator().next(), "META-INF/namedservices/" + path) }; // NOI18N
+ } catch (IOException ex) {
+ return new Lookup[] { Lookups.metaInfServices(allCL.iterator().next(), "META-INF/namedservices/" + path) }; // NOI18N
+ }
+
+ }
+
+ public void resultChanged(LookupEvent ev) {
+ setLookups(delegates(path));
+ }
+ } // end of OverObjects
+}
Index: core/settings/test/unit/src/org/netbeans/modules/settings/RecognizeInstanceObjectsTest.java
===================================================================
RCS file: core/settings/test/unit/src/org/netbeans/modules/settings/RecognizeInstanceObjectsTest.java
diff -N core/settings/test/unit/src/org/netbeans/modules/settings/RecognizeInstanceObjectsTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ core/settings/test/unit/src/org/netbeans/modules/settings/RecognizeInstanceObjectsTest.java 26 Mar 2007 12:00:12 -0000 1.1.2.1
@@ -0,0 +1,32 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License (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.html
+ * or http://www.netbeans.org/cddl.txt.
+ *
+ * When distributing Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at http://www.netbeans.org/cddl.txt.
+ * If applicable, add the following below the CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * 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.
+ */
+
+package org.netbeans.modules.settings;
+
+import org.netbeans.core.startup.layers.NamedFSServicesLookupTest;
+
+
+/** Test finding services from manifest and .instance files using FolderLookup.
+ * @author Jaroslav Tulach
+ */
+public class RecognizeInstanceObjectsTest extends NamedFSServicesLookupTest{
+ public RecognizeInstanceObjectsTest(String name) {
+ super(name);
+ }
+}
Index: core/startup/nbproject/project.xml
===================================================================
RCS file: /shared/data/ccvs/repository/core/startup/nbproject/project.xml,v
retrieving revision 1.12
retrieving revision 1.12.14.1
diff -u -r1.12 -r1.12.14.1
--- core/startup/nbproject/project.xml 11 Oct 2006 13:05:57 -0000 1.12
+++ core/startup/nbproject/project.xml 26 Mar 2007 12:00:12 -0000 1.12.14.1
@@ -70,6 +70,11 @@
+
+ org.openide.util
+
+
+
qa-functional
Index: core/startup/src/META-INF/services/org.netbeans.modules.openide.util.NamedServicesProvider
===================================================================
RCS file: core/startup/src/META-INF/services/org.netbeans.modules.openide.util.NamedServicesProvider
diff -N core/startup/src/META-INF/services/org.netbeans.modules.openide.util.NamedServicesProvider
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ core/startup/src/META-INF/services/org.netbeans.modules.openide.util.NamedServicesProvider 26 Mar 2007 12:00:14 -0000 1.1.2.1
@@ -0,0 +1,2 @@
+org.netbeans.core.startup.layers.RecognizeInstanceFiles
+#position=500
Index: core/startup/src/org/netbeans/core/startup/layers/RecognizeInstanceFiles.java
===================================================================
RCS file: core/startup/src/org/netbeans/core/startup/layers/RecognizeInstanceFiles.java
diff -N core/startup/src/org/netbeans/core/startup/layers/RecognizeInstanceFiles.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ core/startup/src/org/netbeans/core/startup/layers/RecognizeInstanceFiles.java 26 Mar 2007 12:00:16 -0000 1.1.2.1
@@ -0,0 +1,265 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License (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.html
+ * or http://www.netbeans.org/cddl.txt.
+ *
+ * When distributing Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at http://www.netbeans.org/cddl.txt.
+ * If applicable, add the following below the CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc.
+ *
+ * Portions Copyrighted 2007 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.core.startup.layers;
+
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.netbeans.modules.openide.util.NamedServicesProvider;
+import org.openide.filesystems.FileAttributeEvent;
+import org.openide.filesystems.FileChangeListener;
+import org.openide.filesystems.FileEvent;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileRenameEvent;
+import org.openide.filesystems.FileStateInvalidException;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.Repository;
+import org.openide.util.Lookup;
+import org.openide.util.Utilities;
+import org.openide.util.lookup.AbstractLookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/** Interface for core/startup to provide lookup overt system filesystem.
+ *
+ * @author Jaroslav Tulach
+ */
+public final class RecognizeInstanceFiles extends NamedServicesProvider {
+ private static final Logger LOG = Logger.getLogger(RecognizeInstanceFiles.class.getName());
+
+
+ public Lookup create(String path) {
+ return new OverFiles(path);
+ }
+
+
+ private static final class OverFiles extends ProxyLookup
+ implements FileChangeListener {
+ private final String path;
+ private final FileChangeListener weakL;
+ private final AbstractLookup.Content content;
+ private final AbstractLookup lkp;
+
+ public OverFiles(String path) {
+ this(path, new ArrayList(), new AbstractLookup.Content());
+ }
+
+ private OverFiles(String path, List items, AbstractLookup.Content cnt) {
+ this(path, items, new AbstractLookup(cnt), cnt);
+ }
+
+ private OverFiles(String path, List items, AbstractLookup lkp, AbstractLookup.Content cnt) {
+ super(computeDelegates(path, items, lkp));
+ this.path = path;
+ this.lkp = lkp;
+ this.content = cnt;
+ this.content.setPairs(items);
+
+ FileSystem fs = Repository.getDefault().getDefaultFileSystem();
+ this.weakL = FileUtil.weakFileChangeListener(this, fs);
+ fs.addFileChangeListener(weakL);
+ }
+
+ private void refresh() {
+ List items = new ArrayList();
+ Lookup[] delegates = computeDelegates(path, items, lkp);
+
+ this.content.setPairs(items);
+ this.setLookups(delegates);
+ }
+
+ private static Lookup[] computeDelegates(String p, List items, Lookup lkp) {
+ FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource(p);
+ List delegates = new LinkedList();
+ delegates.add(lkp);
+ if (fo != null) {
+ for (FileObject f : fo.getChildren()) {
+ if (f.isFolder()) {
+ delegates.add(new OverFiles(f.getPath()));
+ } else {
+ items.add(new FOItem(f));
+ }
+ }
+
+ }
+ delegates.add(
+ Lookups.metaInfServices(Thread.currentThread().getContextClassLoader(), "META-INF/namedservices/" + p) // NOI18N
+ );
+ return delegates.toArray(new Lookup[0]);
+ }
+
+ public void fileFolderCreated(FileEvent fe) {
+ refresh();
+ }
+
+ public void fileDataCreated(FileEvent fe) {
+ refresh();
+ }
+
+ public void fileChanged(FileEvent fe) {
+ refresh();
+ }
+
+ public void fileDeleted(FileEvent fe) {
+ refresh();
+ }
+
+ public void fileRenamed(FileRenameEvent fe) {
+ refresh();
+ }
+
+ public void fileAttributeChanged(FileAttributeEvent fe) {
+ refresh();
+ }
+ } // end of OverFiles
+
+
+ private static final class FOItem extends AbstractLookup.Pair