public class CachingServiceReference<T> extends Object implements Comparable<CachingServiceReference<T>>
ServiceReference (it DOES
NOT implement ServiceReference) and provides methods to access
underlying ServiceReference properties and caches them so future
access to the same properties return the same values.
Property values are cached on demand. Values that have never been
queried through the method are not cached.
Properties that did not exist when queried will no longer exist even though
they were available at a later time in the underlying
ServiceReference.| Constructor and Description |
|---|
CachingServiceReference(org.osgi.framework.ServiceReference<T> serviceReference) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(CachingServiceReference<T> o) |
boolean |
equals(Object o) |
String[] |
getCachedPropertyKeys() |
Object |
getProperty(String key)
Returns the value associated with a key from the underlying
ServiceReference
The returned value is then cached and the ServiceReference is
never queried again for the same value. |
String[] |
getPropertyKeys() |
org.osgi.framework.ServiceReference<T> |
getServiceReference() |
int |
hashCode() |
boolean |
isDirty()
Checks if any of the cached properties has a different value in the
underlying
ServiceReference. |
boolean |
isDirty(String key)
Checks if the property is dirty in this instance without caching the
value.
|
String |
toString() |
public CachingServiceReference(org.osgi.framework.ServiceReference<T> serviceReference)
public int compareTo(CachingServiceReference<T> o)
compareTo in interface Comparable<CachingServiceReference<T>>public String[] getCachedPropertyKeys()
public Object getProperty(String key)
ServiceReference
The returned value is then cached and the ServiceReference is
never queried again for the same value.
Values that are not present in the ServiceReference return null.
Values that were present in the moment they were first queried will
return the same value even if they disappear from they underlying
ServiceReference.
Values that were not present when queried the first time will continue
to return null even though they exist in future queries.key - the key of the property to be returnedpublic String[] getPropertyKeys()
ServiceReference.
Cached property keys that returned null are not returned here.public org.osgi.framework.ServiceReference<T> getServiceReference()
ServiceReferencepublic boolean isDirty()
ServiceReference. Only properties that have been
accessed through getProperty(String) are
checked, so this method can't be used to know whether the underlying
ServiceReference han been altered since the creation of the
instance.ServiceReferencepublic boolean isDirty(String key)
key - the key to check for dirtinessServiceReferenceCopyright © 2019 The Apache Software Foundation. All rights reserved.