public abstract class OsgiServiceReferenceUtils extends Object
InvalidSyntaxException into unchecked ones.
This classes uses OsgiFilterUtils underneath to allow multiple class names to be used for service reference
lookup.OsgiFilterUtils| Constructor and Description |
|---|
OsgiServiceReferenceUtils() |
| Modifier and Type | Method and Description |
|---|---|
static long |
getServiceId(org.osgi.framework.ServiceReference reference)
Returns the service id (
Constants.SERVICE_ID) of the given service reference. |
static String[] |
getServiceObjectClasses(org.osgi.framework.ServiceReference reference)
Returns the advertised class names (
Constants.OBJECTCLASS) of the given service reference. |
static Dictionary |
getServiceProperties(org.osgi.framework.ServiceReference reference)
Returns a
Dictionary containing the properties available for the given service reference. |
static Map |
getServicePropertiesAsMap(org.osgi.framework.ServiceReference reference)
Returns a
Map containing the properties available for the given service reference. |
static Dictionary |
getServicePropertiesSnapshot(org.osgi.framework.ServiceReference reference)
Returns a
Map containing the properties available for the given service reference. |
static Map |
getServicePropertiesSnapshotAsMap(org.osgi.framework.ServiceReference reference)
Returns a
Map containing the properties available for the given service reference. |
static int |
getServiceRanking(org.osgi.framework.ServiceReference reference)
Returns the service ranking (
Constants.SERVICE_RANKING) of the given service reference. |
static org.osgi.framework.ServiceReference |
getServiceReference(org.osgi.framework.BundleContext bundleContext,
String filter)
Returns a reference to the best matching service for the given OSGi filter.
|
static org.osgi.framework.ServiceReference |
getServiceReference(org.osgi.framework.BundleContext bundleContext,
String[] classes)
Returns a reference to the best matching service for the given class names.
|
static org.osgi.framework.ServiceReference |
getServiceReference(org.osgi.framework.BundleContext bundleContext,
String[] classes,
String filter)
Returns a reference to the best matching service for the given classes and OSGi filter.
|
static org.osgi.framework.ServiceReference |
getServiceReference(org.osgi.framework.BundleContext bundleContext,
String clazz,
String filter)
Returns a reference to the best matching service for the given class and OSGi filter.
|
static org.osgi.framework.ServiceReference |
getServiceReference(org.osgi.framework.ServiceReference... references) |
static org.osgi.framework.ServiceReference[] |
getServiceReferences(org.osgi.framework.BundleContext bundleContext,
String filter)
Returns references to all services matching the OSGi filter.
|
static org.osgi.framework.ServiceReference[] |
getServiceReferences(org.osgi.framework.BundleContext bundleContext,
String[] classes)
Returns references to all services matching the given class names.
|
static org.osgi.framework.ServiceReference[] |
getServiceReferences(org.osgi.framework.BundleContext bundleContext,
String[] classes,
String filter)
Returns references to all services matching the given class names and OSGi filter.
|
static org.osgi.framework.ServiceReference[] |
getServiceReferences(org.osgi.framework.BundleContext bundleContext,
String clazz,
String filter)
Returns references to all services matching the given class name and OSGi filter.
|
static boolean |
isServicePresent(org.osgi.framework.BundleContext bundleContext,
String filter)
Checks if the given filter matches at least one OSGi service or not.
|
public static org.osgi.framework.ServiceReference getServiceReference(org.osgi.framework.BundleContext bundleContext,
String[] classes)
bundleContext - OSGi bundle contextclasses - array of fully qualified class namespublic static org.osgi.framework.ServiceReference getServiceReference(org.osgi.framework.BundleContext bundleContext,
String clazz,
String filter)
bundleContext - OSGi bundle contextclazz - fully qualified class name (can be null)filter - valid OSGi filter (can be null)public static org.osgi.framework.ServiceReference getServiceReference(org.osgi.framework.ServiceReference... references)
public static org.osgi.framework.ServiceReference getServiceReference(org.osgi.framework.BundleContext bundleContext,
String[] classes,
String filter)
bundleContext - OSGi bundle contextclasses - array of fully qualified class namesfilter - valid OSGi filter (can be null)public static org.osgi.framework.ServiceReference getServiceReference(org.osgi.framework.BundleContext bundleContext,
String filter)
bundleContext - OSGi bundle contextfilter - valid OSGi filter (can be null)public static org.osgi.framework.ServiceReference[] getServiceReferences(org.osgi.framework.BundleContext bundleContext,
String[] classes)
bundleContext - OSGi bundle contextclasses - array of fully qualified class namesnull array of references to matching servicespublic static org.osgi.framework.ServiceReference[] getServiceReferences(org.osgi.framework.BundleContext bundleContext,
String clazz,
String filter)
bundleContext - OSGi bundle contextclazz - fully qualified class name (can be null)filter - valid OSGi filter (can be null)null array of references to matching servicespublic static org.osgi.framework.ServiceReference[] getServiceReferences(org.osgi.framework.BundleContext bundleContext,
String[] classes,
String filter)
bundleContext - OSGi bundle contextclasses - array of fully qualified class namesfilter - valid OSGi filter (can be null)null array of references to matching servicespublic static org.osgi.framework.ServiceReference[] getServiceReferences(org.osgi.framework.BundleContext bundleContext,
String filter)
bundleContext - OSGi bundle contextfilter - valid OSGi filter (can be null)null array of references to matching servicespublic static long getServiceId(org.osgi.framework.ServiceReference reference)
Constants.SERVICE_ID) of the given service reference.reference - OSGi service referencepublic static int getServiceRanking(org.osgi.framework.ServiceReference reference)
Constants.SERVICE_RANKING) of the given service reference.reference - OSGi service referencepublic static String[] getServiceObjectClasses(org.osgi.framework.ServiceReference reference)
Constants.OBJECTCLASS) of the given service reference.reference - OSGi service referencepublic static Dictionary getServicePropertiesSnapshot(org.osgi.framework.ServiceReference reference)
Map containing the properties available for the given service reference. This method takes a
snapshot of the properties; future changes to the service properties will not be reflected in the returned
dictionary.
Note that the returned type implements the Map interface also.reference - OSGi service referenceDictionary containing the service reference properties taken as a snapshotpublic static Map getServicePropertiesSnapshotAsMap(org.osgi.framework.ServiceReference reference)
Map containing the properties available for the given service reference. This method takes a
snapshot of the properties; future changes to the service properties will not be reflected in the returned
dictionary.reference - OSGi service referenceMap containing the service reference properties taken as a snapshotpublic static Dictionary getServiceProperties(org.osgi.framework.ServiceReference reference)
Dictionary containing the properties available for the given service reference. The returned
object will reflect any updates made to to the ServiceReference through the owning
ServiceRegistration.
Note that the returned type implements the Map interface also.reference - OSGi service referenceDictionary containing the latest service reference propertiespublic static Map getServicePropertiesAsMap(org.osgi.framework.ServiceReference reference)
Map containing the properties available for the given service reference. The returned object
will reflect any updates made to to the ServiceReference through the owning
ServiceRegistration. Consider using getServiceProperties(ServiceReference) which returns an
object that extends Dictionary as well as implements the Map interface.reference - OSGi service referenceMap containing the latest service reference propertiesgetServiceProperties(ServiceReference)public static boolean isServicePresent(org.osgi.framework.BundleContext bundleContext,
String filter)
bundleContext - OSGi bundle contextfilter - valid OSGi filter (can be null)Copyright © 2006–2016. All rights reserved.