|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
CADI.Server.Request.RequestListener
public class RequestListener
This class listens to the client requests and enqueues them.
None prioritization criterion is performed. Request are enqueued in the same order they are received.
Usage example:
construct
run
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
(package private) boolean |
finish
Indicates if the thread must be finished. |
private HTTPRequestReader |
httpRequestReader
A object that reads the HTTP request from a input stream. |
private CADILog |
log
Definition in Scheduler.log. |
private int |
port
Port where the server is listening to. |
private RequestQueue |
requestQueue
It is a queue where the client request are stored. |
private java.net.ServerSocket |
serverSocket
Server socket where server is listening to client requests. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
RequestListener(java.lang.String threadName,
int port,
RequestQueue requestQueue,
CADILog log)
Constructor. |
|
| Method Summary | |
|---|---|
void |
finish()
This method is used to indicate that the thread has to finish. |
void |
list(java.io.PrintStream out)
Prints this Request listener out to the specified output stream. |
void |
run()
Listens to in a port and receives the client requests. |
private void |
sendHTTPResponseError(java.net.Socket socket,
int statusCode,
java.lang.String reasonPhrase)
This method will be used to send an HTTP error response to the client. |
private void |
showSocket(java.net.Socket socket)
For debugging purposes. |
java.lang.String |
toString()
|
| 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 |
|---|
private int port
Scheduler.ports.
private RequestQueue requestQueue
Definition in Scheduler.requestQueue.
private CADILog log
Scheduler.log.
volatile boolean finish
private java.net.ServerSocket serverSocket
private HTTPRequestReader httpRequestReader
| Constructor Detail |
|---|
public RequestListener(java.lang.String threadName,
int port,
RequestQueue requestQueue,
CADILog log)
throws ErrorException
threadName - is the name of the thread.port - it is the port where the server will listen to the client
requestsrequestQueue - it is the queue where the received client request
will be saved.log -
ErrorException - if the socket server can not be opened.| Method Detail |
|---|
public void run()
The method will be running meanwhile the finish attribute
is true.
run in interface java.lang.Runnablerun in class java.lang.Threadpublic void finish()
public java.lang.String toString()
toString in class java.lang.Threadpublic void list(java.io.PrintStream out)
out - an output stream.
private void showSocket(java.net.Socket socket)
throws java.io.IOException
socket - the socket whose information will be shown.
java.io.IOException - this exception will be thrown if an error has occurred.
private void sendHTTPResponseError(java.net.Socket socket,
int statusCode,
java.lang.String reasonPhrase)
statusCode - definition in StatusCodes.reasonPhrase - a reason phrase related with the status code.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||