當前位置: 首頁>>代碼示例>>Java>>正文


Java Bundle.getBundleId方法代碼示例

本文整理匯總了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();
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:26,代碼來源:NamespaceHandlerActivator.java

示例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);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:11,代碼來源:ProductLauncher.java

示例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;
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:13,代碼來源:InstallerIntegrationTest.java

示例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 "";
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:9,代碼來源:BundleUtils.java

示例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
    }
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:8,代碼來源:ShutdownSorter.java

示例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;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:11,代碼來源:LifecycleManager.java

示例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 "";
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:9,代碼來源:BundleUtils.java

示例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);
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:75,代碼來源:DebugUtils.java

示例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());
    }
}
 
開發者ID:jtkb,項目名稱:flexfx,代碼行數:47,代碼來源:OsgiFxFailureTest.java

示例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);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:11,代碼來源:OsgiBundleUtils.java


注:本文中的org.osgi.framework.Bundle.getBundleId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。