Cliser

cliser
Class ServiceThread

java.lang.Object
  |
  +--cliser.CommunicatorUser
        |
        +--cliser.ServiceThread

public abstract class ServiceThread
extends CommunicatorUser
implements java.lang.Runnable, java.lang.Cloneable


Constructor Summary
ServiceThread()
          default constructor POST: my instance variables are set to default values.
ServiceThread(ThreadManager aManager)
          explicit constructor
 
Method Summary
protected  void awaitNextJob()
          utility to put me to sleep until I'm given something to do PRE: I've finished providing a client with service.
 java.lang.Object clone()
          method to clone myself (implements Cloneable interface)
 Communicator getCommunicator()
          accessor for myCommunicator (overrides CommunicatorUser.getCommunicator())
 ThreadManager getManager()
          accessor for myManager
 java.lang.Thread getThread()
          accessor for myThread
 int getThreadID()
          accessor for myThreadID
protected  Communicator initCommunicator()
          definition for CommunicatorUser.initCommunicator()
abstract  void interactWithClient()
          method defined by subclass specifying thread's interaction with client PRE: A connection has been accepted.
 void run()
          default behavior for a service thread: run forever, interacting with a client, and then sleeping.
 void setCommunicator(Communicator aCommunicator)
          mutator for myCommunicator
 void setManager(ThreadManager manager)
          mutator for myManager
 void setThread(java.lang.Thread aThread)
          mutator for myThread
protected  void setThreadID()
          myThreadID mutator POST: myThreadID == the entry value of numThreads && numThreads has been incremented.
 void start()
          utility to wake me up (or start me the first time) POST: I am awake and working.
 java.lang.String toString()
          String converter
 
Methods inherited from class cliser.CommunicatorUser
receive, send
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServiceThread

public ServiceThread()
default constructor POST: my instance variables are set to default values.

ServiceThread

public ServiceThread(ThreadManager aManager)
explicit constructor
Method Detail

setThreadID

protected void setThreadID()
myThreadID mutator POST: myThreadID == the entry value of numThreads && numThreads has been incremented.

getThreadID

public final int getThreadID()
accessor for myThreadID
Returns:
myThreadID.

interactWithClient

public abstract void interactWithClient()
method defined by subclass specifying thread's interaction with client PRE: A connection has been accepted. POST: my service has been performed for that connection's client

run

public void run()
default behavior for a service thread: run forever, interacting with a client, and then sleeping.
Specified by:
run in interface java.lang.Runnable

awaitNextJob

protected void awaitNextJob()
utility to put me to sleep until I'm given something to do PRE: I've finished providing a client with service. POST: I've gone to sleep.

start

public void start()
utility to wake me up (or start me the first time) POST: I am awake and working.

initCommunicator

protected Communicator initCommunicator()
definition for CommunicatorUser.initCommunicator()
Returns:
null.
Overrides:
initCommunicator in class CommunicatorUser

getCommunicator

public Communicator getCommunicator()
accessor for myCommunicator (overrides CommunicatorUser.getCommunicator())
Returns:
myCommunicator
Overrides:
getCommunicator in class CommunicatorUser

setCommunicator

public void setCommunicator(Communicator aCommunicator)
mutator for myCommunicator
Overrides:
setCommunicator in class CommunicatorUser

getThread

public final java.lang.Thread getThread()
accessor for myThread
Returns:
myThread.

setThread

public void setThread(java.lang.Thread aThread)
mutator for myThread

getManager

public final ThreadManager getManager()
accessor for myManager
Returns:
myManager

setManager

public void setManager(ThreadManager manager)
mutator for myManager

clone

public java.lang.Object clone()
method to clone myself (implements Cloneable interface)
Returns:
a copy of myself.
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
String converter
Returns:
a String representation of myself.
Overrides:
toString in class java.lang.Object

Cliser

Cliser is open-source freeware distributed under the GNU Public License.