本文整理匯總了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;
}