|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectFourMS.FourMSMessageHandler
public class FourMSMessageHandler
This class will form the lowest level interface to the 4MS controller and will access the port server device drivers in order to do so. It will be responsible for ultimately sending messages out to the 4MS, handling the low level acknowledging and resending of messages should there be a need.
This class will not be responsible for processing the incoming messages simply just handling them and passing them onto the objects whcih will establish the semantics of the messages. The data will be read in from an object outside of this class and then passed into this class for appropriating it to the relevent object for processing.
Field Summary | |
---|---|
private java.lang.String |
Destination
This is the value of the destination field in the ER412 message which is returned to the 4MS transmitter. |
(package private) java.util.regex.Pattern |
FourMSMessageACKMatchRE
This will be used for matching ACKs and broadcast messages which are messages with no message body |
(package private) java.util.regex.Pattern |
FourMSMessageMatchRE
This a precompiled regular expression which will be used to find the first 4MS message which adheres to ER412 protocol contained in a string in the input buffer. |
private java.lang.StringBuffer |
Incoming4MSMessageBuffer
We keep all of the incoming message data buffered so that in the event of parts of messages being received, we can buffer them until the rest of the message is received |
private int |
MAXNOOFTRANSMISSIONFAILURES
This is the maximum number of consecutive communications errors which we can receive before we reset the communications layer |
private int |
MAXOUTSTANDINGMSGS
This is the maximum number of outstanding messages which can be active at any one point, by this I mean the number of messages that have been sent by the object which are awaiting acknowledgement from the intended receiver. |
private iDispatchMessageInterface |
MessageDispatcher
This is a reference to an object which will be responsible for dispatching the incoming messages to the appropriate object for providing the semantics associated with the requested action |
private int |
MessageSequenceNumber
This is the message sequence number of the next message to be transmitted, this will be used in constructing any responses to the ER412 protocol transmitter which initiated a response from the object in the first instance |
(package private) java.util.regex.Pattern |
NET200MatchRE
This is a precompiled regular expression which will be used to find NET200 meessages in the incoming message buffer. |
private java.io.OutputStream |
OutputPort
This is an object through which we can access the 4MS through the port server. |
MessagePoster[] |
SentMessages
Maintains a record of all of the outstanding messages which have not been acknowledged by the 4MS after been sent. |
private java.lang.String |
Source
This is the value of the source field in the ER412 message which is returned to the 4MS transmitter. |
private MessageHandler |
SyslogMessageHandler
This will be used for the syslog handling of errors by the class |
private int |
TransmissionErrorCount
Records the number of communications errors which have occured on transmission. |
Constructor Summary | |
---|---|
FourMSMessageHandler(iDispatchMessageInterface Dispatcher,
MessageHandler SyslogHandler)
This is the constructor for the class, it accepts a file descriptor object which will be used to send messages to the transmitter |
Method Summary | |
---|---|
void |
clearIncomingMessageBuffer()
Instructs the class to clear out it's incoming message buffer of messages that have been received from the 4MS module. |
static void |
main(java.lang.String[] args)
A main method for testing the class to ensure that everything is working as expected. |
private FourMSMessage |
parseIncoming4MSMessage()
The purpose of this method will be used to parse the incoming message buffer looking for the first well formed ER412 compliant message, then to break the message down into it's constituent parts and return the result to the caller. |
FourMSMessage |
processIncomingMessage(char[] IncomingMessage,
int AmountRead)
This method will be called when there is a ER412 protocol message received by the system. |
private boolean |
sendAcknowledgement(FourMSMessage MessageToReplyTo)
This method results in an acknowledgment being sent to the sender for the last message that was sent to it. |
boolean |
sendMessage(int MessageType,
java.lang.String MessageToSend,
i4MSMessageSender MessageInitiator)
Builds a message packet suitable to be sent to the 4MS and then creates a MessagePoster object which will be responsible for delivering the message and handling the retries should not ACK be sent. |
private boolean |
sendXONMessage()
To send an XON message to the 4MS in order to provoke it into sending data which it might otherwise be buffering. |
void |
setFourMSOutputPort(java.io.OutputStream FourMSOutputPort)
This method will be used to set the output port so that the message poster objects have a reference to a valid file descriptor upon which to transmit data. |
void |
setMsgEndPointParameters(java.lang.String ER412SourceName,
java.lang.String ER412DestinationName)
This allows the setting of the message end point ie the expected values for the source and destination fields in incoming messages to the software system. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final int MAXOUTSTANDINGMSGS
private final int MAXNOOFTRANSMISSIONFAILURES
private int TransmissionErrorCount
private java.lang.StringBuffer Incoming4MSMessageBuffer
private int MessageSequenceNumber
private java.lang.String Destination
private java.lang.String Source
public MessagePoster[] SentMessages
private java.io.OutputStream OutputPort
final java.util.regex.Pattern NET200MatchRE
final java.util.regex.Pattern FourMSMessageMatchRE
private MessageHandler SyslogMessageHandler
private iDispatchMessageInterface MessageDispatcher
final java.util.regex.Pattern FourMSMessageACKMatchRE
Constructor Detail |
---|
public FourMSMessageHandler(iDispatchMessageInterface Dispatcher, MessageHandler SyslogHandler)
Dispatcher
- This is a class which will be used for dispatching the messages once that
they identified in the input stream from the 4MSSyslogHandler
- This will be used for handling of error messages to the syslogMethod Detail |
---|
private boolean sendXONMessage()
private FourMSMessage parseIncoming4MSMessage() throws Malformed4MSMessageException
Malformed4MSMessageException
- In the case that the
message that we receive is badly formatted we throw this
exceptionpublic FourMSMessage processIncomingMessage(char[] IncomingMessage, int AmountRead) throws Malformed4MSMessageException
IncomingMessage
- - This is a character array which holds
the data that was read in from the 4MS. If this is set to null then
it is assumed that there is no more input data to add.AmountRead
- - This is the number of characters that were
read in.
Malformed4MSMessageException
private boolean sendAcknowledgement(FourMSMessage MessageToReplyTo)
MessageToReplyTo
- - This is the message that we should
reply to, it should contain all of the details that we will
need to construct a messsage that we can.
public static void main(java.lang.String[] args)
args
- Command line arguments.public boolean sendMessage(int MessageType, java.lang.String MessageToSend, i4MSMessageSender MessageInitiator)
MessageType
- - This is the message type of the message
which is to be sent, this should be one of COMMANDMSG,
STATUSRESPONSEMSG, DATARESPONSEMSG, ACKMSG
or BROADCASTMSG.MessageToSend
- - This is the message to be sent which
should be in a format which adheres to ER412 protocol.MessageInitiator
- - This is the object which is
attempting to send the message. This is necessary so that in
the case no acknowledge is received from the 4MS in response to
the transmission, the object may be informed. This should be
set to null if the caller is not expecting to be informed of
the delivery status of the message.
public void setFourMSOutputPort(java.io.OutputStream FourMSOutputPort)
FourMSOutputPort
- - This is the output stream through which we can communicate with the 4MSpublic void setMsgEndPointParameters(java.lang.String ER412SourceName, java.lang.String ER412DestinationName)
ER412SourceName
- This is name of message source on the
ER412 network. Normally this will be something like SYS.AGCA,
SYS.ISIS or SYS.PFIPER412DestinationName
- This is name of message destination
on the ER412 network. Normally this will be something like
AGCA, ISIS or PFIPpublic void clearIncomingMessageBuffer()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |