当前位置: 首页>>代码示例>>Java>>正文


Java Lookups.metaInfServices方法代码示例

本文整理汇总了Java中org.openide.util.lookup.Lookups.metaInfServices方法的典型用法代码示例。如果您正苦于以下问题:Java Lookups.metaInfServices方法的具体用法?Java Lookups.metaInfServices怎么用?Java Lookups.metaInfServices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.util.lookup.Lookups的用法示例。


在下文中一共展示了Lookups.metaInfServices方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: BootClassLoader

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public BootClassLoader(List<File> cp, ClassLoader[] parents) {
    super(cp, parents);

    metaInf = Lookups.metaInfServices(this);

    String value = null;
    try {
        if (cp.isEmpty ()) {
            value = searchBuildNumber(this.getResources("META-INF/MANIFEST.MF"));
        } else {
            value = searchBuildNumber(this.findResources("META-INF/MANIFEST.MF"));
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }

    if (value == null) {
        System.err.println("Cannot set netbeans.buildnumber property no OpenIDE-Module-Build-Version found"); // NOI18N
    } else {
        System.setProperty ("netbeans.buildnumber", value); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:MainImpl.java

示例2: systemClassLoaderChanged

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
/** Called when a system classloader changes.
 */
public static final void systemClassLoaderChanged (ClassLoader nue) {
    if (!(Lookup.getDefault() instanceof MainLookup)) {
        // May be called from MockServices.setServices even though we are not main lookup.
        return;
    }
    if (classLoader != nue) {
        classLoader = nue;
        MainLookup l = (MainLookup)Lookup.getDefault();
        Lookup[] delegates = l.getLookups();
        Lookup[] newDelegates = delegates.clone();
        // Replace classloader.
        newDelegates[0] = Lookups.metaInfServices(classLoader);
        newDelegates[1] = Lookups.singleton(classLoader);
        l.changeLookups(newDelegates);
    } else {
        moduleClassLoadersUp();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MainLookup.java

示例3: testNamedDefinition

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public void testNamedDefinition() throws Exception {
    System.setProperty("executed", "false");
    String content = "import " + RunTestReg.class.getCanonicalName() + ";\n"
        + "@RunTestReg(position=10,when=\"now\")\n"
        + "public class Test implements Runnable {\n"
        + "  public void run() { System.setProperty(\"executed\", \"true\"); }\n"
        + "}\n";
    AnnotationProcessorTestUtils.makeSource(getWorkDir(), "x.Test", content);
    assertTrue("Compiles OK",
        AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, System.err)
        );
    
    URLClassLoader l = new URLClassLoader(new URL[] { getWorkDir().toURI().toURL() }, NamedServiceProcessorTest.class.getClassLoader());
    Lookup lkp = Lookups.metaInfServices(l, "META-INF/namedservices/runtest/now/below/");
    for (Runnable r : lkp.lookupAll(Runnable.class)) {
        r.run();
    }
    assertEquals("Our runnable was executed", "true", System.getProperty("executed"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:NamedServiceProcessorTest.java

示例4: testMetaInfLookupDeliversEventsInRPThread

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public void testMetaInfLookupDeliversEventsInRPThread() throws InterruptedException {
    ClassLoader l = new MyCL();
    Lookup lkp = Lookups.metaInfServices(l);
    Lookup.Result<Runnable> result = lkp.lookupResult(Runnable.class);
    result.addLookupListener(this);

    assertNull("No runnables found", lkp.lookup(Runnable.class));
    assertNotNull("Thread found", lkp.lookup(Thread.class));
    assertNotNull("Now runnable found", lkp.lookup(Runnable.class));
    synchronized (this) {
        int retry = 5;
        while (cnt == 0 && retry-- > 0) {
            wait(1000);
        }
    }    
    assertEquals("Count is now 1", 1, cnt);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:LookupUsesRequestProcessorTest.java

示例5: run

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
/** Checks for new JARs in netbeans.user */
@Override
public void run () {
    // do not call this method twice
    if (onlyRunRunOnce) return;
    onlyRunRunOnce = true;

    ArrayList<File> toAdd = new ArrayList<File> ();
    String user = System.getProperty ("netbeans.user"); // NOI18N
    try {
        if (user != null) {
            JarClassLoader.initializeCache();
            
            build_cp (new File (user), toAdd, new HashSet<File> (), new HashSet<String> ());

        }

        if (!toAdd.isEmpty ()) {
            // source were already added in MainImpl.execute() method while processing userdir
            metaInf = Lookups.metaInfServices(this);
            if (handlers != null) {
                handlers.clear();
                handlers.addAll(metaInf.lookupAll(CLIHandler.class));
            }
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:MainImpl.java

示例6: setLookup

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public static void setLookup(Object[] instances, ClassLoader cl, FileObject servicesFolder, Class [] exclude) {
    Lookup metaInfServices = Lookups.metaInfServices(cl);
    if (exclude != null && exclude.length > 0) {
        metaInfServices = Lookups.exclude(metaInfServices, exclude);
    }
    
    DEFAULT_LOOKUP.setLookups(new Lookup[] {
        Lookups.fixed(instances),
        metaInfServices,
        Lookups.singleton(cl),
    });
    
    if (servicesFolder != null) {
        // DataSystems need default repository, which is read from the default lookup.
        // That's why the lookup is set first without the services lookup and then again
        // here with the FolderLookup over the Services folder.
        Lookup services = new FolderLookup(DataFolder.findFolder(servicesFolder)).getLookup();
        if (exclude != null && exclude.length > 0) {
            services = Lookups.exclude(services, exclude);
        }
        
        DEFAULT_LOOKUP.setLookups(new Lookup[] {
            Lookups.fixed(instances),
            metaInfServices,
            Lookups.singleton(cl),
            services
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:EditorTestLookup.java

示例7: MainLookup

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public MainLookup () {
    super (new Lookup[] {
               // #14722: pay attention also to META-INF/services/class.Name resources:
               Lookups.metaInfServices(classLoader),
               Lookups.singleton(classLoader),
               Lookup.EMPTY, // will be moduleLookup
               instanceLookup
           });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:MainLookup.java

示例8: moduleClassLoadersUp

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
/** Called when modules are about to be turned on.
 */
public static final void moduleClassLoadersUp() {
    MainLookup l = (MainLookup)Lookup.getDefault();
    Lookup[] newDelegates = null;
    Lookup[] delegates = l.getLookups();
    newDelegates = delegates.clone();
    newDelegates[0] = Lookups.metaInfServices(classLoader);
    l.changeLookups(newDelegates);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:MainLookup.java

示例9: setDelegates

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
private void setDelegates() {
    Lookup[] delegates = new Lookup[nonClassLoaderDelegates.size() + 2];
    nonClassLoaderDelegates.toArray(delegates);
    delegates[delegates.length - 2] = Lookups.metaInfServices(classLoader);
    delegates[delegates.length - 1] = Lookups.singleton(classLoader);
    setLookups(delegates);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:OSGiMainLookup.java

示例10: delegates

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static Lookup[] delegates(Lookup prevFolderLkp, String path) {
    ClassLoader loader = Lookup.getDefault().lookup(ClassLoader.class);
    LOG.log(Level.FINEST, "lkp loader: {0}", loader);
    if (loader == null) {
        loader = Thread.currentThread().getContextClassLoader();
        LOG.log(Level.FINEST, "ccl: {0}", loader);
    }
    if (loader == null) {
        loader = RecognizeInstanceObjects.class.getClassLoader();
    }
    LOG.log(Level.FINER, "metaInfServices for {0}", loader);
    Lookup base = Lookups.metaInfServices(loader, "META-INF/namedservices/" + path); // NOI18N
    FileObject fo = FileUtil.getConfigFile(path);
    if (fo == null) {
        return new Lookup[] {base};
    }
    String s;
    if (path.endsWith("/")) { // NOI18N
        s = path.substring(0, path.length() - 1);
    } else {
        s = path;
    }
    if (prevFolderLkp == null) {
        prevFolderLkp = new org.openide.loaders.FolderLookup(DataFolder.findFolder(fo), s).getLookup();
    }
    return new Lookup[] {prevFolderLkp, base};
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:RecognizeInstanceObjects.java

示例11: resetDefaultLookup

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
/** Called from MockServices to reset default lookup in case services change
 */
private static synchronized void resetDefaultLookup() {
    if (defaultLookup == null || defaultLookup instanceof DefLookup) {
        DefLookup def = (DefLookup)defaultLookup;
        ClassLoader l = Thread.currentThread().getContextClassLoader();
        Lookup misl = Lookups.metaInfServices(l);
        if (def == null) {
            def = new DefLookup();
            def.init(l, misl, false);
            defaultLookup = def;
        }
        def.init(l, misl, true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:Lookup.java

示例12: forPath

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public static Lookup forPath(String path) {

        Reference<Lookup> ref = namedServicesProviders.get(path);
        Lookup lkp = ref == null ? null : ref.get();
        if (lkp != null) {
            return lkp;
        }
        NamedServicesProvider prov = Lookup.getDefault().lookup(NamedServicesProvider.class);
        if (prov != null && IN.get() == null) {
            IN.set(true);
            try {
                lkp = prov.create(path);
            } finally {
                IN.set(null);
            }
        } else {
            ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class);
            if (l == null) {
                l = Thread.currentThread().getContextClassLoader();
                if (l == null) {
                    l = NamedServicesProvider.class.getClassLoader();
                }
            }
            lkp = Lookups.metaInfServices(l, "META-INF/namedservices/" + path);
        }

        namedServicesProviders.put(path, new WeakReference<Lookup>(lkp));
        return lkp;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:NamedServicesProvider.java

示例13: getMetaInfLookup

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
private Lookup getMetaInfLookup() {
    return Lookups.metaInfServices(Thread.currentThread().getContextClassLoader());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:Deadlock73332Test.java

示例14: testURLMapperCallingFromMetaInfLookup

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public void testURLMapperCallingFromMetaInfLookup() {
    Lookup lkp = Lookups.metaInfServices(Thread.currentThread().getContextClassLoader());
    Object obj = lkp.lookup(Object.class);
    assertNotNull(obj);
    assertEquals(MyInstance2.class, obj.getClass());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:URLMapperTest.java

示例15: MyLkp

import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
private MyLkp(ClassLoader l) {
    super(Lookups.fixed(new Repository(FileUtil.createMemoryFileSystem())), Lookups.metaInfServices(l), Lookups.singleton(l));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:NbLoaderPoolResolverChangeTest.java


注:本文中的org.openide.util.lookup.Lookups.metaInfServices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。