本文整理汇总了Java中org.osgi.framework.Bundle.getBundleId方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.getBundleId方法的具体用法?Java Bundle.getBundleId怎么用?Java Bundle.getBundleId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.framework.Bundle
的用法示例。
在下文中一共展示了Bundle.getBundleId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initNamespaceHandlers
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
protected void initNamespaceHandlers(BundleContext extenderBundleContext) {
nsManager = new NamespaceManager(extenderBundleContext);
// register listener first to make sure any bundles in INSTALLED state
// are not lost
// if the property is defined and true, consider bundles in STARTED/LAZY-INIT state, otherwise use RESOLVED
boolean nsResolved = !Boolean.getBoolean("org.eclipse.gemini.blueprint.ns.bundles.started");
nsListener = new NamespaceBundleLister(nsResolved, this);
extenderBundleContext.addBundleListener(nsListener);
Bundle[] previousBundles = extenderBundleContext.getBundles();
for (Bundle bundle : previousBundles) {
// special handling for uber bundle being restarted
if ((nsResolved && OsgiBundleUtils.isBundleResolved(bundle)) || (!nsResolved && OsgiBundleUtils.isBundleActive(bundle)) || bundleId == bundle.getBundleId()) {
maybeAddNamespaceHandlerFor(bundle, false);
} else if (OsgiBundleUtils.isBundleLazyActivated(bundle)) {
maybeAddNamespaceHandlerFor(bundle, true);
}
}
// discovery finished, publish the resolvers/parsers in the OSGi space
nsManager.afterPropertiesSet();
}
示例2: findBundle
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
private static long findBundle(BundleContext context, String namePattern) {
Bundle[] installedBundles = context.getBundles();
for (int i = 0; i < installedBundles.length; i++) {
Bundle bundle = installedBundles[i];
if (bundle.getSymbolicName().matches(namePattern)) {
return bundle.getBundleId();
}
}
throw new RuntimeException("Cannot locate bundle with name pattern " + namePattern);
}
示例3: findBundle
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
private Bundle findBundle(String bsn) {
Bundle found = null;
for (Bundle bundle : this.bundleContext.getBundles()) {
if (bsn.equals(bundle.getSymbolicName()) && bundle.getState() != Bundle.UNINSTALLED) {
if (found != null && bundle.getBundleId() != found.getBundleId()) {
throw new IllegalArgumentException("Ambiguous bundle symbolic name " + bsn);
}
found = bundle;
}
}
return found;
}
示例4: createNamespaceFilter
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public static String createNamespaceFilter(BundleContext ctx) {
Bundle bnd = getDMCoreBundle(ctx);
if (bnd != null) {
return "(|(" + DM_CORE_ID + "=" + bnd.getBundleId() + ")(" + DM_CORE_TS + "=" + bnd.getLastModified()
+ "))";
}
return "";
}
示例5: compare
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public int compare(Bundle o1, Bundle o2) {
try {
return (int) (o2.getBundleId() - o1.getBundleId());
} catch (IllegalStateException ignored) {
return o1 == o2 ? 0 : 1; // cannot tell which is larger, but must provide a total ordering
}
}
示例6: getManagedContext
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public ConfigurableOsgiBundleApplicationContext getManagedContext(Bundle bundle) {
ConfigurableOsgiBundleApplicationContext context = null;
try {
Long id = new Long(bundle.getBundleId());
context = (ConfigurableOsgiBundleApplicationContext) managedContexts.get(id);
} catch (IllegalStateException _) {
// ignore
}
return context;
}
示例7: createNamespaceFilter
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public static String createNamespaceFilter(BundleContext ctx) {
Bundle bnd = getDMCoreBundle(ctx);
if (bnd != null) {
return "(|(" + DM_CORE_ID + "=" + bnd.getBundleId() + ")(" + DM_CORE_TS + "=" + bnd.getLastModified()
+ "))";
}
return "";
}
示例8: debugClassLoading
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
* Tries (through a best-guess attempt) to figure out why a given class
* could not be found. This method will search the given bundle and its
* classpath to determine the reason for which the class cannot be loaded.
*
* <p/> This method tries to be effective especially when the dealing with
* {@link NoClassDefFoundError} caused by failure of loading transitive
* classes (such as getting a NCDFE when loading <code>foo.A</code>
* because <code>bar.B</code> cannot be found).
*
* @param bundle the bundle to search for (and which should do the loading)
* @param className the name of the class that failed to be loaded in dot
* format (i.e. java.lang.Thread)
* @param rootClassName the name of the class that triggered the loading
* (i.e. java.lang.Runnable)
*/
public static void debugClassLoading(Bundle bundle, String className, String rootClassName) {
boolean trace = log.isTraceEnabled();
if (!trace)
return;
Dictionary dict = bundle.getHeaders();
String bname = dict.get(Constants.BUNDLE_NAME) + "(" + dict.get(Constants.BUNDLE_SYMBOLICNAME) + ")";
if (trace)
log.trace("Could not find class [" + className + "] required by [" + bname + "] scanning available bundles");
BundleContext context = OsgiBundleUtils.getBundleContext(bundle);
int pkgIndex = className.lastIndexOf('.');
// Reject global packages
if (pkgIndex < 0) {
if (trace)
log.trace("Class is not in a package, its unlikely that this will work");
return;
}
String packageName = className.substring(0, pkgIndex);
Version iversion = hasImport(bundle, packageName);
if (iversion != null && context != null) {
if (trace)
log.trace("Class is correctly imported as version [" + iversion + "], checking providing bundles");
Bundle[] bundles = context.getBundles();
for (int i = 0; i < bundles.length; i++) {
if (bundles[i].getBundleId() != bundle.getBundleId()) {
Version exported = checkBundleForClass(bundles[i], className, iversion);
// Everything looks ok, but is the root bundle importing the
// dependent class also?
if (exported != null && exported.equals(iversion) && rootClassName != null) {
for (int j = 0; j < bundles.length; j++) {
Version rootexport = hasExport(bundles[j], rootClassName.substring(0,
rootClassName.lastIndexOf('.')));
if (rootexport != null) {
// TODO -- this is very rough, check the bundle
// classpath also.
Version rootimport = hasImport(bundles[j], packageName);
if (rootimport == null || !rootimport.equals(iversion)) {
if (trace)
log.trace("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundles[j])
+ "] exports [" + rootClassName + "] as version [" + rootexport
+ "] but does not import dependent package [" + packageName
+ "] at version [" + iversion + "]");
}
}
}
}
}
}
}
if (hasExport(bundle, packageName) != null) {
if (trace)
log.trace("Class is exported, checking this bundle");
checkBundleForClass(bundle, className, iversion);
}
}
示例9: testReinstallJavaFxFail
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
@Test
public void testReinstallJavaFxFail() throws Exception
{
// Check OsgiFx bundle is not installed
Bundle bootBundle = getInstalledBundle(OSGIFX_GROUP_ID + "." + OSGIFX_BOOT_ARTIFACT_ID);
Assert.assertNull(bootBundle);
//Install OsgiFx bundle
session.execute(installCommand);
//Check installed
bootBundle = getInstalledBundle(OSGIFX_GROUP_ID + "." + OSGIFX_BOOT_ARTIFACT_ID);
Assert.assertNotNull(bootBundle);
long bundleId = bootBundle.getBundleId();
final long firstBootBundleId = bundleId;
// Check the bundle is in the installed state.
Assert.assertEquals("Bundle expected to be in the installed state.", bootBundle.getState(), Bundle.INSTALLED);
// Start the bundle
session.execute("start " + bundleId);
Assert.assertEquals("Bundle not started.", bootBundle.getState(), Bundle.ACTIVE);
// Uninstall the bundle
session.execute("uninstall " + bundleId);
bootBundle = getInstalledBundle(OSGIFX_GROUP_ID + "." + OSGIFX_BOOT_ARTIFACT_ID);
Assert.assertNull(bootBundle);
// Re-install the bundle
session.execute(installCommand);
bootBundle = getInstalledBundle(OSGIFX_GROUP_ID + "." + OSGIFX_BOOT_ARTIFACT_ID);
Assert.assertNotNull(bootBundle);
bundleId = bootBundle.getBundleId();
Assert.assertNotEquals(firstBootBundleId, bundleId);
// Try starting the re-installed bundle.
try
{
expectedException.expect(MultiException.class);
session.execute("start " + bundleId);
}
finally
{
bootBundle = getInstalledBundle(OSGIFX_GROUP_ID + "." + OSGIFX_BOOT_ARTIFACT_ID);
Assert.assertNotEquals("Boot bundle NOT expected to be ACTIVE" + bootBundle.getState(), Bundle.ACTIVE, bootBundle.getState());
}
}
示例10: isSystemBundle
import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
* Indicates if the given bundle is the system bundle or not.
*
* @param bundle OSGi bundle
* @return true if the given bundle is a fragment, false otherwise
*/
public static boolean isSystemBundle(Bundle bundle) {
Assert.notNull(bundle);
return (bundle.getBundleId() == 0);
}