T - Type of Service.public interface ServiceReference<T> extends Comparable<T>
The Runtime returns ServiceReference objects from the
ModuleContext.getServiceReference and
ModuleContext.getServiceReferences methods.
A ServiceReference object may be shared between modules and can be
used to examine the properties of the service and to get the service object.
Every service registered in the Runtime 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.
ModuleContext.getServiceReference(Class),
ModuleContext.getServiceReference(String),
ModuleContext.getServiceReferences(Class, String),
ModuleContext.getServiceReferences(String, String),
ModuleContext.getService(ServiceReference)| Modifier and Type | Method and Description |
|---|---|
Module |
getModule()
Returns the module that registered the service referenced by this
ServiceReference object. |
Object |
getProperty(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. |
String[] |
getPropertyKeys()
Returns an array of the keys in the properties
Dictionary object
of the service referenced by this ServiceReference object. |
boolean |
isAssignableTo(Module module,
String className)
Tests if the module that registered the service referenced by this
ServiceReference and the specified module use the same source for
the package of the specified class name. |
compareToObject getProperty(String key)
Dictionary object of the service referenced by
this ServiceReference object.
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, ServiceReference objects stored in the log) can still be
interrogated.
key - The property key.null if
there is no property named after the key.String[] getPropertyKeys()
Dictionary object
of the service referenced by this ServiceReference object.
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
ModuleContext.registerService(String[],Object,Dictionary) or
ServiceRegistration.setProperties(Dictionary) methods.
Module getModule()
ServiceReference object.
This method must return null when the service has been
unregistered. This can be used to determine if the service has been
unregistered.
ServiceReference object; null if that service has
already been unregistered.ModuleContext.registerService(String[],Object,Dictionary)boolean isAssignableTo(Module module, String className)
ServiceReference and the specified module use the same source for
the package of the specified class name.
This method performs the following checks:
ServiceReference (registrant module); find the source for the
package. If no source is found then return true if the registrant
module is equal to the specified module; otherwise return false.true;
otherwise return false.module - The Module object to check.className - The class name to check.true if the module which registered the service
referenced by this ServiceReference and the specified
module use the same source for the package of the specified class
name. Otherwise false is returned.Copyright © 2014 JBoss by Red Hat. All Rights Reserved.