|
xmlBlaster 2.1.0 API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xmlBlaster.util.SimpleXbQueue
public class SimpleXbQueue
This queue (FIFO) implementation may serve as your base class
or as a member variable.
It is based on a linked list.
int size = 3;
Queue queue = new Queue("Test", size);
queue.setModeToDiscardOldest(); // if queue is full, oldest entry is removed
try {
queue.push("Hello ");
queue.push("world.");
}
catch (XmlBlasterException e) {
}
System.out.println(queue.pull()); // prints "Hello "
System.out.println(queue.pull()); // prints "world."
TODO: Allow persistence store e.g. via JDBC bridge into Oracle with some smart caching
| Field Summary | |
|---|---|
private boolean |
discard
Throw the message away if queue is full - the message is silently lost! |
private boolean |
discardOldest
Default is false, and you get an Exception if queue is full |
private int |
MAX_ENTRIES
|
private java.lang.String |
name
|
private long |
numLost
|
private java.util.LinkedList |
queueList
The queue is implemented with a linked list. |
| Constructor Summary | |
|---|---|
SimpleXbQueue(java.lang.String name,
int maxEntries)
Constructs an empty FIFO queue. |
|
| Method Summary | |
|---|---|
long |
getNumLost()
Counter for lost messages in 'discard' or 'discardOldest' mode |
private void |
init()
Allocates a new LinkedList. |
boolean |
isFull()
Check if the queue is filled up. |
static void |
main(java.lang.String[] args)
This method is for testing only. To start this test type: java org.xmlBlaster.util.SimpleXbQueue |
java.lang.Object |
pull()
Pull the next unit from the end of the queue. |
void |
push(java.lang.Object obj)
Add a unit to the beginning of the queue. |
java.util.ListIterator |
queueIterator(int index)
Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list. |
void |
setModeToDiscard()
Default is that an Exception is thrown if the queue is full. |
void |
setModeToDiscardOldest()
Default is that an Exception is thrown if the queue is full. |
int |
size()
How many objects are in the queue. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.lang.String name
private final int MAX_ENTRIES
private boolean discardOldest
private boolean discard
private long numLost
private java.util.LinkedList queueList
| Constructor Detail |
|---|
public SimpleXbQueue(java.lang.String name,
int maxEntries)
name - A nice name, for error reporting only.maxEntries - The maximum number of nodes for this queue.| Method Detail |
|---|
private void init()
public final boolean isFull()
public final java.lang.Object pull()
public final void push(java.lang.Object obj)
throws XmlBlasterException
obj - The object which should be added to the beginning of
the queue.
JUtilsException - This exception is thrown of no more space is available.
XmlBlasterException
public final java.util.ListIterator queueIterator(int index)
throws java.lang.IndexOutOfBoundsException
index - Position of the first element to be returned from the
list-iterator (by a call to next).
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index > size()).public void setModeToDiscardOldest()
public void setModeToDiscard()
public long getNumLost()
public final int size()
public static void main(java.lang.String[] args)
throws java.lang.Exception
java org.xmlBlaster.util.SimpleXbQueue
java.lang.Exception
|
xmlBlaster 2.1.0 API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||