本文整理汇总了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);
}
示例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));
}
示例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);
}
}
示例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...");
}
}
}