uk.org.iscream.cms.server.client
Class WebFeeder

java.lang.Object
  extended byjava.lang.Thread
      extended byuk.org.iscream.cms.server.client.WebFeeder
All Implemented Interfaces:
Runnable

public class WebFeeder
extends Thread

Provides a feed to the webpage system.

Version:
$Id: WebFeeder.java,v 1.25 2004/08/01 10:40:41 tdb Exp $
Author:
$Author: tdb $

Field Summary
private static WebFeeder _instance
          A reference to the single instance of this class
private  Logger _logger
          This holds a reference to the system logger that is being used.
private  String _name
          This is the friendly identifier of the component this class is running in.
 int DEFAULT_AGE
          Delete alerts older than this in seconds, default.
 int DEFAULT_CHECK_PERIOD
          Default check period in seconds (30 minutes)
static String REVISION
          The current CVS revision of this class
private  String sep
          The default path seperator, here for convienience
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
private WebFeeder()
          Construct a new WebFeeder.
 
Method Summary
private  boolean deleteContents(File dir)
          Iterates through dir (a directory) and deletes all files and subdirectories.
static WebFeeder getInstance()
          Return a reference to the single class.
 void receiveAlert(Alert alert)
          Handles an Alert.
 void receiveXMLPacket(XMLPacket packet)
          Handles an XMLPacket.
 void run()
          Thread loop, will check at intervals for any files that need to be "cleaned up".
 String toString()
          Overrides the Object.toString() method to provide clean logging (every class should have this).
private  void writeData(File outDir, File outFile, String data)
          Attempts to write "data" to "outFile" in "outDir".
 
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

REVISION

public static final String REVISION
The current CVS revision of this class

See Also:
Constant Field Values

DEFAULT_CHECK_PERIOD

public final int DEFAULT_CHECK_PERIOD
Default check period in seconds (30 minutes)

See Also:
Constant Field Values

DEFAULT_AGE

public final int DEFAULT_AGE
Delete alerts older than this in seconds, default.

See Also:
Constant Field Values

sep

private final String sep
The default path seperator, here for convienience


_name

private String _name
This is the friendly identifier of the component this class is running in. eg, a Filter may be called "filter1", If this class does not have an owning component, a name from the configuration can be placed here. This name could also be changed to null for utility classes.


_logger

private Logger _logger
This holds a reference to the system logger that is being used.


_instance

private static WebFeeder _instance
A reference to the single instance of this class

Constructor Detail

WebFeeder

private WebFeeder()
Construct a new WebFeeder. This will also wipe out any old Alerts, as these can't be carried from one session until the next.

Method Detail

getInstance

public static WebFeeder getInstance()
Return a reference to the single class. Construct it if it does not already exist, otherwise just return the reference.


run

public void run()
Thread loop, will check at intervals for any files that need to be "cleaned up". This will normally be OK and FINAL alerts that have been around for longer than a specified period of time.


receiveXMLPacket

public void receiveXMLPacket(XMLPacket packet)
Handles an XMLPacket. This will write it out to disk in an appropriate manner.

Parameters:
packet - the XMLPacket to write

receiveAlert

public void receiveAlert(Alert alert)
Handles an Alert. This will write it out to disk in an appropriate manner.

Parameters:
alert - the Alert object to write

toString

public String toString()
Overrides the Object.toString() method to provide clean logging (every class should have this). This uses the uk.org.iscream.cms.util.FormatName class to format the toString()

Returns:
the name of this class and its CVS revision

writeData

private void writeData(File outDir,
                       File outFile,
                       String data)
Attempts to write "data" to "outFile" in "outDir". Performs checks to create the directories, and the file. Does not "return" anything to indicate failure or success.

Parameters:
outDir - the directory to put the file in
outFile - the filename to put the data in
data - the String of data to write

deleteContents

private boolean deleteContents(File dir)
Iterates through dir (a directory) and deletes all files and subdirectories.

Parameters:
dir - the directory to clear
Returns:
true if it succeeded


Copyright © 2000-2003 i-scream. All Rights Reserved.