当前位置: 首页>>代码示例>>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;未经允许,请勿转载。