當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceReference.getUsingBundles方法代碼示例

本文整理匯總了Java中org.osgi.framework.ServiceReference.getUsingBundles方法的典型用法代碼示例。如果您正苦於以下問題:Java ServiceReference.getUsingBundles方法的具體用法?Java ServiceReference.getUsingBundles怎麽用?Java ServiceReference.getUsingBundles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.osgi.framework.ServiceReference的用法示例。


在下文中一共展示了ServiceReference.getUsingBundles方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findDependentContainersRecursively

import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
/**
 * Recursively finds the services registered by the given bundle and the bundles using those services.
 * User bundles that have an associated blueprint container are added to containerBundles. In addition,
 * if a registered service has an associated config system Module, as determined via the presence of
 * certain service properties, the ModuleIdentifier is added to the configModules list.
 *
 * @param bundle the bundle to traverse
 * @param containerBundles the current set of bundles containing blueprint containers
 * @param configModules the current set of bundles containing config modules
 */
private void findDependentContainersRecursively(final Bundle bundle, final Set<Bundle> containerBundles,
        final List<Entry<String, ModuleIdentifier>> configModules) {
    if (!containerBundles.add(bundle)) {
        // Already seen this bundle...
        return;
    }

    ServiceReference<?>[] references = bundle.getRegisteredServices();
    if (references != null) {
        for (ServiceReference<?> reference : references) {
            possiblyAddConfigModuleIdentifier(reference, configModules);

            Bundle[] usingBundles = reference.getUsingBundles();
            if (usingBundles != null) {
                for (Bundle usingBundle : usingBundles) {
                    if (blueprintExtenderService.getContainer(usingBundle) != null) {
                        findDependentContainersRecursively(usingBundle, containerBundles, configModules);
                    }
                }
            }
        }
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:34,代碼來源:BlueprintContainerRestartServiceImpl.java

示例2: unusedBundles

import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
private static List<Bundle> unusedBundles(Collection<Bundle> unsortedManagedBundles) {
	List<Bundle> unused = new ArrayList<Bundle>();

	boolean trace = log.isTraceEnabled();

	for (Bundle bundle : unsortedManagedBundles) {
	    try {
               String bundleToString = null;
               if (trace) {
                   bundleToString = OsgiStringUtils.nullSafeSymbolicName(bundle);
               }
               ServiceReference[] services = bundle.getRegisteredServices();
               if (isEmpty(services)) {
                   if (trace) {
                       log.trace("Bundle " + bundleToString + " has no registered services; added for shutdown");
                   }
                   unused.add(bundle);
               } else {
                   boolean unusedBundle = true;
                   for (ServiceReference serviceReference : services) {
                       Bundle[] usingBundles = serviceReference.getUsingBundles();

					if (!isEmpty(usingBundles)) {
						usingBundles =
								stream(usingBundles)
										.filter(b -> unsortedManagedBundles.contains(b) && !b.equals(bundle))
										.collect(toList())
										.toArray(new Bundle[]{});
					}

                       if (!isEmpty(usingBundles)) {
                           if (trace)
                               log.trace("Bundle " + bundleToString + " has registered services in use; postponing shutdown. The using bundles are "
                                   + Arrays.toString(usingBundles));
                           unusedBundle = false;
                           break;
                       }

                   }
                   if (unusedBundle) {
                       if (trace) {
                           log.trace("Bundle " + bundleToString + " has unused registered services; added for shutdown");
                       }
                       unused.add(bundle);
                   }
               }
           }
	    catch (IllegalStateException ignored) {
	        unused.add(bundle);
	    }
	}

	unused.sort(ReverseBundleIdSorter.INSTANCE);

	return unused;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:57,代碼來源:ShutdownSorter.java

示例3: getServiceUsage

import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
private static int getServiceUsage(final ServiceReference<?> ref) {
    Bundle[] usingBundles = ref.getUsingBundles();
    return usingBundles != null ? usingBundles.length : 0;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:5,代碼來源:BlueprintBundleTracker.java


注:本文中的org.osgi.framework.ServiceReference.getUsingBundles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。