Package com.sun.xml.ws.rx.util
Class TimestampedCollection<K,V>
- java.lang.Object
-
- com.sun.xml.ws.rx.util.TimestampedCollection<K,V>
-
- Direct Known Subclasses:
SuspendedFiberStorage
public class TimestampedCollection<K,V> extends Object
TODO javadoc WARNING: This class is a private utility class used by WS-RX implementation. Any usage outside the intedned scope is strongly discouraged. The API exposed by this class may be changed, replaced or removed without any advance notice.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetOldestRegistrationTimestamp()Returns a timestamp of the oldest registered subject.booleanisEmpty()Call this function to determine whether the collection is empty or not.static <K,V>
TimestampedCollection<K,V>newInstance()booleanregister(long timestamp, V subject)Creates a newsubjectregistration.Vregister(K correlationId, V subject)Registers asubjectand maps it to a givencorrelationId.booleanregister(V subject)Creates a newsubjectregistration.Vremove(K correlationId)Removes a registration from the collection based on acorrelationIdand returns the value of the registeredsubject.List<V>removeAll()Removes all values from the time-stamped collection and returns them as an ordered FIFO list.VremoveOldest()Removes the oldest registration from the collection and returns the value of the registeredsubject.intsize()Returns the number of elements in this collection.
-
-
-
Method Detail
-
newInstance
public static <K,V> TimestampedCollection<K,V> newInstance()
-
register
public V register(@NotNull K correlationId, @NotNull V subject)
Registers asubjectand maps it to a givencorrelationId. The newly created registration is timestamped which allows for later removal based on the age of registration usingremoveOldest()method.- Parameters:
correlationId- correlation identifier to be associated with a givensubjectsubject- a primary registration object- Returns:
- old
subjectassociated with a givencorrelationIdornullif there's no suchsubject - See Also:
remove(java.lang.Object),removeOldest()
-
register
public boolean register(@NotNull V subject)Creates a newsubjectregistration. The newly created registration is timestamped which allows for later removal based on the age of registration usingremoveOldest()method.- Parameters:
subject- a primary registration subject- Returns:
trueif the registration was successfull,falseotherwise- See Also:
removeOldest()
-
register
public boolean register(long timestamp, @NotNull V subject)Creates a newsubjectregistration. The newly created registration is timestamped using a value of thetimestampparameter which allows for later removal based on the age of registration usingremoveOldest()method.- Parameters:
timestamp- a timestamp to be used for the registrationsubject- a primary registration subject- Returns:
trueif the registration was successfull,falseotherwise- See Also:
removeOldest()
-
remove
public V remove(@NotNull K correlationId)
Removes a registration from the collection based on acorrelationIdand returns the value of the registeredsubject. This method may returnnull- Parameters:
correlationId- identifier to be associated with an already registeredsubject- Returns:
- a registered
subjectassociated with a givencorrelationIdornullif there's no suchsubject - See Also:
register(java.lang.Object, java.lang.Object)
-
removeOldest
public V removeOldest()
Removes the oldest registration from the collection and returns the value of the registeredsubject.- Returns:
- an oldest registered
subject - Throws:
NoSuchElementException- if the underlying collection is empty.- See Also:
register(java.lang.Object, java.lang.Object),register(java.lang.Object),register(long, java.lang.Object)
-
removeAll
public List<V> removeAll()
Removes all values from the time-stamped collection and returns them as an ordered FIFO list.- Returns:
- ordered FIFO list of the removed values. Returns empty list in case there are no values stored in the collection.
-
isEmpty
public boolean isEmpty()
Call this function to determine whether the collection is empty or not.- Returns:
trueif the collection is empty,falseotherwise
-
size
public int size()
Returns the number of elements in this collection. If the collection contains more thanInteger.MAX_VALUEelements, returnsInteger.MAX_VALUE.- Returns:
- the number of elements in this collection.
-
getOldestRegistrationTimestamp
public long getOldestRegistrationTimestamp()
Returns a timestamp of the oldest registered subject.- Returns:
- timestamp of the oldest registered subject.
- Throws:
NoSuchElementException- if the underlying collection is empty.- See Also:
removeOldest()
-
-