public class RequestListener
extends java.lang.Thread
None prioritization criterion is performed. Request are enqueued in the same order they are received.
Usage example:
construct
run
Modifier and Type | Field and Description |
---|---|
(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.
|
Constructor and Description |
---|
RequestListener(java.lang.String threadName,
int port,
RequestQueue requestQueue,
CADILog log)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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 |
showServerSocket(java.net.ServerSocket socket)
For debugging purposes.
|
private void |
showSocket(java.net.Socket socket)
For debugging purposes.
|
java.lang.String |
toString() |
activeCount, checkAccess, clone, 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
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
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.public void run()
The method will be running meanwhile the finish
attribute
is true
.
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void finish()
public java.lang.String toString()
toString
in class java.lang.Thread
public 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 showServerSocket(java.net.ServerSocket socket)
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.
CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Group on Interactive Coding of Images (GICI) (contact)