The Framework returns ServiceReference
objects from the
BundleContext.getServiceReference
and
BundleContext.getServiceReferences
methods.
A ServiceReference
object may be shared between bundles and can be
used to examine the properties of the service and to get the service object.
Every service registered in the Framework has a unique
ServiceRegistration
object and may have multiple, distinct
ServiceReference
objects referring to it. ServiceReference
objects associated with a ServiceRegistration
object have the same
hashCode
and are considered equal (more specifically, their
equals()
method will return true
when compared).
If the same service object is registered multiple times,
ServiceReference
objects associated with different
ServiceRegistration
objects are not equal.
BundleContext#getServiceReference(Class)
, BundleContext#getServiceReference(String)
, BundleContext#getServiceReferences(Class, String)
, BundleContext#getServiceReferences(String, String)
, BundleContext#getService(ServiceReference)
, BundleContext#getServiceObjects(ServiceReference)
Modifier and Type | Method and Description |
---|---|
public < The type to which this A> AServiceReference object is to
be adapted. | Returns: The object, of the specified type, to which thisServiceReference object has been adapted or null
if this ServiceReference object cannot be adapted to the
specified type.Class object for the type to which this
type)ServiceReference object is to be adapted.Adapt this |
public int | Returns: Returns a negative integer, zero, or a positive integer if thisServiceReference is less than, equal to, or greater than
the specified ServiceReference .The reference)ServiceReference to be compared.Redeclares java. Compares this |
public Bundle | Returns: The bundle that registered the service referenced by thisServiceReference object; null if that service has
already been unregistered.Redeclares org. Returns the bundle that registered the service referenced by this
|
public Dictionary | Returns: A copy of the properties of the service referenced by thisServiceReference objectReturns a copy of the properties of the service referenced by this
|
public Object | Returns: The property value to which the key is mapped;null if
there is no property named after the key.The property key. key)Returns the property value to which the specified property key is mapped
in the properties |
public String[] | Returns: An array of property keys.Returns an array of the keys in the properties |
public Bundle[] | Returns: An array of bundles whose usage count for the service referenced by thisServiceReference object is greater than zero;
null if no bundles are currently using that service.Returns the bundles that are using the service referenced by this
|
public boolean | Returns: true if the bundle which registered the service
referenced by this ServiceReference and the specified
bundle use the same source for the package of the specified class
name. Otherwise false is returned.The bundle, String Bundle object to check.The class name to check. className)Tests if the bundle that registered the service referenced by this
|
adapt | back to summary |
---|---|
public <A> A adapt(Class<A> type) Adapt this
Adapting this
|
compareTo | back to summary |
---|---|
public int compareTo(Object reference) Redeclares java. Compares this
If this
|
getBundle | back to summary |
---|---|
public Bundle getBundle() Redeclares org. Returns the bundle that registered the service referenced by this
This method must return
|
getProperties | back to summary |
---|---|
public Dictionary Returns a copy of the properties of the service referenced by this
This method will continue to return the properties after the service has
been unregistered. This is so references to unregistered services (for
example,
The returned
|
getProperty | back to summary |
---|---|
public Object getProperty(String key) Returns the property value to which the specified property key is mapped
in the properties Property keys are case-insensitive.
This method must continue to return property values after the service has
been unregistered. This is so references to unregistered services (for
example, |
getPropertyKeys | back to summary |
---|---|
public String[] getPropertyKeys() Returns an array of the keys in the properties
This method will continue to return the keys after the service has been
unregistered. This is so references to unregistered services (for
example,
This method is case-preserving ; this means that every key in the
returned array must have the same case as the corresponding key in the
properties
|
getUsingBundles | back to summary |
---|---|
public Bundle[] getUsingBundles() Returns the bundles that are using the service referenced by this
|
isAssignableTo | back to summary |
---|---|
public boolean isAssignableTo(Bundle bundle, String className) Tests if the bundle that registered the service referenced by this
This method performs the following checks:
|