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


Java BundleContext.installBundle方法代碼示例

本文整理匯總了Java中org.osgi.framework.BundleContext.installBundle方法的典型用法代碼示例。如果您正苦於以下問題:Java BundleContext.installBundle方法的具體用法?Java BundleContext.installBundle怎麽用?Java BundleContext.installBundle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.osgi.framework.BundleContext的用法示例。


在下文中一共展示了BundleContext.installBundle方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: installBundle

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
/**
 * Installs the specified jar bundle and adds the Bundle instance to the local bundle vector {@link #getBundleVector()}.
 * @param bundleJarFilePath the bundle jar file path
 */
public void installBundle(String bundleJarFilePath) {
	Bundle bundle = null;
	try {
		BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
		bundle = bundleContext.installBundle(bundleJarFilePath);
		if (this.debug) System.out.println("=> + " + bundle.getSymbolicName() + " installed.");
		
	} catch (BundleException bEx) {
		bEx.printStackTrace();
	}
	// --- Remind this bundle ---------------
	if (bundle!=null) this.getBundleVector().addElement(bundle);
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:18,代碼來源:ProjectBundleLoader.java

示例2: preProcessBundleContext

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
protected void preProcessBundleContext(BundleContext platformBundleContext) throws Exception {
	super.preProcessBundleContext(platformBundleContext);
	if (!customBundlesInstalled) {
		logger.info("Installing custom bundles...");
		InputStream stream = getClass().getResourceAsStream("/osgi-799-exp.jar");
		assertNotNull(stream);
		Bundle bundle = platformBundleContext.installBundle("osgi-799-exp", stream);
		bundle.start();

		stream = getClass().getResourceAsStream("/osgi-799-imp.jar");
		bundle = platformBundleContext.installBundle("osgi-799-imp", stream);
		bundle.start();

		customBundlesInstalled = true;
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:17,代碼來源:OSGI799Test.java

示例3: installAndStartBundle

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
private void installAndStartBundle(BundleContext context, Resource resource) throws Exception {
	// install & start
	Bundle bundle = context.installBundle("[onTheFly-test-bundle]" + ClassUtils.getShortName(getClass()) + "["
			+ hashCode() + "]", resource.getInputStream());

	String bundleString = OsgiStringUtils.nullSafeNameAndSymName(bundle);
	boolean debug = logger.isDebugEnabled();

	if (debug) {
		logger.debug("Test bundle [" + bundleString + "] successfully installed");
           logger.debug(Constants.FRAMEWORK_BOOTDELEGATION + " = " + context.getProperty(Constants.FRAMEWORK_BOOTDELEGATION));
       }
	bundle.start();
	if (debug) {
		logger.debug("Test bundle [" + bundleString + "] successfully started");
       }
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:18,代碼來源:AbstractOnTheFlyBundleCreatorTests.java

示例4: preProcessBundleContext

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
protected void preProcessBundleContext(BundleContext platformBundleContext) throws Exception {
	super.preProcessBundleContext(platformBundleContext);
	if (!noRootCPTestBundleInstalled) {
		logger.info("Installing no root cp bundle...");
		InputStream stream = getClass().getResourceAsStream("/norootcpbundle.jar");
		Bundle bundle = platformBundleContext.installBundle("norootcpbundle", stream);
		bundle.start();
		noRootCPTestBundleInstalled = true;
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:11,代碼來源:BundleClassPathWildcardTest.java

示例5: preProcessBundleContext

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
protected void preProcessBundleContext(BundleContext platformBundleContext) throws Exception {
	super.preProcessBundleContext(platformBundleContext);
	if (!bundleInstalled) {
		logger.info("Installing OSGi-723 bundle...");
		InputStream stream = getClass().getResourceAsStream("/osgi-723.jar");
		Bundle bundle = platformBundleContext.installBundle("osgi-723", stream);
		bundle.start();
		bundleInstalled = true;
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:11,代碼來源:OSGI723Test.java

示例6: main

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
/**
 * @param args
 *            mix of arguments from the OSGI and for the application
 * @throws Exception
 *             Exceptions propagated from the Equinox platform
 */
public static void main(String[] args) throws Exception {

	if (args == null || args.length == 0) {
		args = new String[] {};
	}
	// is user passed args are mixture of plain platform arguments and arguments for
	// the (later) invoked bundle, then now is the time to process them.

	String[] platformArgs = new String[] { /* defaults are in ProductLauncher.startPlatform */ };

	/** parameters for the product call, e.g. parameters for the N4JSC.class */
	String[] appCallArgs = args;

	List<String> bundlesToInstall = getInstallableBundlesNames(PluginsToLoadConstants.BUNDLES_LIST_RESOURCE,
			PluginsToLoadConstants.PLUGINS_SEPARATOR);
	if (bundlesToInstall.isEmpty())
		throw new RuntimeException("No bundles to load discovered");

	final Path osgiConfigurationArea = Files.createTempDirectory(".n4jsc");
	if (!osgiConfigurationArea.toFile().exists())
		throw new RuntimeException("Cannot obtain working directory");

	try {
		BundleContext context = startPlatform(platformArgs, osgiConfigurationArea);

		Set<String> installedBundleDescriptions = preLaodedBundlesNamePtterns(context);
		log("start install bundles");
		for (Iterator<String> iterator = bundlesToInstall.iterator(); iterator.hasNext();) {
			String bundle = iterator.next();
			if (isBundleLoaded(bundle, installedBundleDescriptions)) {
				log("SKIP INSTALL  " + bundle);
				continue;
			}
			InputStream bndInputStream = getResourceAsStream(bundle);
			Objects.requireNonNull(bndInputStream, "Cannot obtain resource for bundle " + bundle);
			String loc = BUNDLE_INSTALL_SCHEME + bundle;
			log("INSTALL " + loc);
			context.installBundle(loc, bndInputStream);
			bndInputStream.close();
		}

		log("load bundle and invoke its method");
		invoke(context, findBundle(context, MainBundleConstants.MAIN_BUNDLE_NAME_PATTERN),
				MainBundleConstants.MAIN_BUNDLE_CLASS_FQN, MainBundleConstants.MAIN_BUNDLE_METHOD_NAME,
				appCallArgs);
		log("invocation finished");

		shutdownPlatform();

	} finally {
		log("finally");

		String errors = "";

		cleanupWorkArea(osgiConfigurationArea);
		if (osgiConfigurationArea.toFile().exists())
			errors += ("ERROR: Cannot cleanup working area : " + osgiConfigurationArea.toString() + "\n");

		cleanupThreads();
		if (ThreadsUtil.getIdentifiedThredsCount(EQUINOX_THREAD_DESCRIPTION_TOKEN) > 0)
			errors += ("ERROR: There are still platform threads running:\n"
					+ ThreadsUtil.getThreadsInfo(EQUINOX_THREAD_DESCRIPTION_TOKEN));

		if (!errors.isEmpty())
			System.err.println(errors);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:74,代碼來源:ProductLauncher.java

示例7: installTestBundle

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
Bundle installTestBundle(BundleContext context) throws Exception {
	Resource res = getLocator().locateArtifact("org.eclipse.gemini.blueprint.iandt", "export-import-dependency-bundle",
			getSpringDMVersion());
	return context.installBundle("test-bundle", res.getInputStream());
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:6,代碼來源:ExporterWithOptionalAndMandatoryImportersTest.java

示例8: postProcessBundleContext

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
protected void postProcessBundleContext(BundleContext context) throws Exception {
	super.postProcessBundleContext(context);
	File expandedBundle = new File(".", "target/test-classes/expanded-bundle.jar");
	System.out.println("Installing expanded bundle from " + expandedBundle.getCanonicalPath());
	context.installBundle(REFERENCE_PROTOCOL + expandedBundle.getCanonicalPath());
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:7,代碼來源:EquinoxFileTests.java


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