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