QJCC homepage

biz.chitec.quarterback.util
Class UpdateableLogger

java.lang.Object
  extended bybiz.chitec.quarterback.util.Logger
      extended bybiz.chitec.quarterback.util.UpdateableLogger

public class UpdateableLogger
extends Logger

Logging object with update facility. Any registered LoggingReceiver can request an "update" of itself. For this, it is taken out of the normal stream of logging information and added to a special thread which gathers any information to send to the receiver.

The UpdateableLogger gets a special LoggingReceiverUpdater object to send the data needed for an update to the receiver.

Version:
$Id: 2d4cbc729d8ec7c853bab80fe649e48879d47c23 $
Author:
chitec/Dirk Hillbrecht 2001. Distributed under the terms of the GNU LGPL.

Nested Class Summary
 
Nested classes inherited from class biz.chitec.quarterback.util.Logger
Logger.ChainElem
 
Field Summary
protected  LoggingReceiverUpdaterFactory lruf
          The factory for the updaters.
protected  java.util.Map updaters
          The updater list.
 
Fields inherited from class biz.chitec.quarterback.util.Logger
first, handleloophandler, receiverexpr, receivers, sleeping, worked
 
Constructor Summary
UpdateableLogger()
          Simple constructor.
UpdateableLogger(LoggingReceiverUpdaterFactory lrufx)
          Constructor with dirct call to set updater factory.
 
Method Summary
 void cancelUpdate(LoggingReceiver lr)
          Cancel a certain update immideately.
protected  void doSendInHandleLoop(java.lang.Object o, LoggingReceiver receiver, long ts, int seqnr)
          Send data to one receiver, Handle loop part.
 void finishUpdateDelayedSending(LoggingReceiver lr)
          Finishes sending of delayed data to an updated reveicer.
 boolean removeReceiver(LoggingReceiver lr)
          Removes the receiver.
 void setLoggingReceiverUpdaterFactory(LoggingReceiverUpdaterFactory lrufx)
          Set the updater factory.
 void stopUpdate(LoggingReceiver lr)
          Stop the update.
 void updateReceiver(LoggingReceiver lr)
          Initiates an update for a certain receiver.
 
Methods inherited from class biz.chitec.quarterback.util.Logger
addReceiver, addReceiver, containsReceiver, continueHandleLogObject, doSendToReceiver, emergencyRemoveReceiver, handleLogObject, handleloop, logObject, logObject, logObject, logObjectToSenderOnly, nothingToHandle, removeReceiver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

updaters

protected java.util.Map updaters
The updater list. For each receiver, the updater is put into this table if it is running.


lruf

protected LoggingReceiverUpdaterFactory lruf
The factory for the updaters. From this object, an updater is requested in case a receiver wants to be updated.

Constructor Detail

UpdateableLogger

public UpdateableLogger()
Simple constructor. Starts logger. Sets updater factory to be null. In this stage, no update requests can be processed. For this, setLoggingReceiverUpdaterFactory() must be called.


UpdateableLogger

public UpdateableLogger(LoggingReceiverUpdaterFactory lrufx)
Constructor with dirct call to set updater factory.

Method Detail

setLoggingReceiverUpdaterFactory

public void setLoggingReceiverUpdaterFactory(LoggingReceiverUpdaterFactory lrufx)
Set the updater factory. The factory in installed.


removeReceiver

public boolean removeReceiver(LoggingReceiver lr)
Removes the receiver. Apart from the usual stuff, any running update is cancelled and the updater is removed.

Overrides:
removeReceiver in class Logger
Parameters:
lr - Receiver to remove.
Returns:
true if the receiver has actually been removed, false if not (e.g. because it has not been added in the beginning)

doSendInHandleLoop

protected void doSendInHandleLoop(java.lang.Object o,
                                  LoggingReceiver receiver,
                                  long ts,
                                  int seqnr)
Send data to one receiver, Handle loop part. Does look for existing keeperinterface. If exists, does not send directly to receiver, but puts into keeperinterface.

This method locks the keeperinterface.

Overrides:
doSendInHandleLoop in class Logger
Parameters:
o - Message object to log
ts - timestamp for UpdateableLogger
seqnr - Sequence counter for TransactionLogger

finishUpdateDelayedSending

public void finishUpdateDelayedSending(LoggingReceiver lr)
Finishes sending of delayed data to an updated reveicer. First stage: lr's updater is called to clear its cache. Second state: lock on updaters is aquired, lr's updater is called again to clear its cache. Now, it is guaranteed that nothing is in it as nothing can be written there if updaters is locked. Third stage: lr's updater is removed from internal tables. Now, update messages are sent directly to lr again.

Note that while updaters is locked, nothing is written to any receiver. Therefore, writing the data should not take too long.

This method should be called by the updater himself only after it has finished its whole update and must now bring the receiver up to date with any delayed data.


updateReceiver

public void updateReceiver(LoggingReceiver lr)
Initiates an update for a certain receiver. Starts up update thread for this special receiver. The method itself returns quickly. If there is already an update running for the receiver, nothing happens, neither if the receiver is not added.

This method must not be called from inside the handle loop of the Logger to prevent deadlocks!


stopUpdate

public void stopUpdate(LoggingReceiver lr)
Stop the update. No further update data is sent. The list of usual updates is processed, however...


cancelUpdate

public void cancelUpdate(LoggingReceiver lr)
Cancel a certain update immideately. Do not even send normal events. This method is called usually when a receiver is removed from the logger.


QJCC homepage