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