當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。