com.debianmirror.server
Class Worker

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.debianmirror.server.Worker
All Implemented Interfaces:
java.lang.Runnable

public class Worker
extends java.lang.Thread

The Worker is responsible for talking to the client.
This includes receiving the request header and sending the file or any given error back to the client.

Author:
E01 - Tobias Hertkorn, Jonas Jagerhok, Jamie Fitz-Gerald

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Worker(WorkerImplFactory factory, WorkerCache cache)
          Creates a new Worker instance with the specified factory and cache.
 
Method Summary
 void die()
          Kills the Worker gracefully.
 void run()
          Main Worker method.
 void setSocket(java.net.Socket s)
          Does assign a socket to this Worker.
 
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, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Worker

public Worker(WorkerImplFactory factory,
              WorkerCache cache)
Creates a new Worker instance with the specified factory and cache.

Parameters:
factory - the factory to create WorkerImpl from
cache - the cache to return to after the assigned work is done
Method Detail

die

public void die()
Kills the Worker gracefully.


run

public void run()
Main Worker method. Waits for an assigned socket. Creates a new WorkerImpl to handle the work. After the work is done it returns itself to the assigned WorkerCache.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

setSocket

public void setSocket(java.net.Socket s)
Does assign a socket to this Worker. It will wake the thread so it handles this work.

Parameters:
s - the new Socket


Copyright © 2004, Apt-Got Group