Class AbstractNetworkManager
- java.lang.Object
-
- com.sun.enterprise.mgmt.transport.AbstractNetworkManager
-
- All Implemented Interfaces:
MessageSender,MulticastMessageSender,NetworkManager,ShoalMessageSender
- Direct Known Subclasses:
GrizzlyNetworkManager,JxtaNetworkManager
public abstract class AbstractNetworkManager extends java.lang.Object implements NetworkManager
This class implements a commonNetworkManagerlogic simply in order to help the specific transport layer to be implemented easily Mainly, this managesMessageListenerand dispatches an inboundMessageinto the appropriate listener- 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 AbstractNetworkManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddMessageListener(MessageListener messageListener)Adds theMessageListenerprotected abstract voidafterDispatchingMessage(MessageEvent messageEvent, java.util.Map piggyback)After executingMessageListener.receiveMessageEvent(MessageEvent)} callback, this method will be calledprotected abstract voidbeforeDispatchingMessage(MessageEvent messageEvent, java.util.Map piggyback)Before executingMessageListener.receiveMessageEvent(MessageEvent)} callback, this method will be calledstatic NetworkManagergetInstance(java.lang.String transport)PeerIDgetLocalPeerID()Returns localPeerIDstatic java.util.logging.LoggergetLogger()voidinitialize(java.lang.String groupName, java.lang.String instanceName, java.util.Map properties)Initializes this network manager with given params and propertiesvoidreceiveMessage(Message message, java.util.Map piggyback)Processes a receivedMessageIn this process, inboundMessagewill be wrapped intoMessageEventand be delivered to registeredMessageListenerwith corresponding to the message typevoidremoveMessageListener(MessageListener messageListener)Removes theMessageListenervoidstart()Starts this network manager This method will be called afterNetworkManager.initialize(String, String, java.util.Map)internallyvoidstop()Stops this network manager For cleaning up remaining values and finishing I/O operation, this method could be used-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.sun.enterprise.mgmt.transport.MessageSender
send
-
Methods inherited from interface com.sun.enterprise.mgmt.transport.MulticastMessageSender
broadcast
-
Methods inherited from interface com.sun.enterprise.mgmt.transport.NetworkManager
addRemotePeer, getMessageSender, getMulticastMessageSender, getPeerID, isConnected, removePeerID
-
-
-
-
Field Detail
-
localPeerID
protected PeerID localPeerID
Represents localPeerID. This value should be assigned in realNetworkManager's implementation correspoinding to the specific transport layer
-
-
Method Detail
-
start
public void start() throws java.io.IOExceptionStarts this network manager This method will be called afterNetworkManager.initialize(String, String, java.util.Map)internally- Specified by:
startin interfaceNetworkManager- Specified by:
startin interfaceShoalMessageSender- Throws:
java.io.IOException- if an I/O error occurs
-
stop
public void stop() throws java.io.IOExceptionStops this network manager For cleaning up remaining values and finishing I/O operation, this method could be used- Specified by:
stopin interfaceNetworkManager- Specified by:
stopin interfaceShoalMessageSender- Throws:
java.io.IOException- if an I/O error occurs
-
addMessageListener
public void addMessageListener(MessageListener messageListener)
Adds theMessageListener- Specified by:
addMessageListenerin interfaceNetworkManager- Parameters:
messageListener- a message listener which should be registered on this network manager
-
removeMessageListener
public void removeMessageListener(MessageListener messageListener)
Removes theMessageListener- Specified by:
removeMessageListenerin interfaceNetworkManager- Parameters:
messageListener- a message listener which should be removed
-
receiveMessage
public void receiveMessage(Message message, java.util.Map piggyback)
Processes a receivedMessageIn this process, inboundMessagewill be wrapped intoMessageEventand be delivered to registeredMessageListenerwith corresponding to the message type- Specified by:
receiveMessagein interfaceNetworkManager- Parameters:
message- inbound messagepiggyback- piggyback
-
getLocalPeerID
public PeerID getLocalPeerID()
Returns localPeerID- Specified by:
getLocalPeerIDin interfaceNetworkManager- Returns:
- peer id
-
getInstance
public static NetworkManager getInstance(java.lang.String transport)
-
beforeDispatchingMessage
protected abstract void beforeDispatchingMessage(MessageEvent messageEvent, java.util.Map piggyback)
Before executingMessageListener.receiveMessageEvent(MessageEvent)} callback, this method will be called- Parameters:
messageEvent- a receivedMessageEventpiggyback- piggyback
-
afterDispatchingMessage
protected abstract void afterDispatchingMessage(MessageEvent messageEvent, java.util.Map piggyback)
After executingMessageListener.receiveMessageEvent(MessageEvent)} callback, this method will be called- Parameters:
messageEvent- a receivedMessageEventpiggyback- piggyback
-
getLogger
public static java.util.logging.Logger getLogger()
-
initialize
public void initialize(java.lang.String groupName, java.lang.String instanceName, java.util.Map properties) throws java.io.IOExceptionDescription copied from interface:NetworkManagerInitializes this network manager with given params and properties- Specified by:
initializein interfaceNetworkManager- Parameters:
groupName- group nameinstanceName- instance nameproperties- specific properties- Throws:
java.io.IOException- if an unexpected error occurs
-
-