org.knopflerfish.framework
Class ServiceReferenceImpl

java.lang.Object
  extended by org.knopflerfish.framework.ServiceReferenceImpl
All Implemented Interfaces:
ServiceReference

public class ServiceReferenceImpl
extends java.lang.Object
implements ServiceReference

Implementation of the ServiceReference object.

See Also:
ServiceReference

Method Summary
 boolean equals(java.lang.Object o)
          Test if ServiceReferences points to same service.
 Bundle getBundle()
          Return the bundle which registered the service.
 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.
 Bundle[] getUsingBundles()
          Return the bundles that are using the service wrapped by this ServiceReference, i.e., whose usage count for this service is greater than zero.
 int hashCode()
          Return a hashcode for the service.
 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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProperty

public java.lang.Object getProperty(java.lang.String key)
Get the value of a service's property.

Specified by:
getProperty in interface ServiceReference
Parameters:
key - The property key.
Returns:
The property value to which the key is mapped; null if there is no property named after the key.
See Also:
ServiceReference.getProperty(java.lang.String)

getPropertyKeys

public java.lang.String[] getPropertyKeys()
Get the list of key names for the service's properties.

Specified by:
getPropertyKeys in interface ServiceReference
Returns:
An array of property keys.
See Also:
ServiceReference.getPropertyKeys()

getBundle

public Bundle getBundle()
Return the bundle which registered the service.

Specified by:
getBundle in interface ServiceReference
Returns:
The bundle that registered the service referenced by this ServiceReference object; null if that service has already been unregistered.
See Also:
ServiceReference.getBundle()

equals

public boolean equals(java.lang.Object o)
Test if ServiceReferences points to same service.

Overrides:
equals in class java.lang.Object
See Also:
ServiceReference

hashCode

public int hashCode()
Return a hashcode for the service.

Overrides:
hashCode in class java.lang.Object
See Also:
ServiceReference

getUsingBundles

public Bundle[] getUsingBundles()
Return the bundles that are using the service wrapped by this ServiceReference, i.e., whose usage count for this service is greater than zero.

Specified by:
getUsingBundles in interface ServiceReference
Returns:
array of bundles whose usage count for the service wrapped by this ServiceReference is greater than zero, or null if no bundles currently are using this service
Since:
1.1

isAssignableTo

public boolean isAssignableTo(Bundle bundle,
                              java.lang.String className)
Description copied from interface: ServiceReference
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.

This method performs the following checks:

  1. Get the package name from the specified class name.
  2. For the bundle that registered the service referenced by this 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.
  3. If the package source of the registrant bundle is equal to the package source of the specified bundle then return true; otherwise return false.

Specified by:
isAssignableTo in interface ServiceReference
Parameters:
bundle - The Bundle object to check.
className - The class name to check.
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.