|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectzeus.actors.intrays.FIPA_2000_HTTP_Connection
FIPA_2000_HTTP_Connection handles incomming connections on this host/port socket and decides whether or not they are meant for it (ie: is the name on the connection the same as the name in the init of this class)
If the connection is relevant then the data will be read, a response (as per the spec ) will be sent and the message will be decoded into a FIPA.FipaMessage and placed on the registered queue for processing by the relevant server
The class constructor takes a host a port and a name : should this agent only listen for connections for itself at this port and host? That is what is implemented here... comments on a postcard please
| Field Summary | |
private java.lang.String |
host
|
protected int |
MAX_CONTENT_LENGTH
if MAX_CONTENT_LENGHT is greater than 200001 it will be ignored and max_int length content will be accepted |
private int |
MAX_HTTP_QUEUE
|
protected int |
MAX_LINES_TO_READ_WITHOUT_SHUTTING
|
protected int |
MAX_LINES_TO_READ_WITHOUT_YEILDING
MAX_LINES_TO_READ_WITHOUT_YEILDING is used to control how many lines will be read in from a connection in one lump. |
private java.lang.String |
name
|
private java.lang.String |
port
|
protected Queue |
queue
|
private java.lang.String |
response_not_ok
|
private java.lang.String |
response_ok
|
private java.net.ServerSocket |
serverSocket
|
| Constructor Summary | |
FIPA_2000_HTTP_Connection(java.lang.String host,
java.lang.String port,
java.lang.String name)
|
|
| Method Summary | |
private java.lang.String |
addEscape(java.lang.String in)
|
private void |
debug(java.lang.String val)
|
static void |
main(java.lang.String[] argv)
main method for testing this module parameters are |
void |
message(FIPAPerformative aFipaMessage)
message is used to handle the completely read and parsed message when it has come off the message queue |
private FIPAPerformative |
process(java.lang.String inMess,
java.lang.String bound)
|
void |
register(Queue q)
hitch this connection to a message queue |
void |
respondNotOK(java.io.PrintWriter out)
send a not OK response (hopefully we won't have to do this!) |
void |
respondOK(java.io.PrintWriter out)
send the mandated response to a successful message reception episode (see XC00084C) |
void |
run()
run method that makes sure a thread is trying to pick up inputs from a connection The loop blocks on the ServerSocket.accept() method. |
private java.lang.String |
stripEnvelope(java.lang.String HTTPmessage,
java.lang.String bound)
crude for the moment - this needs redoing so it is less fragile. |
protected boolean |
test(java.lang.String myPort,
java.lang.String testHost,
java.lang.String testPort)
used to test the code here! |
private java.lang.String |
testAndSetBoundary(java.lang.String ln)
pull the boundary val from the header |
private int |
testAndSetContentLength(java.lang.String ln)
pull the content length from the header |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Queue queue
private java.lang.String response_ok
private java.lang.String response_not_ok
private java.lang.String host
private java.lang.String name
private java.lang.String port
private int MAX_HTTP_QUEUE
protected int MAX_LINES_TO_READ_WITHOUT_YEILDING
This is protected to prevent it being reset in Agent specific code
protected int MAX_LINES_TO_READ_WITHOUT_SHUTTING
protected int MAX_CONTENT_LENGTH
private java.net.ServerSocket serverSocket
| Constructor Detail |
public FIPA_2000_HTTP_Connection(java.lang.String host,
java.lang.String port,
java.lang.String name)
| Method Detail |
public void run()
The loop blocks on the ServerSocket.accept() method. A count variable is used to prevent an DOS on this agent by yeilding after a certain number of lines have been read.
run in interface java.lang.Runnablepublic void register(Queue q)
private java.lang.String testAndSetBoundary(java.lang.String ln)
private int testAndSetContentLength(java.lang.String ln)
public void respondOK(java.io.PrintWriter out)
public void respondNotOK(java.io.PrintWriter out)
This is not something that I could see mandated in the FIPA-spec, but I think that it is a good idea - otherwise the connection remains open until a timeout.
Perhaps sufficient open connections could be used as some sort of attack on the agent.
public void message(FIPAPerformative aFipaMessage)
protected boolean test(java.lang.String myPort,
java.lang.String testHost,
java.lang.String testPort)
public static void main(java.lang.String[] argv)
parameters are
private FIPAPerformative process(java.lang.String inMess,
java.lang.String bound)
private java.lang.String addEscape(java.lang.String in)
private java.lang.String stripEnvelope(java.lang.String HTTPmessage,
java.lang.String bound)
private void debug(java.lang.String val)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||