當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。