当前位置: 首页>>代码示例>>Java>>正文


Java PojoServiceRegistryFactory类代码示例

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


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

示例1: apply

import org.apache.felix.connect.launch.PojoServiceRegistryFactory; //导入依赖的package包/类
@Override
public Statement apply(Statement statement, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            Map<String, Object> config = new HashMap<>();
            ClasspathScanner scanner = new ClasspathScanner();
            List<BundleDescriptor> bundles = scanner.scanForBundles(bundleFilter);
            config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
            registry = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
            statement.evaluate();
        }
    };
}
 
开发者ID:Microbule,项目名称:microbule,代码行数:15,代码来源:OsgiRule.java

示例2: createBundleContext

import org.apache.felix.connect.launch.PojoServiceRegistryFactory; //导入依赖的package包/类
public static BundleContext createBundleContext(String name, String bundleFilter, TinyBundle bundle) throws Exception {
    // ensure felix-connect stores bundles in an unique target directory
    String uid = "" + System.currentTimeMillis();
    String tempDir = "target/bundles/" + uid;
    System.setProperty("org.osgi.framework.storage", tempDir);
    createDirectory(tempDir);

    // use another directory for the jar of the bundle as it cannot be in the same directory
    // as it has a file lock during running the tests which will cause the temp dir to not be
    // fully deleted between tests
    createDirectory("target/test-bundles");

    List<BundleDescriptor> bundles = new LinkedList<>();

    if (bundle != null) {
        String jarName = name.toLowerCase(Locale.ENGLISH) + "-" + uid + ".jar";
        bundles.add(getBundleDescriptor("target/test-bundles/" + jarName, bundle));
    }

    List<BundleDescriptor> bundleDescriptors = getBundleDescriptors(bundleFilter);
    // let's put configadmin before blueprint.core
    int idx1 = -1;
    int idx2 = -1;
    for (int i = 0; i < bundleDescriptors.size(); i++) {
        BundleDescriptor bd = bundleDescriptors.get(i);
        if ("org.apache.felix.configadmin".equals(bd.getHeaders().get("Bundle-SymbolicName"))) {
            idx1 = i;
        }
        if ("org.apache.aries.blueprint.core".equals(bd.getHeaders().get("Bundle-SymbolicName"))) {
            idx2 = i;
        }
    }
    if (idx1 >= 0 && idx2 >= 0 && idx1 > idx2) {
        bundleDescriptors.add(idx2, bundleDescriptors.remove(idx1));
    }

    // get the bundles
    bundles.addAll(bundleDescriptors);

    if (LOG.isDebugEnabled()) {
        for (int i = 0; i < bundles.size(); i++) {
            BundleDescriptor desc = bundles.get(i);
            LOG.debug("Bundle #{} -> {}", i, desc);
        }
    }

    // setup felix-connect to use our bundles
    Map<String, Object> config = new HashMap<String, Object>();
    config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);

    // create pojorsr osgi service registry
    PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
    return reg.getBundleContext();
}
 
开发者ID:mattrpav,项目名称:blueprint-test,代码行数:55,代码来源:BlueprintHelper.java


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