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


Java Bundle.getResource方法代码示例

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


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

示例1: testCallGetResourceOnADifferentBundle

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public void testCallGetResourceOnADifferentBundle() throws Exception {
	// find bundles
	Bundle[] bundles = bundleContext.getBundles();
	for (int i = 1; i < bundles.length; i++) {
		Bundle bundle = bundles[i];
		logger.debug("calling #getResource on bundle " + OsgiStringUtils.nullSafeNameAndSymName(bundle));
		URL url = bundle.getResource(LOCATION);
		if (!OsgiBundleUtils.isFragment(bundle))
			assertNotNull("bundle " + OsgiStringUtils.nullSafeNameAndSymName(bundle) + " contains no META-INF/",
					url);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:13,代码来源:CallingResourceOnDifferentBundlesTest.java

示例2: findResource

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
@Override
public URL findResource(String name) {
    //Netigso.start();
    Bundle b = bundle;
    if (b == null) {
        LOG.log(Level.WARNING, "Trying to load resource before initialization finished {0}", name);
        return null;
    }
    return b.getResource(name);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:NetigsoLoader.java

示例3: layersFor

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
private static URL[] layersFor(List<Bundle> bundles) {
    List<URL> layers = new ArrayList<URL>(2);
    for (Bundle b : bundles) {
        if (b.getSymbolicName().equals("org.netbeans.modules.autoupdate.ui")) { // NOI18N
            // Won't work anyway, so don't even try.
            continue;
        }
        String explicit = (String) b.getHeaders().get("OpenIDE-Module-Layer");
        if (explicit != null) {
            String base, ext;
            int idx = explicit.lastIndexOf('.'); // NOI18N
            if (idx == -1) {
                base = explicit;
                ext = ""; // NOI18N
            } else {
                base = explicit.substring(0, idx);
                ext = explicit.substring(idx);
            }
            for (String suffix : NbCollections.iterable(NbBundle.getLocalizingSuffixes())) {
                URL layer = b.getResource(base + suffix + ext);
                if (layer != null) {
                    layers.add(layer);
                } else if (suffix.isEmpty()) {
                    LOG.log(Level.WARNING, "no such layer {0} in {1} of state {2}", new Object[] {explicit, b.getSymbolicName(), b.getState()});
                }
            }
        }
        URL generated = b.getResource("META-INF/generated-layer.xml");
        if (generated != null) {
            layers.add(generated);
        }
    }
    return layers.toArray(new URL[layers.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:OSGiRepository.java

示例4: findResource

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
protected @Override URL findResource(String name) {
    for (Bundle b : bundles()) {
        URL resource = b.getResource(name);
        if (resource != null) {
            return resource;
        }
    }
    return super.findResource(name);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:OSGiClassLoader.java

示例5: testNamespaceFilesOnTheClassPath

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public void testNamespaceFilesOnTheClassPath() throws Exception {
	Bundle bundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext, BND_SYM_NAME);
	assertNotNull("cannot find handler bundle", bundle);
	URL handlers = bundle.getResource("META-INF/spring.handlers");
	URL schemas = bundle.getResource("META-INF/spring.schemas");

	assertNotNull("cannot find a handler inside the custom bundle", handlers);
	assertNotNull("cannot find a schema inside the custom bundle", schemas);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:10,代码来源:NamespaceProviderAndConsumerTest.java

示例6: testNamespaceFilesOnTheClassPath

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public void testNamespaceFilesOnTheClassPath() throws Exception {
	// simple code to trigger an import for this package
	assertNotNull(NamespaceHandlerResolver.class);

	Bundle bundle = bundleContext.getBundle();
	URL handlers = bundle.getResource("META-INF/spring.handlers");
	URL schemas = bundle.getResource("META-INF/spring.schemas");

	assertNotNull(handlers);
	assertNotNull(schemas);

}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:13,代码来源:EmbeddedNamespaceLibraryTest.java

示例7: pathExists

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Check if a path exists
 *
 * @param bundle The Bundle to fetch resource
 * @param path The path to check
 * @return true or false
 */
private static boolean pathExists(Bundle bundle, String path){
    boolean response = false;
    if (bundle != null && path != null){
        URL url = bundle.getResource(path);
        if ( url != null ){
            response = true;
        }
    }
    return response;
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:18,代码来源:JahiaUtils.java

示例8: getInputStream

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Get input stream by view
 *
 * @param bundle The bundle used to obtain resource
 * @param path The path to get resource
 * @return inputStream
 */
public static InputStream getInputStream(Bundle bundle, String path){
    InputStream inputStream = null;
    if (bundle != null && path != null){
        URL url = bundle.getResource(path);
        if ( url != null ){
            try {
                inputStream = url.openStream();
            }catch (IOException ioException){
                LOG.error(LOG_PRE+ " Error getting InputStream For URL: {}: ",url.getPath(), ioException);
            }
        }
    }
    return inputStream;
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:22,代码来源:JahiaUtils.java


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