uk.org.iscream.cms.server.clientinterface
Class PacketSorter

java.lang.Object
  extended by java.lang.Thread
      extended by uk.org.iscream.cms.server.clientinterface.PacketSorter
All Implemented Interfaces:
Runnable

 class PacketSorter
extends Thread

Receives data from the incoming CORBA servant, places it in a Queue, and then arranges distribution to the DataHandlers. Has extra functionality to send data to DataHandlers on a per-host basis - ie. the Client can request which hosts it would like to listen for.

Version:
$Id: PacketSorter.java,v 1.26 2005/09/25 09:57:41 tdb Exp $
Author:
$Author: tdb $

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  LinkedList _allHostDataList
          A list specifically for a Queue's associated with DataHandlers that want all host information.
private  LinkedList _allHostsList
          A list of all hosts.
private  HashMap _hostMap
          A HashMap to store lists of Queue's (in the DataHandlers) in a way that can be easily accessed when data comes in.
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.
private  Queue _queue
          A reference to the Queue we're using.
private  XMLCache _xmlCache
          A reference to the XMLCache in use
 String REVISION
          The current CVS revision of this class
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PacketSorter()
          Creates a new PacketSorter.
 
Method Summary
 void deregister(Queue dhQueue, String hostList)
          Deregister a DataHandler.
 Queue getQueue()
          Accessor to return a reference to the Queue object.
 void register(Queue dhQueue, String hostList)
          Register a DataHandler in the system.
 void run()
          Method to start the PacketSorter running.
 String toString()
          Overrides the Object.toString() method to provide clean logging (every class should have this).
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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 final String REVISION
The current CVS revision of this class

See Also:
Constant Field Values

_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.


_queue

private Queue _queue
A reference to the Queue we're using.


_hostMap

private HashMap _hostMap
A HashMap to store lists of Queue's (in the DataHandlers) in a way that can be easily accessed when data comes in.


_allHostDataList

private LinkedList _allHostDataList
A list specifically for a Queue's associated with DataHandlers that want all host information.


_allHostsList

private LinkedList _allHostsList
A list of all hosts.


_xmlCache

private XMLCache _xmlCache
A reference to the XMLCache in use

Constructor Detail

PacketSorter

public PacketSorter()
Creates a new PacketSorter.

Method Detail

run

public void run()
Method to start the PacketSorter running. This method will loop forever processing and sending data.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

register

public void register(Queue dhQueue,
                     String hostList)
Register a DataHandler in the system. This method actually takes a reference to a Queue, which should be a Queue that the DataHandler is making use of. It also takes a hostList, this being a semi-colon seperated list of hosts that the Client the DataHandler is serving has requested. If this list is simply an empty String, it is assumed the Client wants to listen to all host information.

Parameters:
dhQueue - a Queue being used by the DataHandler that is registering
hostList - a semi-colon seperated list of hosts

deregister

public void deregister(Queue dhQueue,
                       String hostList)
Deregister a DataHandler. The DataHandler should give a reference to the Queue it's using, and the *same* hostList it gave when it register. It is imperative that the hostList is the same, otherwise there will be all sorts of problems with lists getting out of sync. NB: Possible future addition would be recording of hostList's.

Parameters:
dhQueue - a Queue being used by the DataHandler that is deregistering
hostList - a semi-colon seperated list of hosts

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.NameFormat class to format the toString()

Overrides:
toString in class Thread
Returns:
the name of this class and its CVS revision

getQueue

public Queue getQueue()
Accessor to return a reference to the Queue object. This is needed so the ClientInterfaceServant can get add data easily.

Returns:
a reference to our Queue object.


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