|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object context.arch.comm.protocol.TCPServerSocket context.arch.comm.protocol.HTTPServerSocket
This class subclasses TCPServerSocket, listening for and handling HTTP requests. It implements the CommunicationsServer interface
TCPServerSocket
,
CommunicationsServer
Field Summary | |
static boolean |
DEBUG
Debug flag. |
static int |
DEFAULT_PORT
Default port for HTTP communications is 80 |
static java.lang.String |
GET
HTTP GET request type |
static java.lang.String |
POST
HTTP POST request type |
static java.lang.String |
PROTOCOL
The protocol being used is HTTP |
Constructor Summary | |
HTTPServerSocket(CommunicationsObject object)
Basic constructor for HTTPServerSocket that calls TCPServerSocket |
|
HTTPServerSocket(CommunicationsObject object,
java.lang.Integer port)
Constructor for HTTPServerSocket that calls TCPServerSocket with the given port |
Method Summary | |
java.lang.String |
addReplyProtocol(java.lang.String data)
Method that takes a reply message and adds the necessary HTTP protocol |
DataObject |
getErrorMessage()
This method generates an error message if a request can't be handled properly, to the point where a contextual error message can still be sent as the reply. |
java.lang.String |
getFatalMessage()
This method generates an fatal message if a request can't be handled properly, to the point where no contextual error message can be sent as the reply. |
java.lang.String |
getProtocol()
Method to get the communications protocol being used |
void |
handleIncomingRequest(java.net.Socket dataSocket)
Stub method that handles incoming HTTP requests. |
void |
quit()
This method stops the server from receiving more data |
RequestData |
stripRequestProtocol(java.net.Socket data)
Method that strips the HTTP protocol from a request message. |
Methods inherited from class context.arch.comm.protocol.TCPServerSocket |
run, start, stopServer |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface context.arch.comm.CommunicationsServer |
start |
Field Detail |
public static boolean DEBUG
public static final int DEFAULT_PORT
public static final java.lang.String PROTOCOL
public static final java.lang.String GET
public static final java.lang.String POST
Constructor Detail |
public HTTPServerSocket(CommunicationsObject object)
object
- Handle of the generic instantiating communications objectDEFAULT_PORT
,
TCPServerSocket
public HTTPServerSocket(CommunicationsObject object, java.lang.Integer port)
object
- Handle of the generic instantiating communications objectport
- Port to use to receive communications onTCPServerSocket
Method Detail |
public void handleIncomingRequest(java.net.Socket dataSocket)
handleIncomingRequest
in interface CommunicationsServer
handleIncomingRequest
in class TCPServerSocket
dataSocket
- Socket to receive HTTP data fromCommunicationsObject.handleIncomingRequest(java.net.Socket)
public java.lang.String addReplyProtocol(java.lang.String data) throws ProtocolException
addReplyProtocol
in interface CommunicationsServer
data
- Reply to a received request
ProtocolException
- if the protocol
can not be addedCommunicationsServer.stripRequestProtocol(java.net.Socket)
,
CommunicationsClient.addRequestProtocol(String,String)
,
CommunicationsClient.stripReplyProtocol(java.net.Socket)
public RequestData stripRequestProtocol(java.net.Socket data) throws ProtocolException
stripRequestProtocol
in interface CommunicationsServer
data
- Socket the request is coming from
ProtocolException
- if the protocol
can not be stripped awayCommunicationsServer.addReplyProtocol(String)
,
CommunicationsClient.addRequestProtocol(String,String)
,
CommunicationsClient.stripReplyProtocol(java.net.Socket)
public DataObject getErrorMessage()
getErrorMessage
in interface CommunicationsServer
getFatalMessage()
public java.lang.String getFatalMessage()
getFatalMessage
in interface CommunicationsServer
getErrorMessage()
public void quit()
quit
in interface CommunicationsServer
TCPServerSocket.stopServer()
public java.lang.String getProtocol()
getProtocol
in interface CommunicationsServer
PROTOCOL
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |