|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.osgi.framework.internal.core.ServiceReferenceImpl
public class ServiceReferenceImpl
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
(See BundleContext.getService
).
A registered service may have multiple, distinct ServiceReference
objects which refer to it.
However these ServiceReference objects will have
the same hashCode
and the equals
method
will return true
when compared.
Field Summary | |
---|---|
protected ServiceRegistrationImpl |
registration
Registered Service object. |
Constructor Summary | |
---|---|
protected |
ServiceReferenceImpl(ServiceRegistrationImpl registration)
Construct a reference. |
Method Summary | |
---|---|
int |
compareTo(java.lang.Object object)
Compares two service objects and returns an indication as to which is higher ranked based on service ranking and service_ID. |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one. |
Bundle |
getBundle()
Return the bundle which registered the service. |
protected java.lang.String[] |
getClasses()
Return the classes under which the referenced service was registered. |
protected long |
getId()
Return the serviceid of the ServiceRegistration. |
java.lang.Object |
getProperty(java.lang.String key)
Get the value of a service's property. |
java.lang.String[] |
getPropertyKeys()
Get the list of key names for the service's properties. |
protected int |
getRanking()
Return the serviceranking of the ServiceRegistration. |
Bundle[] |
getUsingBundles()
Return the list of bundles which are using the service. |
int |
hashCode()
Returns a hash code value for the object. |
boolean |
isAssignableTo(Bundle bundle,
java.lang.String className)
Tests if the bundle that registered the service referenced by this ServiceReference and the specified bundle use the same
source for the package of the specified class name. |
java.lang.String |
toString()
Return a string representation of this reference. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ServiceRegistrationImpl registration
Constructor Detail |
---|
protected ServiceReferenceImpl(ServiceRegistrationImpl registration)
Method Detail |
---|
public java.lang.Object getProperty(java.lang.String key)
This method will continue to return property values after the service has been unregistered. This is so that references to unregistered service can be interrogated. (For example: ServiceReference objects stored in the log.)
getProperty
in interface ServiceReference
key
- Name of the property.
null
if there is
no property by that name.public java.lang.String[] getPropertyKeys()
This method will continue to return the keys after the service has been unregistered. This is so that references to unregistered service can be interrogated. (For example: ServiceReference objects stored in the log.)
getPropertyKeys
in interface ServiceReference
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.
getBundle
in interface ServiceReference
BundleContext.registerService(String[],Object,java.util.Dictionary)
public Bundle[] getUsingBundles()
This method will always return null
when the
service has been unregistered.
getUsingBundles
in interface ServiceReference
BundleContextImpl.getService(org.osgi.framework.ServiceReference)
protected java.lang.String[] getClasses()
protected long getId()
protected int getRanking()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the reference object with which to compare.
true
if this object is the same as the obj
argument; false
otherwise.public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(java.lang.Object object)
compareTo
in interface java.lang.Comparable
compareTo
in interface ServiceReference
object
- an object to compare the receiver to
java.lang.ClassCastException
- if the argument can not be converted
into something comparable with the
receiver.public boolean isAssignableTo(Bundle bundle, java.lang.String className)
ServiceReference
ServiceReference
and the specified bundle use the same
source for the package of the specified class name.
This method performs the following checks:
ServiceReference
(registrant bundle); find the source for
the package. If no source is found then return true
if the
registrant bundle is equal to the specified bundle; otherwise return
false
.true
;
otherwise return false
.
isAssignableTo
in interface ServiceReference
bundle
- The Bundle
object to check.className
- The class name to check.
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |