amber.server.application
Class SendThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--amber.server.application.SendThread
All Implemented Interfaces:
java.lang.Runnable

public class SendThread
extends java.lang.Thread

Thread to deal with the transmission of messages destined for the Client.

Version:
1.0.0
Author:
Mark Howard, Dr. David J. Knowles
See Also:
ApplicationHandler, ComponentHandler, amber.server.application

Field Summary
static long TerminationTimeout
          Time taken for the termination routine to timeout.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SendThread(java.lang.ThreadGroup group, java.net.Socket socket, ApplicationInterface parent)
          Construct the thread, with it's parent class so it may pass back messages.
 
Method Summary
 void addPacket(Packet packet)
          Adds a packet for transmission to the remote client.
 void deactivate()
          This function causes the flag to be set disabling this thread.
 ApplicationInterface getParent()
          This function returns the parent application to which messages will be sent.
protected  void init(java.net.Socket socket)
          Initialises the socket system for this thread.
 boolean isActive()
          Returns whether the thread is active.
 boolean isOperating()
          Returns the state of the thread.
 void restart(java.net.Socket socket)
          Forces the thread to restart using the new socket.
 void run()
          Main operating function.
protected  void sendQueue()
          This function sends all outstanding packets in the transmission queue.
 void setParent(ApplicationInterface parent)
          This function sets the parent application to which messages will be sent.
 void terminate()
          This function causes the flag to be set terminating this thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TerminationTimeout

public static final long TerminationTimeout
Time taken for the termination routine to timeout.
Constructor Detail

SendThread

public SendThread(java.lang.ThreadGroup group,
                  java.net.Socket socket,
                  ApplicationInterface parent)
Construct the thread, with it's parent class so it may pass back messages.
Parameters:
group - ThreadGroup this thread belongs to.
socket - Socket which is the connection to the remote client.
parent - ApplicationInterface which is the parent of this thread.
Method Detail

restart

public void restart(java.net.Socket socket)
Forces the thread to restart using the new socket.

init

protected void init(java.net.Socket socket)
Initialises the socket system for this thread.
Parameters:
socket - Socket used to send the data to.

addPacket

public void addPacket(Packet packet)
Adds a packet for transmission to the remote client.
Parameters:
packet - Packet to send to the client.

run

public void run()
Main operating function.
Overrides:
run in class java.lang.Thread

sendQueue

protected void sendQueue()
                  throws java.io.IOException
This function sends all outstanding packets in the transmission queue.
Throws:
java.io.IOException - if there is a problem sending the packet.

terminate

public void terminate()
This function causes the flag to be set terminating this thread. It waits for the thread to terminate before exiting.

deactivate

public void deactivate()
This function causes the flag to be set disabling this thread. The thread is still alive however it will perform no more operations.

isOperating

public boolean isOperating()
Returns the state of the thread.
Returns:
boolean true if operating normally.

isActive

public boolean isActive()
Returns whether the thread is active. This thread will be active if operating normally and inactive if suspended waiting for a connection to reestablish itself if lost.
Returns:
boolean true if active.

setParent

public void setParent(ApplicationInterface parent)
This function sets the parent application to which messages will be sent.
Parameters:
parent - ApplicationInterface which is to be the new parent.

getParent

public ApplicationInterface getParent()
This function returns the parent application to which messages will be sent.
Returns:
ApplicationInterface which is the parent.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.