com.sun.enterprise.mgmt.transport
Class AbstractMultiMessageSender

java.lang.Object
  extended by com.sun.enterprise.mgmt.transport.AbstractMultiMessageSender
All Implemented Interfaces:
MessageSender, MulticastMessageSender, ShoalMessageSender
Direct Known Subclasses:
GrizzlyUDPConnectorWrapper, JxtaPipeManagerWrapper

public abstract class AbstractMultiMessageSender
extends Object
implements MulticastMessageSender, MessageSender

This class implements both a common MulticastMessageSender and MessageSender logic simply in order to help the specific transport layer to be implemented easily Mainly, this stores both source's PeerID and target's PeerID before sending the message to the peer or broadcasting the message to all members

Author:
Bongjae Chang

Field Summary
protected  PeerID localPeerID
          Represents local PeerID.
 
Fields inherited from interface com.sun.enterprise.mgmt.transport.ShoalMessageSender
TCP_TRANSPORT, UDP_TRANSPORT
 
Constructor Summary
AbstractMultiMessageSender()
           
 
Method Summary
 boolean broadcast(Message message)
          Broadcasts or Multicasts the given Message to all members
protected abstract  boolean doBroadcast(Message message)
          Broadcasts or Multicasts the given Message to all members
protected abstract  boolean doSend(PeerID peerID, Message message)
          Sends the given Message to the destination
 boolean send(PeerID peerID, Message message)
          Sends the given Message to the destination
 void start()
          
 void stop()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localPeerID

protected PeerID localPeerID
Represents local PeerID. This value should be assigned in real MessageSender's implementation correspoinding to the specific transport layer

Constructor Detail

AbstractMultiMessageSender

public AbstractMultiMessageSender()
Method Detail

broadcast

public boolean broadcast(Message message)
                  throws IOException
Broadcasts or Multicasts the given Message to all members

Specified by:
broadcast in interface MulticastMessageSender
Parameters:
message - a message which is sent to all members
Returns:
true if the message is sent to all members successfully, otherwise false
Throws:
IOException - if I/O error occurs or given parameters are not valid

send

public boolean send(PeerID peerID,
                    Message message)
             throws IOException
Sends the given Message to the destination

Specified by:
send in interface MessageSender
Parameters:
peerID - the destination PeerID. null is not allowed
message - a message which is sent to the peer
Returns:
true if the message is sent to the destination successfully, otherwise false
Throws:
IOException - if I/O error occurs or given parameters are not valid

start

public void start()
           throws IOException

Specified by:
start in interface ShoalMessageSender
Throws:
IOException

stop

public void stop()
          throws IOException

Specified by:
stop in interface ShoalMessageSender
Throws:
IOException

doBroadcast

protected abstract boolean doBroadcast(Message message)
                                throws IOException
Broadcasts or Multicasts the given Message to all members

Parameters:
message - a message which is sent to all members
Returns:
true if the message is sent to all members successfully, otherwise false
Throws:
IOException - if I/O error occurs or given parameters are not valid

doSend

protected abstract boolean doSend(PeerID peerID,
                                  Message message)
                           throws IOException
Sends the given Message to the destination

Parameters:
peerID - the destination PeerID. null is not allowed
message - a message which is sent to the peer
Returns:
true if the message is sent to the destination successfully, otherwise false
Throws:
IOException - if I/O error occurs or given parameters are not valid


Copyright © 2012. All Rights Reserved.