org.robokind.api.messaging
Class DefaultMessageReceiver<Msg,Rec,L extends org.robokind.api.common.utils.Listener<Msg>>

java.lang.Object
  extended by org.robokind.api.messaging.DefaultMessageReceiver<Msg,Rec,L>
Type Parameters:
Msg - type of Message received
Rec - type of underlying Record received
L - type of Listener to notify
All Implemented Interfaces:
MessageReceiver<Msg,Rec,L>

public class DefaultMessageReceiver<Msg,Rec,L extends org.robokind.api.common.utils.Listener<Msg>>
extends Object
implements MessageReceiver<Msg,Rec,L>

Default MessageReceiver implementation. Uses a RecordAdapterHandler as a RecordHandler to passes Records to an Adapter for deserialization.

Author:
Matthew Stevenson

Constructor Summary
DefaultMessageReceiver()
          Creates an empty DefaultMessageReceiver.
 
Method Summary
 void addMessageListener(L listener)
          Adds a Listener to be notified when a Message has been received.
protected  void fireMessageEvent(Msg message)
          Notifies listeners of a Message
 void pause()
          Pauses a MessageReceiver.
 void removeMessageListener(L listener)
          Removes a Listener from being notified.
 void resume()
          Resumes a paused MessageReceiver.
 void setAdapter(org.robokind.api.common.utils.Adapter<Rec,Msg> adapter)
          Sets the Adapter used to convert Records to Messages.
 void setRecordReceiver(RecordReceiver<Rec> service)
          Sets the RecordReceiver used to receive Records.
 void start()
          Initializes and connects the MessageReceiver, and begins receiving Messages.
 void stop()
          Stops the MessageReceiver, making it unable to receive Messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMessageReceiver

public DefaultMessageReceiver()
Creates an empty DefaultMessageReceiver.

Method Detail

setRecordReceiver

public void setRecordReceiver(RecordReceiver<Rec> service)
Description copied from interface: MessageReceiver
Sets the RecordReceiver used to receive Records.

Specified by:
setRecordReceiver in interface MessageReceiver<Msg,Rec,L extends org.robokind.api.common.utils.Listener<Msg>>
Parameters:
service - theRecordReceiver to set

setAdapter

public void setAdapter(org.robokind.api.common.utils.Adapter<Rec,Msg> adapter)
Description copied from interface: MessageReceiver
Sets the Adapter used to convert Records to Messages.

Specified by:
setAdapter in interface MessageReceiver<Msg,Rec,L extends org.robokind.api.common.utils.Listener<Msg>>
Parameters:
adapter - the Adapter to set

start

public void start()
           throws Exception
Description copied from interface: MessageReceiver
Initializes and connects the MessageReceiver, and begins receiving Messages.

Specified by:
start in interface MessageReceiver<Msg,Rec,L extends org.robokind.api.common.utils.Listener<Msg>>
Throws:
Exception - if there is an error starting

pause

public void pause()
Description copied from interface: MessageReceiver
Pauses a MessageReceiver.

Specified by:
pause in interface MessageReceiver<Msg,Rec,L extends org.robokind.api.common.utils.Listener<Msg>>

resume

public void resume()
Description copied from interface: MessageReceiver
Resumes a paused MessageReceiver.

Specified by:
resume in interface MessageReceiver<Msg,Rec,L extends org.robokind.api.common.utils.Listener<Msg>>

stop

public void stop()
Description copied from interface: MessageReceiver
Stops the MessageReceiver, making it unable to receive Messages.

Specified by:
stop in interface MessageReceiver<Msg,Rec,L extends org.robokind.api.common.utils.Listener<Msg>>

fireMessageEvent

protected void fireMessageEvent(Msg message)
Notifies listeners of a Message

Parameters:
message -

addMessageListener

public void addMessageListener(L listener)
Description copied from interface: MessageReceiver
Adds a Listener to be notified when a Message has been received.

Specified by:
addMessageListener in interface MessageReceiver<Msg,Rec,L extends org.robokind.api.common.utils.Listener<Msg>>
Parameters:
listener - the Listener to be notified

removeMessageListener

public void removeMessageListener(L listener)
Description copied from interface: MessageReceiver
Removes a Listener from being notified.

Specified by:
removeMessageListener in interface MessageReceiver<Msg,Rec,L extends org.robokind.api.common.utils.Listener<Msg>>
Parameters:
listener - the Listener to remove


Copyright © 2011. All Rights Reserved.