本文整理汇总了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);
}
}
}
}
}
}
示例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;
}
示例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;
}