Class AbstractMessageSender
- java.lang.Object
-
- com.sun.enterprise.mgmt.transport.AbstractMessageSender
-
- All Implemented Interfaces:
MessageSender,ShoalMessageSender
- Direct Known Subclasses:
GrizzlyTCPMessageSender
public abstract class AbstractMessageSender extends java.lang.Object implements MessageSender
This class implements a commonMessageSenderlogic simply in order to help the specific transport layer to be implemented easily Mainly, this stores both source'sPeerIDand target'sPeerIDbefore sending the message to the peer- Author:
- Bongjae Chang
-
-
Field Summary
Fields Modifier and Type Field Description protected PeerIDlocalPeerIDRepresents localPeerID.-
Fields inherited from interface com.sun.enterprise.mgmt.transport.ShoalMessageSender
TCP_TRANSPORT, UDP_TRANSPORT
-
-
Constructor Summary
Constructors Constructor Description AbstractMessageSender()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract booleandoSend(PeerID peerID, Message message)Sends the givenMessageto the destinationbooleansend(PeerID peerID, Message message)Sends the givenMessageto the destinationvoidstart()voidstop()
-
-
-
Field Detail
-
localPeerID
protected PeerID localPeerID
Represents localPeerID. This value should be assigned in realMessageSender's implementation correspoinding to the specific transport layer
-
-
Method Detail
-
send
public boolean send(PeerID peerID, Message message) throws java.io.IOException
Sends the givenMessageto the destination- Specified by:
sendin interfaceMessageSender- Parameters:
peerID- the destinationPeerID.nullis not allowedmessage- a message which is sent to the peer- Returns:
- true if the message is sent to the destination successfully, otherwise false
- Throws:
java.io.IOException- if I/O error occurs or given parameters are not valid
-
start
public void start() throws java.io.IOException- Specified by:
startin interfaceShoalMessageSender- Throws:
java.io.IOException
-
stop
public void stop() throws java.io.IOException- Specified by:
stopin interfaceShoalMessageSender- Throws:
java.io.IOException
-
doSend
protected abstract boolean doSend(PeerID peerID, Message message) throws java.io.IOException
Sends the givenMessageto the destination- Parameters:
peerID- the destinationPeerID.nullis not allowedmessage- a message which is sent to the peer- Returns:
- true if the message is sent to the destination successfully, otherwise false
- Throws:
java.io.IOException- if I/O error occurs or given parameters are not valid
-
-