• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FelixConstants类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.felix.framework.util.FelixConstants的典型用法代码示例。如果您正苦于以下问题:Java FelixConstants类的具体用法?Java FelixConstants怎么用?Java FelixConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FelixConstants类属于org.apache.felix.framework.util包,在下文中一共展示了FelixConstants类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: requireThatBundlesCanBeInstalled

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
@Test
public void requireThatBundlesCanBeInstalled() throws BundleException {
    FelixFramework felix = TestDriver.newOsgiFramework();
    felix.start();

    Bundle bundle = felix.installBundle("cert-a.jar").get(0);
    assertNotNull(bundle);

    Iterator<Bundle> it = felix.bundles().iterator();
    assertNotNull(it);
    assertTrue(it.hasNext());
    assertEquals(FelixConstants.SYSTEM_BUNDLE_SYMBOLICNAME, it.next().getSymbolicName());
    assertTrue(it.hasNext());
    assertSame(bundle, it.next());
    assertFalse(it.hasNext());

    felix.stop();
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:19,代码来源:FelixFrameworkIntegrationTest.java


示例2: mergeProperties

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
private void mergeProperties(Properties frameworkProperties, Properties addionalProperties) {
    for (Object key : addionalProperties.keySet()) {
        String propertyKey = key.toString();
        if (FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA.equals(propertyKey)) {
            String existingPackages = frameworkProperties.getProperty(propertyKey);
            if (existingPackages == null) {
                frameworkProperties.setProperty(propertyKey,
                        addionalProperties.getProperty(propertyKey));
            } else {
                frameworkProperties.setProperty(propertyKey, existingPackages + ","
                        + addionalProperties.getProperty(propertyKey));
            }
        } else {
            frameworkProperties.setProperty(propertyKey,
                    addionalProperties.getProperty(propertyKey));
        }
    }

}
 
开发者ID:Communote,项目名称:communote-server,代码行数:20,代码来源:OSGiManagement.java


示例3: generateOSGiFrameworkConfig

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
private HashMap<String, String> generateOSGiFrameworkConfig() {
    String osgiFrameworkPackage = Bundle.class.getPackage().getName();
    String goPluginApiPackage = GoPluginApiMarker.class.getPackage().getName();
    String subPackagesOfGoPluginApiPackage = goPluginApiPackage + ".*";
    String internalServicesPackage = PluginHealthService.class.getPackage().getName();
    String javaxPackages = "javax.*";
    String orgXmlSaxPackages = "org.xml.sax, org.xml.sax.*";
    String orgW3cDomPackages = "org.w3c.dom, org.w3c.dom.*";

    HashMap<String, String> config = new HashMap<>();
    config.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK);
    config.put(Constants.FRAMEWORK_BOOTDELEGATION, osgiFrameworkPackage + ", " + goPluginApiPackage + ", " + subPackagesOfGoPluginApiPackage
            + ", " + internalServicesPackage + ", " + javaxPackages + ", " + orgXmlSaxPackages + ", " + orgW3cDomPackages);
    config.put(Constants.FRAMEWORK_STORAGE_CLEAN, "onFirstInit");
    config.put(BundleCache.CACHE_LOCKING_PROP, "false");
    config.put(FelixConstants.SERVICE_URLHANDLERS_PROP, "false");
    return config;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:19,代码来源:FelixGoPluginOSGiFramework.java


示例4: requireThatLifecycleWorks

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
@Test
public void requireThatLifecycleWorks() throws Exception {
    MyModule module = new MyModule();
    ApplicationLoader loader = new ApplicationLoader(TestDriver.newOsgiFramework(),
                                                     Arrays.asList(module));
    loader.init("app-a.jar", false);

    assertFalse(module.init.await(100, TimeUnit.MILLISECONDS));
    assertFalse(module.start.await(100, TimeUnit.MILLISECONDS));
    loader.start();
    assertTrue(module.init.await(60, TimeUnit.SECONDS));
    assertTrue(module.start.await(60, TimeUnit.SECONDS));

    Iterator<Bundle> it = loader.osgiFramework().bundles().iterator();
    assertTrue(it.hasNext());
    Bundle bundle = it.next();
    assertNotNull(bundle);
    assertEquals(FelixConstants.SYSTEM_BUNDLE_SYMBOLICNAME,
                 bundle.getSymbolicName());
    assertTrue(it.hasNext());
    assertNotNull(bundle = it.next());
    assertEquals("com.yahoo.vespa.jdisc_core.app-a",
                 bundle.getSymbolicName());
    assertFalse(it.hasNext());

    assertFalse(module.stop.await(100, TimeUnit.MILLISECONDS));
    assertFalse(module.destroy.await(100, TimeUnit.MILLISECONDS));
    loader.stop();
    assertTrue(module.stop.await(60, TimeUnit.SECONDS));
    assertTrue(module.destroy.await(60, TimeUnit.SECONDS));

    loader.destroy();
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:34,代码来源:ApplicationLoaderIntegrationTest.java


示例5: initSystemBundles

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
/**
 * Scans the plugins folder for included bundles and specific start level folders.
 *
 * @param frameworkProperties
 *            The framework properties, to add this.
 * @param rootPathToSystemPlugins
 *            The root path the folder including system bundles.
 */
private void initSystemBundles(Properties frameworkProperties, String rootPathToSystemPlugins) {
    LOG.info("Scanning for system bundles: {}", rootPathToSystemPlugins);
    File rootDirectory = new File(rootPathToSystemPlugins);
    if (!rootDirectory.isDirectory()) {
        LOG.warn("The root folder for plugins may not be a file.");
        return;
    }
    Integer defaultStartLevel = NumberUtils.toInt(
            frameworkProperties.getProperty(FelixConstants.BUNDLE_STARTLEVEL_PROP),
            FelixConstants.FRAMEWORK_DEFAULT_STARTLEVEL);
    for (File file : rootDirectory.listFiles()) {
        if (file.isFile()) {
            addBundleForStartLevel(frameworkProperties, defaultStartLevel.toString(),
                    defaultStartLevel, file);
        } else {
            LOG.debug("Scanning directory for bundles: {}", file.getAbsolutePath());
            for (File subFile : file.listFiles()) {
                if (subFile.isFile()) {
                    addBundleForStartLevel(frameworkProperties, file.getName(),
                            defaultStartLevel, subFile);
                } else {
                    LOG.error("Bundle directories must not contain directories: {}",
                            file.getAbsolutePath());
                }
            }
        }
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:37,代码来源:OSGiManagement.java


示例6: prepareFramework

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
private void prepareFramework() {
    fileInstall = new FileInstall();
    propertiesDictionary = new Hashtable<String, String>();
    StartupProperties startupProperties = CommunoteRuntime.getInstance()
            .getConfigurationManager().getStartupProperties();
    propertiesDictionary.put(DirectoryWatcher.DIR, startupProperties.getPluginDir()
            .getAbsolutePath());
    propertiesDictionary.put(DirectoryWatcher.NO_INITIAL_DELAY, Boolean.TRUE.toString());
    propertiesDictionary.put(DirectoryWatcher.START_NEW_BUNDLES, Boolean.TRUE.toString());
    propertiesDictionary.put(DirectoryWatcher.LOG_LEVEL, Integer.toString(4));
    Properties frameworkProperties = loadFrameworkProperties();
    List<BundleActivator> activatorList = new ArrayList<BundleActivator>();
    activatorList.add(fileInstall);
    frameworkProperties.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, activatorList);
    // TODO better add a setSystemBundlesLocation method
    String pathToWebInf = CommunoteRuntime.getInstance().getApplicationInformation()
            .getApplicationRealPath()
            + "WEB-INF" + File.separator;
    initSystemBundles(frameworkProperties, pathToWebInf + "plugins");
    frameworkProperties.put(Constants.FRAMEWORK_STORAGE, OSGiHelper.getBundleBasePath()
            .getAbsolutePath() + File.separator + "bundle-cache");
    try {
        framework = new Felix(frameworkProperties);
        framework.init();
        AutoProcessor.process(frameworkProperties, framework.getBundleContext());
        framework.getBundleContext().addBundleListener(this);
    } catch (BundleException e) {
        throw new BeanCreationException(
                "Starting OSGi framework failed because of a BundleException.", e);
    }
    LOG.info("OSGi Framework initialized.");
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:33,代码来源:OSGiManagement.java


示例7: HostApplication

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
public HostApplication() throws IOException {
    // Create a configuration property map.
    Map<String, Object> config = new HashMap<String, Object>();
    // Create host activator;
    m_activator = new HostActivator();
    List<BundleActivator> list = new ArrayList<BundleActivator>();
    list.add(m_activator);
    config.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
    config.put(FelixConstants.FRAMEWORK_STORAGE, "target/felix");
    config.put(FelixConstants.LOG_LEVEL_PROP, "5");

    cleanUp("target/felix");

    try
    {
        // Now create an instance of the framework with
        // our configuration properties.
        m_felix = new Felix(config);
        // Now start Felix instance.
        m_felix.start();
    }
    catch (Exception ex)
    {
        System.err.println("Could not create framework: " + ex);
        ex.printStackTrace();
    }
}
 
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:28,代码来源:HostApplication.java


示例8: startPluginContainer

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
private void startPluginContainer() throws BundleException, Exception {
    Map<String, String> config = new HashMap<>();
    config.put(FelixConstants.ACTIVATION_LAZY, "false");
    config.put("felix.cache.locking", "false");
    config.put("felix.auto.deploy.dir", "install");
    config.put("felix.auto.deploy.action", "install,start");
    config.put("org.osgi.framework.system.packages.extra",
            "javafx.event,"
            + "org.badvision.outlaweditor.api,"
            + "org.badvision.outlaweditor.data,"
            + "org.badvision.outlaweditor.data.xml,"
            + "org.badvision.outlaweditor.ui,"
            + "org.osgi.framework");
    // MH: Had to add these to allow plugin to access basic Java XML classes, 
    //     and other stuff you'd think would just be default.
    config.put("org.osgi.framework.bootdelegation", 
            "sun.*,"
            + "com.sun.*,"
            + "org.w3c.*,"
            + "org.xml.*,"
            + "javax.xml.*");
    felix = new Felix(config);
    felix.start();
    felix.getBundleContext().registerService(ApplicationState.class, this, null);
    tracker = new ServiceTracker(felix.getBundleContext(), MenuAction.class, null);
    tracker.open();
    Activator scrActivator = new Activator();
    scrActivator.start(felix.getBundleContext());
    AutoProcessor.process(config, felix.getBundleContext());
}
 
开发者ID:badvision,项目名称:lawless-legends,代码行数:31,代码来源:Application.java


示例9: processConfiguration

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
private static void processConfiguration(Properties configuration) {
	configuration.put(FelixConstants.LOG_LOGGER_PROP, new FelixLoggerAdapter());
	LOGGER.fine("Felix configuration: " + configuration);
}
 
开发者ID:to2mbn,项目名称:LoliXL,代码行数:5,代码来源:Main.java


示例10: FelixManager

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
private FelixManager() {
        Map<String, Object> config = new HashMap<>();

        // Cache File for bundle storage
        File cache = new File("/data/data/org.inaetics.ails.android/felixcache");
        System.out.println("Creating cache: " + cache.mkdirs());
        config.put(Constants.FRAMEWORK_STORAGE, cache.toString());

        // Framework bundle
        config.put(FelixConstants.SERVICE_URLHANDLERS_PROP, "false");
        config.put("org.osgi.framework.bundle.parent", "framework");

        // Amdatu shit
        config.put("org.amdatu.remote.discovery.etcd.connecturl", "http://172.17.8.20:2379");
        config.put("org.amdatu.remote.discovery.etcd.rootpath", "/inaetics/discovery");
//        config.put("org.amdatu.remote.admin.http.host", "eigen ip");
//        config.put("org.apache.felix.http.host", "eigen ip");

        // Bundle Activators
        config.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, Arrays.asList(
                // Amdatu remote services bundles
                new org.amdatu.remote.admin.http.Activator(),
                new org.amdatu.remote.discovery.etcd.Activator(),
                new org.amdatu.remote.topology.promiscuous.Activator(),

                // AILS bundles
                new DeviceControllerActivator(),
                new DeviceDataStoreActivator(),

                new WiFiProfileFactoryActivatorAndroid(applicationContext)
        ));

        // Startup Felix
        felix = new Felix(config);
        
        try {
            felix.start();
        } catch (BundleException e) {
            throw new RuntimeException("Felix could not be started", e);
        }

        bundleContext = felix.getBundleContext();
        dependencyManager = new DependencyManager(bundleContext);
    }
 
开发者ID:INAETICS,项目名称:AILS_Demonstrator,代码行数:45,代码来源:FelixManager.java


示例11: doLaunch

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
public void doLaunch() {
    // Create a case-insensitive configuration property map.
    StringMap configMap = new StringMap(false);
    // Configure the Felix instance to be embedded.
    // configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
    // Add core OSGi packages to be exported from the class path
    // via the system bundle.
    configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.3.0," + "org.osgi.service.packageadmin; version=1.2.0,"
                    + "org.osgi.service.startlevel; version=1.0.0," + "org.osgi.service.url; version=1.0.0");

    configMap.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);

    // Explicitly specify the directory to use for caching bundles.
    // configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "cache");

    try {
        // Create host activator;

        List<Object> list = new ArrayList<Object>();

        // list.add(new HostActivator());
        configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.xml.sax, org.xml.sax.helpers, javax.xml.parsers, javax.naming");
        configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
        configMap.put("felix.log.level", "4");

        // Now create an instance of the framework with
        // our configuration properties and activator.
        felix = new Felix(configMap);
        felix.init();

        // otherProps.put(Constants.FRAMEWORK_STORAGE, "bundles");

        otherProps.put(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY, AutoProcessor.AUTO_DEPLOY_DIR_VALUE);
        otherProps.put(AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY, AutoProcessor.AUTO_DEPLOY_START_VALUE + "," + AutoProcessor.AUTO_DEPLOY_INSTALL_VALUE);

        BundleContext felixBudleContext = felix.getBundleContext();

        AutoProcessor.process(otherProps, felixBudleContext);
        // listen to errors
        felixBudleContext.addFrameworkListener(frameworkErrorListener);
        felixBudleContext.addBundleListener(myBundleListener);
        // Now start Felix instance.
        felix.start();
        System.out.println("felix started");

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:50,代码来源:FelixHost.java


示例12: doLaunch

import org.apache.felix.framework.util.FelixConstants; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void doLaunch() {
  // Create a case-insensitive configuration property map.
  Map configMap = new StringMap(false);
  // Configure the Felix instance to be embedded.
  // configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
  // Add core OSGi packages to be exported from the class path
  // via the system bundle.
  configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
      "org.osgi.framework; version=1.3.0,"
          + "org.osgi.service.packageadmin; version=1.2.0,"
          + "org.osgi.service.startlevel; version=1.0.0,"
          + "org.osgi.service.url; version=1.0.0");

  configMap.put(Constants.FRAMEWORK_STORAGE_CLEAN,
      Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);

  // Explicitly specify the directory to use for caching bundles.
  // configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "cache");

  try {
    // Create host activator;

    List list = new ArrayList();

    // list.add(new HostActivator());
    configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
        "org.xml.sax, org.xml.sax.helpers, javax.xml.parsers, javax.naming");
    configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
    configMap.put("felix.log.level", "4");

    // Now create an instance of the framework with
    // our configuration properties and activator.
    felix = new Felix(configMap);
    felix.init();

    // otherProps.put(Constants.FRAMEWORK_STORAGE, "bundles");

     otherProps.put(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY,
     AutoProcessor.AUTO_DEPLOY_DIR_VALUE);
    otherProps.put(AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY,
        AutoProcessor.AUTO_DEPLOY_START_VALUE + ","
            + AutoProcessor.AUTO_DEPLOY_INSTALL_VALUE);

    BundleContext felixBudleContext = felix.getBundleContext();

    AutoProcessor.process(otherProps, felixBudleContext);
    // listen to errors
    felixBudleContext.addFrameworkListener(frameworkErrorListener);
    felixBudleContext.addBundleListener(myBundleListener);
    // Now start Felix instance.
    felix.start();
    System.out.println("felix started");

  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:59,代码来源:FelixHost.java



注:本文中的org.apache.felix.framework.util.FelixConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Variable类代码示例发布时间:2022-05-22
下一篇:
Java FSINFO3Response类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap