|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread de.fhg.igd.logging.AbstractAsynchronousMessageDispatcher
This abstract class provides the main functionality of Asynchronous Message Dispatching.
Messages handed over via dispatch()
will be put
into an internal FIFO (First In, First Out) buffer. As soon as the
dispatcher Thread
gains the monitor, it will try to
deliver buffered messages via the attached Messenger
.
In case the internal buffer would exceed its limit, any further calls
of dispatch()
will drop the oldest message until either the
dispatcher was able to catch up or enough messages have been discarded.
An additional notification log entry will inform about the number of
lost messages.
Field Summary | |
protected List |
fifo_
The internal message buffer |
protected boolean |
finished_
This flag will be set to true as soon as finish()
has been called. |
protected int |
lost_
Counter for discarded messages |
protected int |
maxbuf_
The maximum size of the internal message buffer |
protected Messenger |
messenger_
The actual messenger that posts messages into the underlying logging system |
protected boolean |
notified_
This flag will be set to true once a notification about
message loss has been printed to System.out |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
AbstractAsynchronousMessageDispatcher(Messenger messenger,
int maxbuf)
Create an AbstractAsynchronousMessageDispatcher daemon. |
Method Summary | |
protected abstract Object |
createLossEntry(int lost,
Object ref)
Create a notification log entry informing about lost messages. |
void |
dispatch(Object msg)
Hand over a message for dispatching. |
void |
finish()
Calling this method will stop the dispatcher as soon as all remaining messages in the buffer are written into the destination stream. |
protected abstract void |
printLossMessage(Object ref)
Print a notification about automatic message discarding to System.out . |
void |
run()
This is the actual dispatcher implementation. |
String |
toString()
|
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected List fifo_
protected Messenger messenger_
protected int maxbuf_
protected int lost_
protected boolean finished_
true
as soon as finish()
has been called.
protected boolean notified_
true
once a notification about
message loss has been printed to System.out
Constructor Detail |
public AbstractAsynchronousMessageDispatcher(Messenger messenger, int maxbuf)
AbstractAsynchronousMessageDispatcher
daemon.
messenger
- The messenger that actually posts log messages into
the underlying logging systemmaxbuf
- The maximum size of the internal message bufferMethod Detail |
protected abstract void printLossMessage(Object ref)
System.out
.
ref
- The message to refer to and get information fromprotected abstract Object createLossEntry(int lost, Object ref)
lost
- The number of lost messagesref
- The message to refer to and get information from
public void dispatch(Object msg)
msg
- The message to be dispatchedpublic void finish()
public void run()
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |