1.1 --- a/openide.util/apichanges.xml Tue Apr 10 16:50:25 2007 +0000
1.2 +++ b/openide.util/apichanges.xml Mon Apr 16 20:46:47 2007 +0000
1.3 @@ -26,6 +26,24 @@
1.4 <apidef name="actions">Actions API</apidef>
1.5 </apidefs>
1.6 <changes>
1.7 + <change id="Lookups.forPath">
1.8 + <api name="util"/>
1.9 + <summary>Added simplified support for named lookups <code>Lookups.forPath</code></summary>
1.10 + <version major="7" minor="9"/>
1.11 + <date day="17" month="4" year="2007"/>
1.12 + <author login="jtulach"/>
1.13 + <compatibility addition="yes"/>
1.14 + <description>
1.15 + <p>
1.16 + New method <a href="@TOP@/org/openide/util/lookup/Lookups.html#forPath(java.lang.String)">Lookups.forPath(String)</a>
1.17 + has been added to replace now deprecated <a href="@org-openide-loaders@/org/openide/loaders/FolderLookup.html">FolderLookup</a>
1.18 + and allow modules who wants to read settings from layers
1.19 + to do so with a simpler code, without dependency on DataSystems API.
1.20 + </p>
1.21 + </description>
1.22 + <class package="org.openide.util.lookup" name="Lookups"/>
1.23 + <issue number="98426"/>
1.24 + </change>
1.25
1.26 <change id="ChangeSupport">
1.27 <api name="util"/>
2.1 --- a/openide.util/nbproject/project.properties Tue Apr 10 16:50:25 2007 +0000
2.2 +++ b/openide.util/nbproject/project.properties Mon Apr 16 20:46:47 2007 +0000
2.3 @@ -19,7 +19,7 @@
2.4 javac.source=1.5
2.5 module.jar.dir=lib
2.6
2.7 -spec.version.base=7.8.0
2.8 +spec.version.base=7.9.0
2.9
2.10 # For XMLSerializer, needed for XMLUtil.write to work w/ namespaces under JDK 1.4:
2.11
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/openide.util/src/org/netbeans/modules/openide/util/NamedServicesProvider.java Mon Apr 16 20:46:47 2007 +0000
3.3 @@ -0,0 +1,70 @@
3.4 +/*
3.5 + * The contents of this file are subject to the terms of the Common Development
3.6 + * and Distribution License (the License). You may not use this file except in
3.7 + * compliance with the License.
3.8 + *
3.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
3.10 + * or http://www.netbeans.org/cddl.txt.
3.11 + *
3.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
3.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
3.14 + * If applicable, add the following below the CDDL Header, with the fields
3.15 + * enclosed by brackets [] replaced by your own identifying information:
3.16 + * "Portions Copyrighted [year] [name of copyright owner]"
3.17 + *
3.18 + * The Original Software is NetBeans. The Initial Developer of the Original
3.19 + * Software is Sun Microsystems, Inc.
3.20 + *
3.21 + * Portions Copyrighted 2006 Sun Microsystems, Inc.
3.22 + */
3.23 +
3.24 +package org.netbeans.modules.openide.util;
3.25 +
3.26 +import java.lang.ref.Reference;
3.27 +import java.lang.ref.WeakReference;
3.28 +import java.util.HashMap;
3.29 +import java.util.Map;
3.30 +import org.openide.util.Lookup;
3.31 +import org.openide.util.Lookup;
3.32 +import org.openide.util.lookup.Lookups;
3.33 +
3.34 +/** Interface for core/startup and core/settings
3.35 + * to provide lookup over system filesystem.
3.36 + *
3.37 + * @author Jaroslav Tulach
3.38 + */
3.39 +public abstract class NamedServicesProvider {
3.40 + private static volatile Map<String,Reference<Lookup>> map = new HashMap<String,Reference<Lookup>>();
3.41 +
3.42 +
3.43 + public abstract Lookup create(String path);
3.44 +
3.45 + public static synchronized Lookup find(String path) {
3.46 + if (!path.endsWith("/")) {
3.47 + path = path + "/";
3.48 + }
3.49 +
3.50 + Reference<Lookup> ref = map.get(path);
3.51 + Lookup lkp = ref == null ? null : ref.get();
3.52 + if (lkp != null) {
3.53 + return lkp;
3.54 + }
3.55 + NamedServicesProvider prov = Lookup.getDefault().lookup(NamedServicesProvider.class);
3.56 + if (prov != null) {
3.57 + lkp = prov.create(path);
3.58 + } else {
3.59 + ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class);
3.60 + if (l == null) {
3.61 + l = Thread.currentThread().getContextClassLoader();
3.62 + if (l == null) {
3.63 + l = NamedServicesProvider.class.getClassLoader();
3.64 + }
3.65 + }
3.66 + lkp = Lookups.metaInfServices(l, "META-INF/namedservices/" + path);
3.67 + }
3.68 +
3.69 + map.put(path, new WeakReference<Lookup>(lkp));
3.70 + return lkp;
3.71 + }
3.72 +
3.73 +}
4.1 --- a/openide.util/src/org/openide/util/doc-files/api.html Tue Apr 10 16:50:25 2007 +0000
4.2 +++ b/openide.util/src/org/openide/util/doc-files/api.html Mon Apr 16 20:46:47 2007 +0000
4.3 @@ -641,22 +641,56 @@
4.4 also changeable later). The results it provides are constructed by
4.5 merging together the results of the delegate lookups.
4.6
4.7 -<p>If you want to use the common mechanism of finding instances in
4.8 +<p>
4.9 +<a name="folderlookup"></a>
4.10 +
4.11 +If you want to use the common mechanism of finding instances in
4.12 folders (or subfolders) and serving these as the results,
4.13
4.14 -<code>FolderLookup</code>
4.15 +<a href="../lookup/Lookups.html#forPath(java.lang.String)">Lookups.forPath(String)</a>
4.16
4.17 -makes this possible: you need only provide a folder to look in, and
4.18 +makes this possible: you need only provide a name of a folder to look in, and
4.19 use
4.20
4.21 -<code>getLookup</code>
4.22 +<code>Lookups.forPath(theFolderName)</code>
4.23
4.24 to retrieve a lookup implementation which will scan this folder and
4.25 its subfolders for data objects with <code>InstanceCookie</code>
4.26 matching the lookup template. Furthermore, any instance cookies whose
4.27 instance class is assignable to <code>Lookup</code> will be treated
4.28 specially: they will be proxied to, so these sub-lookups may provide
4.29 -additional instances if they match the lookup template.
4.30 +additional instances if they match the lookup template. In order to
4.31 +get the full functionality associated with such a lookup it is wise
4.32 +to request presence of <code>org.netbeans.modules.settings > 1.13</code>
4.33 +as that is the module that does most of the work behind <code>Lookups.forPath</code>.
4.34 +To register <code>javax.xml.parsers.DocumentBuilderFactory</code> into
4.35 +<code>Lookups.forName("my/xml/app/data")</code> add the above described dependency
4.36 +and put following code in your layer file:
4.37 +<pre>
4.38 +<folder name="my">
4.39 + <folder name="xml">
4.40 + <folder name="app">
4.41 + <folder name="data">
4.42 + <file name="ThisIsMyRegistration.instance>
4.43 + <attr name="instanceCreate" newvalue="pkg.ClassNameOfYourImpl"/>
4.44 + </file>
4.45 + </folder>
4.46 + </folder>
4.47 + </folder>
4.48 +</folder>
4.49 +</pre>
4.50 +
4.51 +<p>
4.52 +In fact the <code>Lookups.forPath</code> can be used in completely
4.53 +standalone mode. This is not very recommended in the NetBeans IDE, but
4.54 +can be found pretty useful when using this library in standalone applications:
4.55 +<code>Lookups.forPath(path)</code> scans all instances registered in the
4.56 +<a href="#service-lookup">META-INF/services style</a> just it uses
4.57 +<code>META-INF/namedservices/path</code> prefix instead. As a result to
4.58 +perform a successfull search for all <code>javax.xml.parsers.DocumentBuilderFactory</code>
4.59 +inside <code>Lookups.forName("my/xml/app/data")</code> one can register the
4.60 +implementation into <code>META-INF/namedservices/my/xml/app/data/javax.xml.parsers.DocumentBuilderFactory</code>.
4.61 +</p>
4.62
4.63 <p>The most powerful way to provide a lookup is to directly define
4.64 what instances and items it should provide, by subclassing. For this,
5.1 --- a/openide.util/src/org/openide/util/lookup/Lookups.java Tue Apr 10 16:50:25 2007 +0000
5.2 +++ b/openide.util/src/org/openide/util/lookup/Lookups.java Mon Apr 16 20:46:47 2007 +0000
5.3 @@ -21,6 +21,7 @@
5.4
5.5 import java.util.Arrays;
5.6 import java.util.Collections;
5.7 +import org.netbeans.modules.openide.util.NamedServicesProvider;
5.8 import org.openide.util.Lookup;
5.9
5.10 /**
5.11 @@ -134,9 +135,41 @@
5.12 * @since 3.35
5.13 */
5.14 public static Lookup metaInfServices(ClassLoader classLoader) {
5.15 - return new MetaInfServicesLookup(classLoader);
5.16 + return new MetaInfServicesLookup(classLoader, "META-INF/services/"); // NOI18N
5.17 }
5.18
5.19 + /** Returns a lookup that behaves exactly as the one
5.20 + * created <code>metaInfServices(ClassLoader)</code> except that
5.21 + * it does not read data from META-INF/services, but instead
5.22 + * from the specified <code>prefix</code>.
5.23 + * @param classLoader class loader to use for loading
5.24 + * @param prefix prefix to prepend to the class name when searching
5.25 + * @since 7.9
5.26 + */
5.27 + public static Lookup metaInfServices(ClassLoader classLoader, String prefix) {
5.28 + return new MetaInfServicesLookup(classLoader, prefix);
5.29 + }
5.30 +
5.31 + /** Creates a <q>named</q> lookup. It is a lookup identified by a
5.32 + * given path. Two lookups with the same path are going to have
5.33 + * the same content. It is expected that each <q>named</q> lookup
5.34 + * will contain a superset of what would lookup created by
5.35 + * <code>metaInfServices(theRightLoader, "META-INF/namedservices/" + path)</code>
5.36 + * contain. However various environments can add their own
5.37 + * extensions to its content. For example when running inside NetBeans Runtime
5.38 + * Container, the content of system file system under the given
5.39 + * <code>path</code> is also present in the returned lookup.
5.40 + * <p>
5.41 + * Read more about the <a href="../doc-files/api.html#folderlookup">usage of this method...</a>
5.42 + *
5.43 + * @param path the path identifying the lookup, for example <q>Databases/</q>, etc.
5.44 + * @return lookup associated with this path
5.45 + * @since 7.9
5.46 + */
5.47 + public static Lookup forPath(String path) {
5.48 + return NamedServicesProvider.find(path);
5.49 + }
5.50 +
5.51 /** Creates a lookup that wraps another one and filters out instances
5.52 * of specified classes. If you have a lookup and
5.53 * you want to remove all instances of ActionMap you can use:
6.1 --- a/openide.util/src/org/openide/util/lookup/MetaInfServicesLookup.java Tue Apr 10 16:50:25 2007 +0000
6.2 +++ b/openide.util/src/org/openide/util/lookup/MetaInfServicesLookup.java Mon Apr 16 20:46:47 2007 +0000
6.3 @@ -68,18 +68,14 @@
6.4
6.5 /** class loader to use */
6.6 private final ClassLoader loader;
6.7 -
6.8 - /** Create a lookup reading from the classpath.
6.9 - * That is, the same classloader as this class itself.
6.10 - */
6.11 - public MetaInfServicesLookup() {
6.12 - this(MetaInfServicesLookup.class.getClassLoader());
6.13 - }
6.14 + /** prefix to prepend */
6.15 + private final String prefix;
6.16
6.17 /** Create a lookup reading from a specified classloader.
6.18 */
6.19 - public MetaInfServicesLookup(ClassLoader loader) {
6.20 + public MetaInfServicesLookup(ClassLoader loader, String prefix) {
6.21 this.loader = loader;
6.22 + this.prefix = prefix;
6.23
6.24 LOGGER.log(Level.FINE, "Created: {0}", this);
6.25 }
6.26 @@ -123,7 +119,7 @@
6.27 LOGGER.log(Level.FINER, "Searching for " + clazz.getName() + " in " + clazz.getClassLoader() + " from " + this);
6.28 }
6.29
6.30 - String res = "META-INF/services/" + clazz.getName(); // NOI18N
6.31 + String res = prefix + clazz.getName(); // NOI18N
6.32 Enumeration<URL> en;
6.33
6.34 try {
7.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/MetaInfServicesLookupTest.java Tue Apr 10 16:50:25 2007 +0000
7.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/MetaInfServicesLookupTest.java Mon Apr 16 20:46:47 2007 +0000
7.3 @@ -25,6 +25,8 @@
7.4 import java.io.IOException;
7.5 import java.io.InputStream;
7.6 import java.io.InputStreamReader;
7.7 +import java.lang.ref.Reference;
7.8 +import java.lang.ref.WeakReference;
7.9 import java.net.URL;
7.10 import java.net.URLClassLoader;
7.11 import java.util.ArrayList;
7.12 @@ -32,8 +34,11 @@
7.13 import java.util.Collections;
7.14 import java.util.Comparator;
7.15 import java.util.Enumeration;
7.16 +import java.util.HashMap;
7.17 +import java.util.HashSet;
7.18 import java.util.Iterator;
7.19 import java.util.List;
7.20 +import java.util.Map;
7.21 import java.util.Set;
7.22 import java.util.Set;
7.23 import java.util.TreeSet;
7.24 @@ -55,20 +60,34 @@
7.25 */
7.26 public class MetaInfServicesLookupTest extends NbTestCase {
7.27 private Logger LOG;
7.28 + private Map<ClassLoader,Lookup> lookups = new HashMap<ClassLoader,Lookup>();
7.29
7.30 public MetaInfServicesLookupTest(String name) {
7.31 super(name);
7.32 LOG = Logger.getLogger("Test." + name);
7.33 }
7.34
7.35 - private String prefix() {
7.36 + protected String prefix() {
7.37 return "META-INF/services/";
7.38 }
7.39
7.40 + protected Lookup createLookup(ClassLoader c) {
7.41 + return Lookups.metaInfServices(c);
7.42 + }
7.43 +
7.44 protected Level logLevel() {
7.45 return Level.INFO;
7.46 }
7.47
7.48 + private Lookup getTestedLookup(ClassLoader c) {
7.49 + Lookup l = lookups.get(c);
7.50 + if (l == null) {
7.51 + l = createLookup(c);
7.52 + lookups.put(c, l);
7.53 + }
7.54 + return l;
7.55 + }
7.56 +
7.57 private URL findJar(String n) throws IOException {
7.58 LOG.info("Looking for " + n);
7.59 File jarDir = new File(getWorkDir(), "jars");
7.60 @@ -159,8 +178,21 @@
7.61 }, c0);
7.62 }
7.63
7.64 + protected void tearDown() throws Exception {
7.65 + Set<Reference<Lookup>> weak = new HashSet<Reference<Lookup>>();
7.66 + for (Lookup l : lookups.values()) {
7.67 + weak.add(new WeakReference<Lookup>(l));
7.68 + }
7.69 +
7.70 + lookups = null;
7.71 +
7.72 + for(Reference<Lookup> ref : weak) {
7.73 + assertGC("Lookup can disappear", ref);
7.74 + }
7.75 + }
7.76 +
7.77 public void testBasicUsage() throws Exception {
7.78 - Lookup l = Lookups.metaInfServices(c2);
7.79 + Lookup l = getTestedLookup(c2);
7.80 Class xface = c1.loadClass("org.foo.Interface");
7.81 List results = new ArrayList(l.lookup(new Lookup.Template(xface)).allInstances());
7.82 assertEquals(2, results.size());
7.83 @@ -174,11 +206,11 @@
7.84
7.85 public void testLoaderSkew() throws Exception {
7.86 Class xface1 = c1.loadClass("org.foo.Interface");
7.87 - Lookup l3 = Lookups.metaInfServices(c3);
7.88 + Lookup l3 = getTestedLookup(c3);
7.89 // If we cannot load Interface, there should be no impls of course... quietly!
7.90 assertEquals(Collections.EMPTY_LIST,
7.91 new ArrayList(l3.lookup(new Lookup.Template(xface1)).allInstances()));
7.92 - Lookup l4 = Lookups.metaInfServices(c4);
7.93 + Lookup l4 = getTestedLookup(c4);
7.94 // If we can load Interface but it is the wrong one, ignore it.
7.95 assertEquals(Collections.EMPTY_LIST,
7.96 new ArrayList(l4.lookup(new Lookup.Template(xface1)).allInstances()));
7.97 @@ -188,18 +220,18 @@
7.98 }
7.99
7.100 public void testStability() throws Exception {
7.101 - Lookup l = Lookups.metaInfServices(c2);
7.102 + Lookup l = getTestedLookup(c2);
7.103 Class xface = c1.loadClass("org.foo.Interface");
7.104 Object first = l.lookup(new Lookup.Template(xface)).allInstances().iterator().next();
7.105 - l = Lookups.metaInfServices(c2a);
7.106 + l = getTestedLookup(c2a);
7.107 Object second = l.lookup(new Lookup.Template(xface)).allInstances().iterator().next();
7.108 assertEquals(first, second);
7.109 }
7.110
7.111 public void testMaskingOfResources() throws Exception {
7.112 - Lookup l1 = Lookups.metaInfServices(c1);
7.113 - Lookup l2 = Lookups.metaInfServices(c2);
7.114 - Lookup l4 = Lookups.metaInfServices(c4);
7.115 + Lookup l1 = getTestedLookup(c1);
7.116 + Lookup l2 = getTestedLookup(c2);
7.117 + Lookup l4 = getTestedLookup(c4);
7.118
7.119 assertNotNull("services1.jar defines a class that implements runnable", l1.lookup(Runnable.class));
7.120 assertNull("services2.jar does not defines a class that implements runnable", l2.lookup(Runnable.class));
7.121 @@ -207,12 +239,12 @@
7.122 }
7.123
7.124 public void testOrdering() throws Exception {
7.125 - Lookup l = Lookups.metaInfServices(c1);
7.126 + Lookup l = getTestedLookup(c1);
7.127 Class xface = c1.loadClass("java.util.Comparator");
7.128 List results = new ArrayList(l.lookup(new Lookup.Template(xface)).allInstances());
7.129 assertEquals(1, results.size());
7.130
7.131 - l = Lookups.metaInfServices(c2);
7.132 + l = getTestedLookup(c2);
7.133 xface = c2.loadClass("java.util.Comparator");
7.134 results = new ArrayList(l.lookup(new Lookup.Template(xface)).allInstances());
7.135 assertEquals(2, results.size());
7.136 @@ -221,7 +253,7 @@
7.137 assertEquals("org.foo.impl.Comparator1", results.get(1).getClass().getName());
7.138
7.139 // test that items without position are always at the end
7.140 - l = Lookups.metaInfServices(c2);
7.141 + l = getTestedLookup(c2);
7.142 xface = c2.loadClass("java.util.Iterator");
7.143 results = new ArrayList(l.lookup(new Lookup.Template(xface)).allInstances());
7.144 assertEquals(2, results.size());
7.145 @@ -256,7 +288,7 @@
7.146 }
7.147 }
7.148 Loader loader = new Loader();
7.149 - Lookup l = Lookups.metaInfServices(loader);
7.150 + Lookup l = getTestedLookup(loader);
7.151
7.152 Object no = l.lookup(String.class);
7.153 assertNull("Not found of course", no);
7.154 @@ -264,7 +296,7 @@
7.155 }
7.156
7.157 public void testListenersAreNotifiedWithoutHoldingALockIssue36035() throws Exception {
7.158 - final Lookup l = Lookups.metaInfServices(c2);
7.159 + final Lookup l = getTestedLookup(c2);
7.160 final Class xface = c1.loadClass("org.foo.Interface");
7.161 final Lookup.Result res = l.lookup(new Lookup.Template(Object.class));
7.162
7.163 @@ -305,7 +337,7 @@
7.164 ClassLoader c1 = new URLClassLoader(new URL[] {
7.165 findJar("problem100320.jar"),
7.166 }, c0);
7.167 - Lookup lookup = Lookups.metaInfServices(c1);
7.168 + Lookup lookup = Lookups.metaInfServices(c1, prefix());
7.169
7.170 Collection<?> colAWT = lookup.lookupAll(Component.class);
7.171 assertEquals("There is enough objects to switch to InheritanceTree", 12, colAWT.size());
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/NamedServicesLookupTest.java Mon Apr 16 20:46:47 2007 +0000
8.3 @@ -0,0 +1,71 @@
8.4 +/*
8.5 + * The contents of this file are subject to the terms of the Common Development
8.6 + * and Distribution License (the License). You may not use this file except in
8.7 + * compliance with the License.
8.8 + *
8.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
8.10 + * or http://www.netbeans.org/cddl.txt.
8.11 + *
8.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
8.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
8.14 + * If applicable, add the following below the CDDL Header, with the fields
8.15 + * enclosed by brackets [] replaced by your own identifying information:
8.16 + * "Portions Copyrighted [year] [name of copyright owner]"
8.17 + *
8.18 + * The Original Software is NetBeans. The Initial Developer of the Original
8.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
8.20 + * Microsystems, Inc. All Rights Reserved.
8.21 + */
8.22 +
8.23 +package org.openide.util.lookup;
8.24 +
8.25 +import org.openide.util.Lookup;
8.26 +
8.27 +
8.28 +/** Test finding services from manifest.
8.29 + * @author Jaroslav Tulach
8.30 + */
8.31 +public class NamedServicesLookupTest extends MetaInfServicesLookupTest {
8.32 + public NamedServicesLookupTest(String name) {
8.33 + super(name);
8.34 + }
8.35 +
8.36 + protected String prefix() {
8.37 + return "META-INF/namedservices/sub/path/";
8.38 + }
8.39 +
8.40 + protected Lookup createLookup(ClassLoader c) {
8.41 + ClassLoader prev = Thread.currentThread().getContextClassLoader();
8.42 + Thread.currentThread().setContextClassLoader(c);
8.43 + Lookup l = Lookups.forPath("sub/path");
8.44 + Thread.currentThread().setContextClassLoader(prev);
8.45 + return l;
8.46 + }
8.47 +
8.48 + //
8.49 + // this is not much inheriting test, as we mask most of the tested methods
8.50 + // anyway, but the infrastructure to generate the JAR files is useful
8.51 + //
8.52 +
8.53 + public void testLoaderSkew() throws Exception {
8.54 + }
8.55 +
8.56 + public void testStability() throws Exception {
8.57 + }
8.58 +
8.59 + public void testMaskingOfResources() throws Exception {
8.60 + }
8.61 +
8.62 + public void testOrdering() throws Exception {
8.63 + }
8.64 +
8.65 + public void testNoCallToGetResourceForObjectIssue65124() throws Exception {
8.66 + }
8.67 +
8.68 + public void testListenersAreNotifiedWithoutHoldingALockIssue36035() throws Exception {
8.69 + }
8.70 +
8.71 + public void testWrongOrderAsInIssue100320() throws Exception {
8.72 + }
8.73 +
8.74 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/PrefixServicesLookupTest.java Mon Apr 16 20:46:47 2007 +0000
9.3 @@ -0,0 +1,41 @@
9.4 +/*
9.5 + * The contents of this file are subject to the terms of the Common Development
9.6 + * and Distribution License (the License). You may not use this file except in
9.7 + * compliance with the License.
9.8 + *
9.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
9.10 + * or http://www.netbeans.org/cddl.txt.
9.11 + *
9.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
9.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
9.14 + * If applicable, add the following below the CDDL Header, with the fields
9.15 + * enclosed by brackets [] replaced by your own identifying information:
9.16 + * "Portions Copyrighted [year] [name of copyright owner]"
9.17 + *
9.18 + * The Original Software is NetBeans. The Initial Developer of the Original
9.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
9.20 + * Microsystems, Inc. All Rights Reserved.
9.21 + */
9.22 +
9.23 +package org.openide.util.lookup;
9.24 +
9.25 +import org.openide.util.Lookup;
9.26 +
9.27 +
9.28 +/** Test finding services from manifest.
9.29 + * @author Jaroslav Tulach
9.30 + */
9.31 +public class PrefixServicesLookupTest extends MetaInfServicesLookupTest {
9.32 + public PrefixServicesLookupTest(String name) {
9.33 + super(name);
9.34 + }
9.35 +
9.36 + protected String prefix() {
9.37 + return "META-INF/netbeans/prefix/services/test/";
9.38 + }
9.39 +
9.40 + protected Lookup createLookup(ClassLoader c) {
9.41 + return Lookups.metaInfServices(c, prefix());
9.42 + }
9.43 +
9.44 +}