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

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

 class TCPDataHandler
extends Thread

Acts as a Data Handler to a TCP based client, providing it with a constant stream of XML data for the hosts the client has requested.

Version:
$Id: TCPDataHandler.java,v 1.18 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  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 our Queue
private  int _queueID
          Our queue number within our Queue
private  Socket _socket
          A reference to the Socket connected to the client
private  BufferedReader _socketIn
          A hook to the inbound data from the socket
private  PrintWriter _socketOut
          A hook to the outbound stream for the socket
 String REVISION
          The current CVS revision of this class
private  boolean run
          The flag that dictates whether we should be running
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TCPDataHandler(Socket socket)
          Construct a new TCPDataHandler with a Socket provided by the Control Handler.
 
Method Summary
 Queue getQueue()
          Accessor to our Queue.
 void run()
          Main loop for the Data Handler, keeps sending data from it's local Queue.
 void shutdown()
          Method to shutdown this Data Handler.
 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.


_socketIn

private BufferedReader _socketIn
A hook to the inbound data from the socket


_socketOut

private PrintWriter _socketOut
A hook to the outbound stream for the socket


_socket

private Socket _socket
A reference to the Socket connected to the client


_queue

private Queue _queue
A reference to our Queue


run

private boolean run
The flag that dictates whether we should be running


_queueID

private int _queueID
Our queue number within our Queue

Constructor Detail

TCPDataHandler

public TCPDataHandler(Socket socket)
               throws IOException
Construct a new TCPDataHandler with a Socket provided by the Control Handler.

Parameters:
socket - The socket to which the Client has connected
Throws:
IOException - if something goes wrong, the Control Handler can deal with it
Method Detail

run

public void run()
Main loop for the Data Handler, keeps sending data from it's local Queue.

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

shutdown

public void shutdown()
Method to shutdown this Data Handler. All this actually does is set a flag which the main loop will see and commence shutting down. This method will return before the main loop stops.


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 our Queue. The Control Handler needs to get this reference to register us.

Returns:
a reference to our Queue


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