|
OSGi™ Service Platform Release 2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A reference to a service.
The Framework returns ServiceReference objects from the BundleContext.getServiceReference and BundleContext.getServiceReferences methods.
A ServiceReference 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(java.lang.String)
,
BundleContext.getServiceReferences(java.lang.String, java.lang.String)
,
BundleContext.getService(org.osgi.framework.ServiceReference)
Method Summary | |
Bundle |
getBundle()
Returns the bundle that registered the service referenced by this ServiceReference object. |
java.lang.Object |
getProperty(java.lang.String key)
Returns the property value to which the specified property key is mapped in the properties Dictionary object of the service referenced by this ServiceReference object. |
java.lang.String[] |
getPropertyKeys()
Returns an array of the keys in the properties Dictionary object of the service referenced by this ServiceReference object. |
Bundle[] |
getUsingBundles()
Returns the bundles that are using the service referenced by this ServiceReference object. |
Method Detail |
public java.lang.Object getProperty(java.lang.String key)
Property keys are case-insensitive.
This method will continue to return property values after the service has been unregistered. This is so references to unregistered services (for example, ServiceReference objects stored in the log) can still be interrogated.
key
- The property key.
public java.lang.String[] getPropertyKeys()
This method will continue to return the keys after the service has been unregistered. This is so references to unregistered services (for example, ServiceReference objects stored in the log) can still be interrogated.
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 Dictionary that was
passed to the BundleContext.registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)
or ServiceRegistration.setProperties(java.util.Dictionary)
methods.
public Bundle getBundle()
This method will always return null when the service has been unregistered. This can be used to determine if the service has been unregistered.
BundleContext.registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)
public Bundle[] getUsingBundles()
|
OSGi™ Service Platform Release 2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |