Class ServiceRegistrationImpl.ServiceReferenceImpl

java.lang.Object
org.apache.felix.framework.wiring.BundleCapabilityImpl
org.apache.felix.framework.ServiceRegistrationImpl.ServiceReferenceImpl
All Implemented Interfaces:
Comparable, ServiceReference, BundleCapability, Capability
Enclosing class:
ServiceRegistrationImpl

class ServiceRegistrationImpl.ServiceReferenceImpl extends BundleCapabilityImpl implements ServiceReference
  • Field Details

  • Constructor Details

    • ServiceReferenceImpl

      private ServiceReferenceImpl()
  • Method Details

    • getRegistration

      ServiceRegistrationImpl getRegistration()
    • getRevision

      public BundleRevision getRevision()
      Description copied from interface: BundleCapability
      Returns the bundle revision declaring this capability.
      Specified by:
      getRevision in interface BundleCapability
      Overrides:
      getRevision in class BundleCapabilityImpl
      Returns:
      The bundle revision declaring this capability.
    • getNamespace

      public String getNamespace()
      Description copied from interface: BundleCapability
      Returns the namespace of this capability.
      Specified by:
      getNamespace in interface BundleCapability
      Specified by:
      getNamespace in interface Capability
      Overrides:
      getNamespace in class BundleCapabilityImpl
      Returns:
      The namespace of this capability.
    • getDirectives

      public Map<String,String> getDirectives()
      Description copied from interface: BundleCapability
      Returns the directives of this capability.

      All capability directives not specified by the wiring namespaces have no specified semantics and are considered extra user defined information.

      Specified by:
      getDirectives in interface BundleCapability
      Specified by:
      getDirectives in interface Capability
      Overrides:
      getDirectives in class BundleCapabilityImpl
      Returns:
      An unmodifiable map of directive names to directive values for this capability, or an empty map if this capability has no directives.
    • getAttributes

      public Map<String,Object> getAttributes()
      Description copied from interface: BundleCapability
      Returns the attributes of this capability.
      Specified by:
      getAttributes in interface BundleCapability
      Specified by:
      getAttributes in interface Capability
      Overrides:
      getAttributes in class BundleCapabilityImpl
      Returns:
      An unmodifiable map of attribute names to attribute values for this capability, or an empty map if this capability has no attributes.
    • getUses

      public List<String> getUses()
      Overrides:
      getUses in class BundleCapabilityImpl
    • getProperty

      public Object getProperty(String s)
      Description copied from interface: ServiceReference
      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.

      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.

      Specified by:
      getProperty in interface ServiceReference
      Parameters:
      s - The property key.
      Returns:
      The property value to which the key is mapped; null if there is no property named after the key.
    • getPropertyKeys

      public String[] getPropertyKeys()
      Description copied from interface: ServiceReference
      Returns an array of the keys in the properties 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 BundleContext.registerService(String[],Object,Dictionary) or ServiceRegistration.setProperties(Dictionary) methods.

      Specified by:
      getPropertyKeys in interface ServiceReference
      Returns:
      An array of property keys.
    • getBundle

      public Bundle getBundle()
      Description copied from interface: ServiceReference
      Returns the bundle that registered the service referenced by this 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.

      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:
    • getUsingBundles

      public Bundle[] getUsingBundles()
      Description copied from interface: ServiceReference
      Returns the bundles that are using the service referenced by this ServiceReference object. Specifically, this method returns the bundles whose usage count for that service is greater than zero.
      Specified by:
      getUsingBundles in interface ServiceReference
      Returns:
      An array of bundles whose usage count for the service referenced by this ServiceReference object is greater than zero; null if no bundles are currently using that service.
    • toString

      public String toString()
      Overrides:
      toString in class BundleCapabilityImpl
    • isAssignableTo

      public boolean isAssignableTo(Bundle requester, 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:
      requester - 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.
    • compareTo

      public int compareTo(Object reference)
      Description copied from interface: ServiceReference
      Compares this ServiceReference with the specified ServiceReference for order.

      If this ServiceReference and the specified ServiceReference have the same service id they are equal. This ServiceReference is less than the specified ServiceReference if it has a lower service ranking and greater if it has a higher service ranking. Otherwise, if this ServiceReference and the specified ServiceReference have the same service ranking, this ServiceReference is less than the specified ServiceReference if it has a higher service id and greater if it has a lower service id.

      Specified by:
      compareTo in interface Comparable
      Specified by:
      compareTo in interface ServiceReference
      Parameters:
      reference - The ServiceReference to be compared.
      Returns:
      Returns a negative integer, zero, or a positive integer if this ServiceReference is less than, equal to, or greater than the specified ServiceReference.