本文整理汇总了Java中org.osgi.framework.Bundle.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.equals方法的具体用法?Java Bundle.equals怎么用?Java Bundle.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.framework.Bundle
的用法示例。
在下文中一共展示了Bundle.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJPAPackages
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
* Get all the relevant packages that the EclipseLink JPA provider exports or persistence packages it uses itself. These are needed
* so that the woven proxy (for runtime enhancement) can be used later on :)
*
* Note that differently to OpenJPA the relevant classes are actually in more than just one bundle (org.eclipse.persistence.jpa and org.eclipse.persistence.core
* at the time of this writing). Hence, we have to take more than just the packages of the JPA provider bundle into account ...
*
* @param jpaBundle
* @return
*/
private String[] getJPAPackages(Bundle jpaBundle) {
Set<String> result = new HashSet<String>();
for (Bundle b : context.getBundles()) {
BundleWiring bw = b.adapt(BundleWiring.class);
if (bw == null) {
continue;
}
boolean isJpaBundle = b.equals(jpaBundle);
List<BundleWire> wires = bw.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE);
for (BundleWire w : wires) {
String pkgName = (String)w.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE);
boolean add = isJpaBundle || pkgName.startsWith("org.eclipse.persistence");
if (add) {
result.add(getPkg(b, pkgName));
}
}
}
result.add(getPkg(context.getBundle(), "org.apache.aries.jpa.eclipselink.adapter.platform"));
LOG.debug("Found JPA packages {}", result);
return result.toArray(new String[0]);
}
示例2: 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...");
}
}
}
示例3: getImportedBundles
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public ImportedBundle[] getImportedBundles(Bundle bundle) {
boolean trace = log.isTraceEnabled();
PackageAdmin pa = getPackageAdmin();
// create map with bundles as keys and a list of packages as value
Map<Bundle, List<String>> importedBundles = new LinkedHashMap<Bundle, List<String>>(8);
// 1. consider required bundles first
// see if there are required bundle(s) defined
String[] entries = OsgiHeaderUtils.getRequireBundle(bundle);
// 1. if so, locate the bundles
for (int i = 0; i < entries.length; i++) {
String[] parsed = OsgiHeaderUtils.parseRequiredBundleString(entries[i]);
// trim the strings just to be on the safe side (some implementations allows whitespaces, some don't)
String symName = parsed[0].trim();
String versionRange = parsed[1].trim();
Bundle[] foundBundles = pa.getBundles(symName, versionRange);
if (!ObjectUtils.isEmpty(foundBundles)) {
Bundle requiredBundle = foundBundles[0];
// find exported packages
ExportedPackage[] exportedPackages = pa.getExportedPackages(requiredBundle);
if (exportedPackages != null)
addExportedPackages(importedBundles, requiredBundle, exportedPackages);
}
else {
if (trace) {
log.trace("Cannot find required bundle " + symName + "|" + versionRange);
}
}
}
// 2. determine imported bundles
// get all bundles
Bundle[] bundles = bundleContext.getBundles();
for (int i = 0; i < bundles.length; i++) {
Bundle analyzedBundle = bundles[i];
// if the bundle is already included (it's a required one), there's no need to look at it again
if (!importedBundles.containsKey(analyzedBundle)) {
ExportedPackage[] epa = pa.getExportedPackages(analyzedBundle);
if (epa != null)
for (int j = 0; j < epa.length; j++) {
ExportedPackage exportedPackage = epa[j];
Bundle[] importingBundles = exportedPackage.getImportingBundles();
if (importingBundles != null)
for (int k = 0; k < importingBundles.length; k++) {
if (bundle.equals(importingBundles[k])) {
addImportedBundle(importedBundles, exportedPackage);
}
}
}
}
}
List<ImportedBundle> importedBundlesList = new ArrayList<ImportedBundle>(importedBundles.size());
for (Map.Entry<Bundle, List<String>> entry : importedBundles.entrySet()) {
Bundle importedBundle = entry.getKey();
List<String> packages = entry.getValue();
importedBundlesList.add(new ImportedBundle(importedBundle,
(String[]) packages.toArray(new String[packages.size()])));
}
return (ImportedBundle[]) importedBundlesList.toArray(new ImportedBundle[importedBundlesList.size()]);
}