QJCC homepage

biz.chitec.quarterback.util
Class LoggingReceiverUpdater

java.lang.Object
  extended byjava.lang.Thread
      extended bybiz.chitec.quarterback.util.StoppableThread
          extended bybiz.chitec.quarterback.util.LoggingReceiverUpdater
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
ClientUpdaterFactory.ClientUpdater, UpdateableLoggerDemo.ExampleUpdaterFactory.ExampleUpdater

public abstract class LoggingReceiverUpdater
extends StoppableThread

Updates logging receivers. Heart is the updater thread, which must be implemented by the non-abstract implementations of this object.

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

Nested Class Summary
 class LoggingReceiverUpdater.KeeperInterfaceContent
          Content record for the keeperinterface.
 
Nested classes inherited from class biz.chitec.quarterback.util.StoppableThread
StoppableThread.StopException
 
Field Summary
protected  UpdateableLogger mylogger
          The logger.
protected  LoggingReceiver myreceiver
          The receiver.
protected  boolean stopupdate
          Flag to stop the update (without stopping delayed sending)
protected  ThreadInterface ti
          The storage for delayed data.
 
Fields inherited from class biz.chitec.quarterback.util.StoppableThread
shouldbestopped
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LoggingReceiverUpdater()
          Initiates the object without receiver and logger.
LoggingReceiverUpdater(UpdateableLogger myloggerx, LoggingReceiver myreceiverx)
          Initiates the object complete with receiver and logger.
 
Method Summary
 void cancelUpdate()
          Cancels the update.
 void run()
          Main method of the updater's thread.
abstract  void runUpdate()
          Implements the actual update.
 void sendDelayed()
          Empties the storage for delayed sending.
protected  void sendToReceiver(java.lang.Object o)
          Send logging data to receiver.
 void setLogger(UpdateableLogger ulx)
          Sets the logger.
 void setReceiver(LoggingReceiver lrx)
          Sets the receiver.
 void startUpdate()
          Start the update.
 void stopUpdate()
          Stop the update.
 void storeForDelayedSending(java.lang.Object o, long ts, int seqnr)
          Stores one element of data to be sent delayed.
 
Methods inherited from class biz.chitec.quarterback.util.StoppableThread
shouldBeStopped, stopGracefully
 
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, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mylogger

protected UpdateableLogger mylogger
The logger.


myreceiver

protected LoggingReceiver myreceiver
The receiver.


ti

protected ThreadInterface ti
The storage for delayed data.


stopupdate

protected boolean stopupdate
Flag to stop the update (without stopping delayed sending)

Constructor Detail

LoggingReceiverUpdater

public LoggingReceiverUpdater()
Initiates the object without receiver and logger. Note that receiver and logger must be set before any actual operation takes place. Otherwise, NPEs will arise very soon.


LoggingReceiverUpdater

public LoggingReceiverUpdater(UpdateableLogger myloggerx,
                              LoggingReceiver myreceiverx)
Initiates the object complete with receiver and logger.

Method Detail

setLogger

public void setLogger(UpdateableLogger ulx)
Sets the logger. Note that receiver and logger must be set before any actual operation takes place. Otherwise, NPEs will arise very soon.


setReceiver

public void setReceiver(LoggingReceiver lrx)
Sets the receiver. Note that receiver and logger must be set before any actual operation takes place. Otherwise, NPEs will arise very soon.


storeForDelayedSending

public void storeForDelayedSending(java.lang.Object o,
                                   long ts,
                                   int seqnr)
Stores one element of data to be sent delayed. This method is called by the UpdateableLogger in its handleloop thread.


sendDelayed

public void sendDelayed()
Empties the storage for delayed sending. This method is called by the UpdateableLogger, once without any locks, once with lock on the logger's updaters list.


startUpdate

public void startUpdate()
Start the update. Simply calls start() to start up the thread's run() method.


run

public void run()
Main method of the updater's thread. First, calls runUpdate(). Then, if wanted, calls finishUpdateDelayedSending() of the logger. That one will call sendDelayed() twice and remove the updater from the system.


stopUpdate

public void stopUpdate()
Stop the update. No further update data is sent as soon as runUpdate() recognizes. Passing the delayed data of the usual data stream is not prevented, however.


cancelUpdate

public void cancelUpdate()
Cancels the update. No further update data is sent as soon as runUpdate() recognizes. After that, nothing else happens as the sending of the delayed data is left out in the run() method after this method has been called.


sendToReceiver

protected void sendToReceiver(java.lang.Object o)
Send logging data to receiver. Helper method. Calls appropriate method of Logger and sets timestamp and sequence number to -1.


runUpdate

public abstract void runUpdate()
Implements the actual update. Creates the update messages and sends them (via the helper method sendToReceiver()) to the logging receiver. How the messages are created is totally up to the implementation, it should, however, take care of some settings:


QJCC homepage