Regain 2.1.0-STABLE API

net.sf.regain.ui.desktop
Class IndexUpdateManager

java.lang.Object
  extended by net.sf.regain.ui.desktop.IndexUpdateManager
All Implemented Interfaces:
DesktopConstants

public class IndexUpdateManager
extends Object
implements DesktopConstants

Handles automatic updating of index.

Author:
Til Schneider, www.murfman.de

Field Summary
private static long MAX_CRAWLER_WAIT_MILLIS
           
private  Thread mCheckThread
          The check thread.
private  Crawler mCrawler
          The crawler.
private static org.apache.log4j.Logger mLog
          The logger for this class
private static IndexUpdateManager mSingleton
          The singleton.
private  boolean welcomePageShown
           
 
Fields inherited from interface net.sf.regain.ui.desktop.DesktopConstants
AUTH_PROPS_FILE, CONFIG_DIR, CRAWLER_CONFIG_FILE, DEFAULT_CONFIG_DIR, DEFAULT_CRAWLER_CONFIG_FILE, DEFAULT_DESKTOP_CONFIG_FILE, DEFAULT_INTERVAL, DEFAULT_PORT, DESKTOP_CONFIG_FILE, INDEX_DIR, LASTUPDATE_FILE, LOG_DIR, NEEDSUPDATE_FILE, TAGLIB_DIR
 
Constructor Summary
IndexUpdateManager()
           
 
Method Summary
protected  void checkThreadRun()
          The run method of the thread that checks whether an index update is nessesary.
private  void checkUpdate()
          Executes an index update if nessesary.
 Crawler getCurrentCrawler()
          Gets the crawler that processes the current index update.
static IndexUpdateManager getInstance()
          Gets the Singleton.
private  boolean indexNeedsUpdate()
          Gets the timestamp of the last index update.
 void init()
          Initializes the IndexUpdateManager.
private  void saveIndexLastUpdate()
          Saves the current time as the last index update.
 void setShouldPause(boolean shouldPause)
          Sets whether the crawler should pause.
 void startIndexUpdate()
          Starts an index update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_CRAWLER_WAIT_MILLIS

private static final long MAX_CRAWLER_WAIT_MILLIS
See Also:
Constant Field Values

mLog

private static org.apache.log4j.Logger mLog
The logger for this class


mSingleton

private static volatile IndexUpdateManager mSingleton
The singleton.


mCheckThread

private Thread mCheckThread
The check thread.


mCrawler

private volatile Crawler mCrawler
The crawler. Is null if there is currently no index update running.


welcomePageShown

private volatile boolean welcomePageShown
Constructor Detail

IndexUpdateManager

public IndexUpdateManager()
Method Detail

getInstance

public static IndexUpdateManager getInstance()
Gets the Singleton.

Returns:
The Singleton.

init

public void init()
Initializes the IndexUpdateManager.


getCurrentCrawler

public Crawler getCurrentCrawler()
Gets the crawler that processes the current index update.

Returns:
The crawler that processes the current index update or null if there is currently no index update running.

startIndexUpdate

public void startIndexUpdate()
                      throws RegainException
Starts an index update.

Throws:
RegainException - If starting the index update failed.

setShouldPause

public void setShouldPause(boolean shouldPause)
Sets whether the crawler should pause.

Parameters:
shouldPause - Whether the crawler should pause.

checkThreadRun

protected void checkThreadRun()
The run method of the thread that checks whether an index update is nessesary.


checkUpdate

private void checkUpdate()
                  throws RegainException
Executes an index update if nessesary.

Throws:
RegainException - If updating the index failed.

indexNeedsUpdate

private boolean indexNeedsUpdate()
                          throws RegainException
Gets the timestamp of the last index update.

Returns:
The timestamp of the last index update.
Throws:
RegainException - If getting the timestamp failed.

saveIndexLastUpdate

private void saveIndexLastUpdate()
Saves the current time as the last index update.


Regain 2.1.0-STABLE API

Regain 2.1.0-STABLE, Copyright (C) 2004-2010 Til Schneider, www.murfman.de, Thomas Tesche, www.clustersystems.info