|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object context.arch.comm.CommunicationsObject
This class handles the network communications for the calling class. It is able to send synchronous message, asynchronous messages (with a threaded client pool) and is connected to a multicast address. Agathe - to do : make of the communication client a thread pool
MessageHandler
Field Summary | |
static boolean |
DEBUG
Debug flag. |
static java.lang.String |
DEFAULT_CLIENT
The default client protocol class to use is "context.arch.comm.protocol.HTTPClientSocket". |
static int |
DEFAULT_POOL_CLIENTS_NUMBER
The default number of threads in the pool of threads. |
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,
int poolClientsNumber)
Basic constructor for CommunicationsObject using given port and protocol server class, and client class. |
|
CommunicationsObject(MessageHandler handler,
java.lang.String clientClass,
java.lang.String serverClass,
int serverPort,
java.lang.String multicastClass)
Basic constructor for CommunicationsObject using given port and protocol server class, and client class, and given multicast protocol 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.DatagramPacket packet)
This method handles an incoming datagram packet from the multicast channel It should only be called by the underlying CommunicationsMulticast object |
void |
handleIncomingRequest(java.net.Socket socket)
This method handles an incoming request on the given socket and sends a reply. |
void |
handleIndependentReply(IndependentCommunication independentComm)
|
void |
println(java.lang.String obs)
Print on the frame |
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 |
void |
sendIndependentRequest(IndependentCommunication request)
|
void |
sendMulticastRequest(java.lang.String request,
java.lang.String url)
This method sends the given request using the CommunicationsMulticast object. |
RequestData |
sendRequest(RequestObject request)
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 |
setFrame(GenericFrame gf)
Set the display frame of the BaseObject |
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.DatagramPacket packet)
This stub method strips the communications protocol from the given request using the CommunicationsMulticast object |
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 boolean DEBUG
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
public static int DEFAULT_POOL_CLIENTS_NUMBER
Constructor Detail |
public CommunicationsObject(MessageHandler handler, java.lang.String clientClass, java.lang.String serverClass, int serverPort, int poolClientsNumber)
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_SERVER
public CommunicationsObject(MessageHandler handler, java.lang.String clientClass, java.lang.String serverClass, int serverPort, java.lang.String multicastClass)
handler
- Basic message handling objectclientClass
- Class to use for client communicationsserverClass
- Class to use for server communicationsserverPort
- Port the server receives communications onmulticastClass
- Class to use for multicast communicationsDEFAULT_CLIENT
,
DEFAULT_PORT
,
DEFAULT_SERVER
public 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
InvalidProtocolException
- if the
class implementing the communications protocol can't be createdCommunicationsServer
,
CommunicationsServer.start()
public DataObject decodeData(java.io.Reader message) throws DecodeException, InvalidDecoderException
message
- Message to be decoded
DecodeException
- if the message can't be decoded
InvalidDecoderException
- if a decoder can't be createdMessageHandler.decodeData(Reader)
public java.lang.String encodeData(DataObject message) throws EncodeException, InvalidEncoderException
message
- Message to be encoded in the form of a DataObject
EncodeException
- if the message can't be encoded
InvalidEncoderException
- if the encoder can't be createdMessageHandler.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 added
ProtocolException
- if protocol can't
be added to the given replyCommunicationsServer.addReplyProtocol(String)
public RequestData stripRequestProtocol(java.net.Socket socket) throws ProtocolException
socket
- The socket the request is being received on
ProtocolException
- thrown if protocol can't
be stripped from the given requestCommunicationsServer.stripRequestProtocol(java.net.Socket)
public RequestData stripRequestProtocol(java.net.DatagramPacket packet) throws ProtocolException
packet
- The multicast datagram the request is being received in
ProtocolException
- thrown if protocol can't
be stripped from the given requestCommunicationsServer.stripRequestProtocol(java.net.Socket)
public RequestData sendRequest(RequestObject request) throws InvalidProtocolException, ProtocolException, java.io.IOException
request
- The request to send
InvalidProtocolException
- if request can't be sent successfully
ProtocolException
- thrown when request fails due to mistake in protocol
java.io.IOException
public void handleIndependentReply(IndependentCommunication independentComm)
public void sendIndependentRequest(IndependentCommunication request)
public void sendMulticastRequest(java.lang.String request, java.lang.String url) throws ProtocolException
request
- The request to sendurl
- The request type
ProtocolException
public 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 RPC
InvalidMethodException
- thrown if specified RPC can't be found
MethodException
- thrown if specified RPC can't be successfully executedMessageHandler.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()
public void handleIncomingRequest(java.net.DatagramPacket packet)
packet
- DatagramPacket which is being received
??@see context.arch.comm.language.MessageHandler#runMethod(String, DataObject)public void setFrame(GenericFrame gf)
public void println(java.lang.String obs)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |