|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--context.arch.comm.CommunicationsObject
This class handles the network communications for the calling class.
MessageHandler| Field Summary | |
static java.lang.String |
DEFAULT_CLIENT
The default client protocol class to use is "context.arch.comm.protocol.HTTPClientSocket". |
static int |
DEFAULT_PORT
The default port number to use is port 5555. |
static int |
DEFAULT_REMOTE_PORT
The default remote port number to use is port 5555. |
static java.lang.String |
DEFAULT_REMOTE_SERVER
The default remote server is localhost. |
static java.lang.String |
DEFAULT_SERVER
The default server protocol class to use is "context.arch.comm.protocol.HTTPServerSocket". |
static java.lang.String |
HTTP_CLIENT
The HTTP client protocol class. |
static java.lang.String |
HTTP_SERVER
The HTTP server protocol class. |
| Constructor Summary | |
CommunicationsObject(MessageHandler handler)
Basic constructor for CommunicationsObject using default port and protocol server class, and default client class, |
|
CommunicationsObject(MessageHandler handler,
int port)
Constructor for CommunicationsObject using given port. |
|
CommunicationsObject(MessageHandler handler,
int port,
java.lang.String serverClass)
Constructor for CommunicationsObject using the given port and given protocol. |
|
CommunicationsObject(MessageHandler handler,
java.lang.String serverClass)
Constructor for CommunicationsObject using default port, default client class and given protocol server. |
|
CommunicationsObject(MessageHandler handler,
java.lang.String clientClass,
java.lang.String serverClass,
int serverPort)
Basic constructor for CommunicationsObject using given port and protocol server class, and client class. |
|
| Method Summary | |
java.lang.String |
addReplyProtocol(java.lang.String reply)
This stub method adds the communications protocol to the given reply using the CommunicationsServer object |
DataObject |
decodeData(java.io.Reader message)
This stub method calls the decodeData method in MessageHandler. |
java.lang.String |
encodeData(DataObject message)
This stub method calls the encodeData method in MessageHandler. |
java.lang.String |
getClientClass()
Returns the class being used as the communications client. |
java.lang.String |
getServerClass()
Returns the class being used as the communications client. |
int |
getServerPort()
Returns the port being used for incoming communications (server). |
java.lang.String |
getServerProtocol()
This method gets the communications protocol being used by the object that implements the CommunicationsServer interface |
void |
handleIncomingRequest(java.net.Socket socket)
This method handles an incoming request on the given socket and sends a reply. |
void |
quit()
This stub method stops the communications server from receiving more data by using the CommunicationsServer object |
DataObject |
runMethod(java.lang.String line,
DataObject data)
This stub method runs the specified request using the MessageHandler |
RequestData |
sendRequest(java.lang.String request,
java.lang.String url)
This method creates a communications client with the default hostname and port and sends the given request using the newly created CommunicationsClient object |
RequestData |
sendRequest(java.lang.String request,
java.lang.String url,
java.lang.String host)
This method creates a communications client with the given hostname and default port and sends the given request using the newly created CommunicationsClient object |
RequestData |
sendRequest(java.lang.String request,
java.lang.String url,
java.lang.String host,
int port)
This method creates a communications client with the given hostname and port and sends the given request using the newly created CommunicationsClient object |
RequestData |
sendRequest(java.lang.String request,
java.lang.String url,
java.lang.String host,
int port,
java.lang.String type)
This method creates a communications client with the given hostname and port and sends the given request using the newly created CommunicationsClient object |
void |
setClientClass(java.lang.String client)
Sets the class to use as the communications client. |
void |
setServerClass(java.lang.String server)
Sets the class to use as the communications server. |
void |
setServerPort(int port)
Sets the port to use for incoming communications (server). |
void |
start()
This method creates and starts an instance of the class that deals with the underlying communications protocol being used. |
RequestData |
stripRequestProtocol(java.net.Socket socket)
This stub method strips the communications protocol from the given request using the CommunicationsServer object |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final int DEFAULT_PORT
public static final int DEFAULT_REMOTE_PORT
public static final java.lang.String DEFAULT_REMOTE_SERVER
public static final java.lang.String DEFAULT_SERVER
public static final java.lang.String DEFAULT_CLIENT
public static final java.lang.String HTTP_SERVER
public static final java.lang.String HTTP_CLIENT
| Constructor Detail |
public CommunicationsObject(MessageHandler handler,
java.lang.String clientClass,
java.lang.String serverClass,
int serverPort)
handler - Basic message handling objectclientClass - Class to use for client communicationsserverClass - Class to use for server communicationsserverPort - Port the server recieves communications onDEFAULT_CLIENT,
DEFAULT_PORT,
DEFAULT_SERVERpublic CommunicationsObject(MessageHandler handler)
handler - Basic message handling objectDEFAULT_PORT,
DEFAULT_SERVER,
DEFAULT_CLIENT
public CommunicationsObject(MessageHandler handler,
int port)
handler - Basic message handling objectport - Port number to communicate onDEFAULT_SERVER,
DEFAULT_CLIENT
public CommunicationsObject(MessageHandler handler,
java.lang.String serverClass)
handler - Basic message handling objectserverClass - Name of server class to use for communicationsDEFAULT_PORT,
DEFAULT_CLIENT
public CommunicationsObject(MessageHandler handler,
int port,
java.lang.String serverClass)
handler - Basic message handling objectport - Port number to communicate onserverClass - Class to use for server communicationsDEFAULT_CLIENT| Method Detail |
public void start()
throws InvalidProtocolException
CommunicationsServer,
CommunicationsServer.start()
public DataObject decodeData(java.io.Reader message)
throws DecodeException,
InvalidDecoderException
message - Message to be decodedMessageHandler.decodeData(Reader)
public java.lang.String encodeData(DataObject message)
throws EncodeException,
InvalidEncoderException
message - Message to be encoded in the form of a DataObjectMessageHandler.encodeData(DataObject)public java.lang.String getServerProtocol()
CommunicationsServer.getProtocol()
public java.lang.String addReplyProtocol(java.lang.String reply)
throws ProtocolException
reply - The reply that needs the protocol addedCommunicationsServer.addReplyProtocol(String)
public RequestData stripRequestProtocol(java.net.Socket socket)
throws ProtocolException
socket - The socket the request is being received onCommunicationsServer.stripRequestProtocol(java.net.Socket)
public RequestData sendRequest(java.lang.String request,
java.lang.String url)
throws InvalidProtocolException,
ProtocolException
request - The request to sendurl - The request type
public RequestData sendRequest(java.lang.String request,
java.lang.String url,
java.lang.String host)
throws InvalidProtocolException,
ProtocolException
request - The request to sendurl - The request typehost - Hostname of the server to connect to
public RequestData sendRequest(java.lang.String request,
java.lang.String url,
java.lang.String host,
int port)
throws InvalidProtocolException,
ProtocolException
request - The request to sendurl - The request typehost - Hostname of the server to connect toport - Port number of the server to connect to
public RequestData sendRequest(java.lang.String request,
java.lang.String url,
java.lang.String host,
int port,
java.lang.String type)
throws InvalidProtocolException,
ProtocolException
request - The request to sendurl - The request typehost - Hostname of the server to connect toport - Port number of the server to connect totype - Whether the request is a GET or a POSTpublic void quit()
CommunicationsServer.quit()
public DataObject runMethod(java.lang.String line,
DataObject data)
throws InvalidMethodException,
MethodException
line - Single line specifying the type of requestdata - Data for the specified RPCMessageHandler.runMethod(String, DataObject)public void handleIncomingRequest(java.net.Socket socket)
socket - Socket on which the request is being receivedMessageHandler.runMethod(String, DataObject)public void setClientClass(java.lang.String client)
client - Class to use as the communications client.public java.lang.String getClientClass()
public void setServerClass(java.lang.String server)
server - Class to use as the communications server.public java.lang.String getServerClass()
public void setServerPort(int port)
port - Port to use for incoming communications (server).public int getServerPort()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||