|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.wsspi.kernel.service.utils.ConcurrentServiceReferenceSet<T>
public class ConcurrentServiceReferenceSet<T>
This provides a simple set implementation for lazy-resolution of services.
Use this class when you have frequent iteration with infrequent add/removal.
Services are stored in reverse order of ServiceReference.compareTo(java.lang.Object)
: highest
service.ranking then lowest (first) service.id.
Usage (following OSGi DS naming conventions/patterns):
private final ConcurrentServiceReferenceSet<T> serviceSet = new ConcurrentServiceReferenceSet<T>("referenceName"); protected void activate(ComponentContext ctx) { serviceSet.activate(ctx); } protected void deactivate(ComponentContext ctx) { serviceSet.deactivate(ctx); } protected void setReferenceName(ServiceReference<T> ref) { serviceSet.addReference(ref); } protected void unsetReferenceName(ServiceReference<T> ref) { serviceSet.removeReference(ref); } public Iterator<T> getReferenceName() { return serviceSet.getServices(); }
Constructor Summary | |
---|---|
ConcurrentServiceReferenceSet(java.lang.String name)
Create a new ConcurrentServiceReferenceSet for the named service. |
Method Summary | |
---|---|
void |
activate(org.osgi.service.component.ComponentContext context)
|
boolean |
addReference(org.osgi.framework.ServiceReference<T> reference)
Adds the service reference to the set, or notifies the set that the service ranking for the reference might have been updated. |
void |
deactivate(org.osgi.service.component.ComponentContext context)
|
org.osgi.framework.ServiceReference<T> |
getHighestRankedReference()
The ConcurrentReferenceSet is ordered by the usual service ranking rules: highest service.ranking then lowest (first) service.id. |
T |
getHighestRankedService()
The ConcurrentReferenceSet is ordered by the usual service ranking rules: highest service.ranking then lowest (first) service.id. |
T |
getService(org.osgi.framework.ServiceReference<T> serviceReference)
Find the provided reference in the set, and return the corresponding service. |
java.util.Iterator<T> |
getServices()
Allocate and return an iterator: The iterator will return the service associated with each ServiceReference as it progresses. |
java.util.Iterator<ServiceAndServiceReferencePair<T>> |
getServicesWithReferences()
Allocate and return an iterator: The iterator will return the service associated with each ServiceReference as it progresses. |
boolean |
isActive()
|
boolean |
isEmpty()
Check if there are any registered/added service references: this will return true if the set is empty (none available). |
java.lang.Iterable<org.osgi.framework.ServiceReference<T>> |
references()
|
boolean |
removeReference(org.osgi.framework.ServiceReference<T> reference)
Removes the service reference from the set |
java.lang.Iterable<T> |
services()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConcurrentServiceReferenceSet(java.lang.String name)
name
- Name of DS referenceMethod Detail |
---|
public void activate(org.osgi.service.component.ComponentContext context)
public void deactivate(org.osgi.service.component.ComponentContext context)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean addReference(org.osgi.framework.ServiceReference<T> reference)
reference
- ServiceReference for the target service
public boolean removeReference(org.osgi.framework.ServiceReference<T> reference)
reference
- ServiceReference associated with service to be unset
public boolean isEmpty()
public boolean isActive()
public T getService(org.osgi.framework.ServiceReference<T> serviceReference)
serviceReference
- Service reference to find in the set
public T getHighestRankedService()
public org.osgi.framework.ServiceReference<T> getHighestRankedReference()
public java.util.Iterator<T> getServices()
public java.util.Iterator<ServiceAndServiceReferencePair<T>> getServicesWithReferences()
public java.lang.Iterable<T> services()
public java.lang.Iterable<org.osgi.framework.ServiceReference<T>> references()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |