anon.infoservice.update
Class AbstractDatabaseUpdater

java.lang.Object
  extended by anon.util.Updater
      extended by anon.infoservice.update.AbstractDatabaseUpdater
All Implemented Interfaces:
java.util.Observer
Direct Known Subclasses:
AbstractMixCascadeUpdater, InfoServiceUpdater, JAPFeedback, JavaVersionUpdater, MessageUpdater, MinVersionUpdater, PaymentInstanceUpdater, PerformanceInfoUpdater, TermsAndConditionsUpdater

public abstract class AbstractDatabaseUpdater
extends Updater

Updates the local database. This may be done automatically (by a background thread) and manually by method call. The automatic update is only done if this is allowed by the model.

Author:
Rolf Wendolsky

Nested Class Summary
 
Nested classes/interfaces inherited from class anon.util.Updater
Updater.ConstantUpdateInterval, Updater.DynamicUpdateInterval, Updater.IUpdateInterval, Updater.ObservableInfo
 
Field Summary
static long KEEP_ENTRY_FACTOR
          Keep all entries KEEP_ENTRY_FACTOR times of the update interval, even if the InfoService does not hold this object any longer.
private  boolean m_bFirstUpdateDone
           
private  boolean m_successfulUpdate
           
 
Constructor Summary
AbstractDatabaseUpdater(long a_updateInterval, Updater.ObservableInfo a_observableInfo)
          Initialises and starts the database update thread.
AbstractDatabaseUpdater(Updater.IUpdateInterval a_updateInterval, Updater.ObservableInfo a_observableInfo)
          Initialises and starts the database update thread.
 
Method Summary
protected  boolean doCleanup(java.util.Hashtable a_newEntries)
          Does some cleanup operations of the database.
protected abstract  java.util.Hashtable getEntrySerials()
           
protected  AbstractDatabaseEntry getPreferredEntry()
           
protected abstract  java.util.Hashtable getUpdatedEntries(java.util.Hashtable a_entriesToUpdate)
           
 boolean isFirstUpdateDone()
           
protected  boolean protectFromCleanup(AbstractDatabaseEntry a_currentEntry)
           
protected  void setPreferredEntry(AbstractDatabaseEntry a_preferredEntry)
           
protected  void updateInternal()
          Does the update.
protected  boolean wasUpdateSuccessful()
           
 
Methods inherited from class anon.util.Updater
getObservableInfo, getUpdatedClass, getUpdatedClassName, getUpdateInterval, isUpdatePaused, start, stop, update, update, updateAsync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEEP_ENTRY_FACTOR

public static final long KEEP_ENTRY_FACTOR
Keep all entries KEEP_ENTRY_FACTOR times of the update interval, even if the InfoService does not hold this object any longer. If the update interval is 5 minutes, for example, each entry read into the JAP database is kept for at least 15 minutes before it is deleted (if the database does not delete it before).

See Also:
Constant Field Values

m_successfulUpdate

private boolean m_successfulUpdate

m_bFirstUpdateDone

private boolean m_bFirstUpdateDone
Constructor Detail

AbstractDatabaseUpdater

public AbstractDatabaseUpdater(long a_updateInterval,
                               Updater.ObservableInfo a_observableInfo)
Initialises and starts the database update thread.


AbstractDatabaseUpdater

public AbstractDatabaseUpdater(Updater.IUpdateInterval a_updateInterval,
                               Updater.ObservableInfo a_observableInfo)
Initialises and starts the database update thread.

Method Detail

updateInternal

protected void updateInternal()
Does the update. Subclasses may overwrite to, for example, synchronize the update with another object.

Specified by:
updateInternal in class Updater

wasUpdateSuccessful

protected boolean wasUpdateSuccessful()
Specified by:
wasUpdateSuccessful in class Updater

doCleanup

protected boolean doCleanup(java.util.Hashtable a_newEntries)
Does some cleanup operations of the database. All old entries that were not updated by the new entries are removed. Subclasses may overwrite this method to suppress or alter this behavior. This method is called by updateInternal().

Parameters:
a_newEntries - the list of new entries
Returns:
boolean

isFirstUpdateDone

public final boolean isFirstUpdateDone()
Specified by:
isFirstUpdateDone in class Updater

protectFromCleanup

protected boolean protectFromCleanup(AbstractDatabaseEntry a_currentEntry)

getPreferredEntry

protected AbstractDatabaseEntry getPreferredEntry()

setPreferredEntry

protected void setPreferredEntry(AbstractDatabaseEntry a_preferredEntry)

getEntrySerials

protected abstract java.util.Hashtable getEntrySerials()

getUpdatedEntries

protected abstract java.util.Hashtable getUpdatedEntries(java.util.Hashtable a_entriesToUpdate)