I am afraid that my previous decision to change MockLookup.setInstances to also include content of Services folder was not really compatible. People report problems from all around the code base. Better to add new method and allow users to decide which alternative behaviour they are about to use.
authorJaroslav Tulach <jtulach@netbeans.org>
Fri, 20 Mar 2009 10:45:15 +0100
changeset 525417d0329b188
parent 524 95f75a332024
child 526 519bef079589
I am afraid that my previous decision to change MockLookup.setInstances to also include content of Services folder was not really compatible. People report problems from all around the code base. Better to add new method and allow users to decide which alternative behaviour they are about to use.
openide.util/test/unit/src/org/openide/util/test/MockLookup.java
     1.1 --- a/openide.util/test/unit/src/org/openide/util/test/MockLookup.java	Thu Mar 19 23:41:53 2009 -0400
     1.2 +++ b/openide.util/test/unit/src/org/openide/util/test/MockLookup.java	Fri Mar 20 10:45:15 2009 +0100
     1.3 @@ -113,6 +113,16 @@
     1.4       */
     1.5      public static void setInstances(Object... instances) {
     1.6          ClassLoader l = MockLookup.class.getClassLoader();
     1.7 +        setLookup(Lookups.fixed(instances), Lookups.metaInfServices(l), Lookups.singleton(l));
     1.8 +    }
     1.9 +    /**
    1.10 +     * Sets the global default lookup with some fixed instances and
    1.11 +     * content read from Services folder from system file system.
    1.12 +     * Will also include (at a lower priority) a {@link ClassLoader},
    1.13 +     * and services found from <code>META-INF/services/*</code> in the classpath.
    1.14 +     */
    1.15 +    public static void setLayersAndInstances(Object... instances) {
    1.16 +        ClassLoader l = MockLookup.class.getClassLoader();
    1.17          if (l != Lookup.getDefault().lookup(ClassLoader.class)) {
    1.18              setLookup(Lookups.fixed(instances), Lookups.metaInfServices(l), Lookups.singleton(l));
    1.19          }