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


Java Bundle.getResources方法代码示例

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


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

示例1: findResources

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
@Override
public Enumeration<URL> findResources(String name) {
    //Netigso.start();
    Bundle b = bundle;
    if (b == null) {
        LOG.log(Level.WARNING, "Trying to load resource before initialization finished {0}", name);
        return Enumerations.empty();
    }
    Enumeration ret = null;
    try {
        if (b.getState() != Bundle.UNINSTALLED) {
            ret = b.getResources(name);
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    return ret == null ? Enumerations.<URL>empty() : NbCollections.checkedEnumerationByFilter(ret, URL.class, true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:NetigsoLoader.java

示例2: findResources

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
protected @Override Enumeration<URL> findResources(String name) throws IOException {
    List<Enumeration<URL>> resourcess = new ArrayList<Enumeration<URL>>();
    for (Bundle b : bundles()) {
        Enumeration<?> resourcesRaw = b.getResources(name);
        if (resourcesRaw == null) {
            // Oddly, this is permitted.
            continue;
        }
        Enumeration<URL> resources = NbCollections.checkedEnumerationByFilter(resourcesRaw, URL.class, true);
        if (resources != null) {
            resourcess.add(resources);
        }
    }
    return Enumerations.concat(Collections.enumeration(resourcess));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:OSGiClassLoader.java

示例3: testCallGetResourcesOnADifferentBundle

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

示例4: maybeAddNamespaceHandlerFor

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Registers the namespace plugin handler if this bundle defines handler mapping or schema mapping resources.
 * 
 * <p/> This method considers only the bundle space and not the class space.
 * 
 * @param bundle target bundle
 * @param isLazyBundle indicator if the bundle analyzed is lazily activated
 */
public void maybeAddNamespaceHandlerFor(Bundle bundle, boolean isLazyBundle) {
	// Ignore system bundle
	if (OsgiBundleUtils.isSystemBundle(bundle)) {
		return;
	}

	// Ignore non-wired Spring DM bundles
	if ("org.eclipse.gemini.blueprint.core".equals(bundle.getSymbolicName())
			&& !bundle.equals(BundleUtils.getDMCoreBundle(context))) {
		return;
	}

	boolean debug = log.isDebugEnabled();
	boolean trace = log.isTraceEnabled();
	// FIXME: Blueprint uber bundle temporary hack
	// since embedded libraries are not discovered by findEntries and inlining them doesn't work
	// (due to resource classes such as namespace handler definitions)
	// we use getResource

	boolean hasHandlers = false, hasSchemas = false;

	if (trace) {
		log.trace("Inspecting bundle " + bundle + " for Spring namespaces");
	}
	// extender/RFC 124 bundle
	if (context.getBundle().equals(bundle)) {

		try {
			Enumeration<?> handlers = bundle.getResources(META_INF + SPRING_HANDLERS);
			Enumeration<?> schemas = bundle.getResources(META_INF + SPRING_SCHEMAS);

			hasHandlers = handlers != null;
			hasSchemas = schemas != null;

			if (hasHandlers && debug) {
				log.debug("Found namespace handlers: " + Collections.list(schemas));
			}
		} catch (IOException ioe) {
			log.warn("Cannot discover own namespaces", ioe);
		}
	} else {
		hasHandlers = bundle.findEntries(META_INF, SPRING_HANDLERS, false) != null;
		hasSchemas = bundle.findEntries(META_INF, SPRING_SCHEMAS, false) != null;
	}

	// if the bundle defines handlers
	if (hasHandlers) {

		if (trace)
			log.trace("Bundle " + bundle + " provides Spring namespace handlers...");

		if (isLazyBundle) {
			this.namespacePlugins.addPlugin(bundle, isLazyBundle, true);
		} else {
			// check type compatibility between the bundle's and spring-extender's spring version
			if (hasCompatibleNamespaceType(bundle)) {
				this.namespacePlugins.addPlugin(bundle, isLazyBundle, false);
			} else {
				if (debug)
					log.debug("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle)
							+ "] declares namespace handlers but is not compatible with extender [" + extenderInfo
							+ "]; ignoring...");
			}
		}
	} else {
		// bundle declares only schemas, add it though the handlers might not be compatible...
		if (hasSchemas) {
			this.namespacePlugins.addPlugin(bundle, isLazyBundle, false);
			if (trace)
				log.trace("Bundle " + bundle + " provides Spring schemas...");
		}
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:82,代码来源:NamespaceManager.java


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