本文整理匯總了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);
}
示例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;
}
}
示例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");
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例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());
}
示例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());
}