Class ServiceRegistrationImpl.ServiceReferenceImpl
- java.lang.Object
-
- org.apache.felix.framework.wiring.BundleCapabilityImpl
-
- org.apache.felix.framework.ServiceRegistrationImpl.ServiceReferenceImpl
-
- All Implemented Interfaces:
java.lang.Comparable,ServiceReference,BundleCapability,Capability
- Enclosing class:
- ServiceRegistrationImpl
class ServiceRegistrationImpl.ServiceReferenceImpl extends BundleCapabilityImpl implements ServiceReference
-
-
Field Summary
Fields Modifier and Type Field Description private ServiceRegistrationImpl.ServiceReferenceMapm_map-
Fields inherited from class org.apache.felix.framework.wiring.BundleCapabilityImpl
VERSION_ATTR
-
-
Constructor Summary
Constructors Modifier Constructor Description privateServiceReferenceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(java.lang.Object reference)Compares thisServiceReferencewith the specifiedServiceReferencefor order.java.util.Map<java.lang.String,java.lang.Object>getAttributes()Returns the attributes of this capability.BundlegetBundle()Returns the bundle that registered the service referenced by thisServiceReferenceobject.java.util.Map<java.lang.String,java.lang.String>getDirectives()Returns the directives of this capability.java.lang.StringgetNamespace()Returns the namespace of this capability.java.lang.ObjectgetProperty(java.lang.String s)Returns the property value to which the specified property key is mapped in the propertiesDictionaryobject of the service referenced by thisServiceReferenceobject.java.lang.String[]getPropertyKeys()Returns an array of the keys in the propertiesDictionaryobject of the service referenced by thisServiceReferenceobject.(package private) ServiceRegistrationImplgetRegistration()BundleRevisiongetRevision()Returns the bundle revision declaring this capability.java.util.List<java.lang.String>getUses()Bundle[]getUsingBundles()Returns the bundles that are using the service referenced by thisServiceReferenceobject.booleanisAssignableTo(Bundle requester, java.lang.String className)Tests if the bundle that registered the service referenced by thisServiceReferenceand the specified bundle use the same source for the package of the specified class name.java.lang.StringtoString()-
Methods inherited from class org.apache.felix.framework.wiring.BundleCapabilityImpl
getResource, isAttributeMandatory, isIncluded
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.osgi.resource.Capability
equals, hashCode
-
-
-
-
Field Detail
-
m_map
private final ServiceRegistrationImpl.ServiceReferenceMap m_map
-
-
Method Detail
-
getRegistration
ServiceRegistrationImpl getRegistration()
-
getRevision
public BundleRevision getRevision()
Description copied from interface:BundleCapabilityReturns the bundle revision declaring this capability.- Specified by:
getRevisionin interfaceBundleCapability- Overrides:
getRevisionin classBundleCapabilityImpl- Returns:
- The bundle revision declaring this capability.
-
getNamespace
public java.lang.String getNamespace()
Description copied from interface:BundleCapabilityReturns the namespace of this capability.- Specified by:
getNamespacein interfaceBundleCapability- Specified by:
getNamespacein interfaceCapability- Overrides:
getNamespacein classBundleCapabilityImpl- Returns:
- The namespace of this capability.
-
getDirectives
public java.util.Map<java.lang.String,java.lang.String> getDirectives()
Description copied from interface:BundleCapabilityReturns the directives of this capability.All capability directives not specified by the
wiring namespaceshave no specified semantics and are considered extra user defined information.- Specified by:
getDirectivesin interfaceBundleCapability- Specified by:
getDirectivesin interfaceCapability- Overrides:
getDirectivesin classBundleCapabilityImpl- 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 java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Description copied from interface:BundleCapabilityReturns the attributes of this capability.- Specified by:
getAttributesin interfaceBundleCapability- Specified by:
getAttributesin interfaceCapability- Overrides:
getAttributesin classBundleCapabilityImpl- 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 java.util.List<java.lang.String> getUses()
- Overrides:
getUsesin classBundleCapabilityImpl
-
getProperty
public java.lang.Object getProperty(java.lang.String s)
Description copied from interface:ServiceReferenceReturns the property value to which the specified property key is mapped in the propertiesDictionaryobject of the service referenced by thisServiceReferenceobject.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,
ServiceReferenceobjects stored in the log) can still be interrogated.- Specified by:
getPropertyin interfaceServiceReference- Parameters:
s- The property key.- Returns:
- The property value to which the key is mapped;
nullif there is no property named after the key.
-
getPropertyKeys
public java.lang.String[] getPropertyKeys()
Description copied from interface:ServiceReferenceReturns an array of the keys in the propertiesDictionaryobject of the service referenced by thisServiceReferenceobject.This method will continue to return the keys after the service has been unregistered. This is so references to unregistered services (for example,
ServiceReferenceobjects 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
Dictionarythat was passed to theBundleContext.registerService(String[],Object,Dictionary)orServiceRegistration.setProperties(Dictionary)methods.- Specified by:
getPropertyKeysin interfaceServiceReference- Returns:
- An array of property keys.
-
getBundle
public Bundle getBundle()
Description copied from interface:ServiceReferenceReturns the bundle that registered the service referenced by thisServiceReferenceobject.This method must return
nullwhen the service has been unregistered. This can be used to determine if the service has been unregistered.- Specified by:
getBundlein interfaceServiceReference- Returns:
- The bundle that registered the service referenced by this
ServiceReferenceobject;nullif that service has already been unregistered. - See Also:
BundleContext.registerService(String[],Object,Dictionary)
-
getUsingBundles
public Bundle[] getUsingBundles()
Description copied from interface:ServiceReferenceReturns the bundles that are using the service referenced by thisServiceReferenceobject. Specifically, this method returns the bundles whose usage count for that service is greater than zero.- Specified by:
getUsingBundlesin interfaceServiceReference- Returns:
- An array of bundles whose usage count for the service referenced
by this
ServiceReferenceobject is greater than zero;nullif no bundles are currently using that service.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classBundleCapabilityImpl
-
isAssignableTo
public boolean isAssignableTo(Bundle requester, java.lang.String className)
Description copied from interface:ServiceReferenceTests if the bundle that registered the service referenced by thisServiceReferenceand the specified bundle use the same source for the package of the specified class name.This method performs the following checks:
- Get the package name from the specified class name.
- 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 returntrueif the registrant bundle is equal to the specified bundle; otherwise returnfalse. - If the package source of the registrant bundle is equal to the
package source of the specified bundle then return
true; otherwise returnfalse.
- Specified by:
isAssignableToin interfaceServiceReference- Parameters:
requester- TheBundleobject to check.className- The class name to check.- Returns:
trueif the bundle which registered the service referenced by thisServiceReferenceand the specified bundle use the same source for the package of the specified class name. Otherwisefalseis returned.
-
compareTo
public int compareTo(java.lang.Object reference)
Description copied from interface:ServiceReferenceCompares thisServiceReferencewith the specifiedServiceReferencefor order.If this
ServiceReferenceand the specifiedServiceReferencehave the sameservice idthey are equal. ThisServiceReferenceis less than the specifiedServiceReferenceif it has a lowerservice rankingand greater if it has a higher service ranking. Otherwise, if thisServiceReferenceand the specifiedServiceReferencehave the sameservice ranking, thisServiceReferenceis less than the specifiedServiceReferenceif it has a higherservice idand greater if it has a lower service id.- Specified by:
compareToin interfacejava.lang.Comparable- Specified by:
compareToin interfaceServiceReference- Parameters:
reference- TheServiceReferenceto be compared.- Returns:
- Returns a negative integer, zero, or a positive integer if this
ServiceReferenceis less than, equal to, or greater than the specifiedServiceReference.
-
-