|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.osgi.util.OsgiServiceReferenceUtils
public abstract class OsgiServiceReferenceUtils
Utility class for retrieving OSGi service references. This class offers a
unified filter-based access for OSGi services as well as translation of
checked exceptions InvalidSyntaxException
into unchecked ones.
OsgiFilterUtils
underneath to allow multiple class
names to be used for service reference lookup.
OsgiFilterUtils
Constructor Summary | |
---|---|
OsgiServiceReferenceUtils()
|
Method Summary | |
---|---|
static long |
getServiceId(ServiceReference reference)
Returns the service id ( Constants.SERVICE_ID ) of the given
service reference. |
static String[] |
getServiceObjectClasses(ServiceReference reference)
Returns the advertised class names ( Constants.OBJECTCLASS ) of
the given service reference. |
static Dictionary |
getServiceProperties(ServiceReference reference)
Returns a Dictionary containing the properties available for the
given service reference. |
static Map |
getServicePropertiesAsMap(ServiceReference reference)
Returns a Map containing the properties available for the given
service reference. |
static Dictionary |
getServicePropertiesSnapshot(ServiceReference reference)
Returns a Map containing the properties available for the given
service reference. |
static Map |
getServicePropertiesSnapshotAsMap(ServiceReference reference)
Returns a Map containing the properties available for the given
service reference. |
static int |
getServiceRanking(ServiceReference reference)
Returns the service ranking ( Constants.SERVICE_RANKING ) of the
given service reference. |
static ServiceReference |
getServiceReference(BundleContext bundleContext,
String filter)
Returns a reference to the best matching service for the given OSGi filter. |
static ServiceReference |
getServiceReference(BundleContext bundleContext,
String[] classes)
Returns a reference to the best matching service for the given class names. |
static ServiceReference |
getServiceReference(BundleContext bundleContext,
String[] classes,
String filter)
Returns a reference to the best matching service for the given classes and OSGi filter. |
static ServiceReference |
getServiceReference(BundleContext bundleContext,
String clazz,
String filter)
Returns a reference to the best matching service for the given class and OSGi filter. |
static ServiceReference[] |
getServiceReferences(BundleContext bundleContext,
String filter)
Returns references to all services matching the OSGi filter. |
static ServiceReference[] |
getServiceReferences(BundleContext bundleContext,
String[] classes)
Returns references to all services matching the given class names. |
static ServiceReference[] |
getServiceReferences(BundleContext bundleContext,
String[] classes,
String filter)
Returns references to all services matching the given class names and OSGi filter. |
static ServiceReference[] |
getServiceReferences(BundleContext bundleContext,
String clazz,
String filter)
Returns references to all services matching the given class name and OSGi filter. |
static boolean |
isServicePresent(BundleContext bundleContext,
String filter)
Checks if the given filter matches at least one OSGi service or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OsgiServiceReferenceUtils()
Method Detail |
---|
public static ServiceReference getServiceReference(BundleContext bundleContext, String[] classes)
bundleContext
- OSGi bundle contextclasses
- array of fully qualified class names
public static ServiceReference getServiceReference(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 ServiceReference getServiceReference(BundleContext bundleContext, String[] classes, String filter)
bundleContext
- OSGi bundle contextclasses
- array of fully qualified class namesfilter
- valid OSGi filter (can be null
)
public static ServiceReference getServiceReference(BundleContext bundleContext, String filter)
bundleContext
- OSGi bundle contextfilter
- valid OSGi filter (can be null
)
public static ServiceReference[] getServiceReferences(BundleContext bundleContext, String[] classes)
bundleContext
- OSGi bundle contextclasses
- array of fully qualified class names
null
array of references to matching servicespublic static ServiceReference[] getServiceReferences(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 ServiceReference[] getServiceReferences(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 ServiceReference[] getServiceReferences(BundleContext bundleContext, String filter)
bundleContext
- OSGi bundle contextfilter
- valid OSGi filter (can be null
)
null
array of references to matching servicespublic static long getServiceId(ServiceReference reference)
Constants.SERVICE_ID
) of the given
service reference.
reference
- OSGi service reference
public static int getServiceRanking(ServiceReference reference)
Constants.SERVICE_RANKING
) of the
given service reference.
reference
- OSGi service reference
public static String[] getServiceObjectClasses(ServiceReference reference)
Constants.OBJECTCLASS
) of
the given service reference.
reference
- OSGi service reference
public static Dictionary getServicePropertiesSnapshot(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 reference
Dictionary
containing the service reference
properties taken as a snapshotpublic static Map getServicePropertiesSnapshotAsMap(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 reference
Map
containing the service reference properties
taken as a snapshotpublic static Dictionary getServiceProperties(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 reference
Dictionary
containing the latest service
reference propertiespublic static Map getServicePropertiesAsMap(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 reference
Map
containing the latest service reference
propertiesgetServiceProperties(ServiceReference)
public static boolean isServicePresent(BundleContext bundleContext, String filter)
bundleContext
- OSGi bundle contextfilter
- valid OSGi filter (can be null
)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |