org.universAAL.middleware.modules.communication
Class CommunicationModuleImpl

Package class diagram package CommunicationModuleImpl
java.lang.Object
  extended by org.universAAL.middleware.modules.communication.CommunicationModuleImpl
All Implemented Interfaces:
RejectedExecutionHandler, SharedObjectListener, CommunicationModule, ConfigurableCommunicationModule, Module

public class CommunicationModuleImpl
extends Object
implements CommunicationModule, ConfigurableCommunicationModule, SharedObjectListener, RejectedExecutionHandler

CommunicationModule implementation

Author:
Michele Girolami, Francesco Furfari

Constructor Summary
CommunicationModuleImpl(ModuleContext context)
           
 
Method Summary
 void addMessageListener(MessageListener listener, String channelName)
          Method used by the brokerage layer to add message listener
 void configureChannels(List<ChannelDescriptor> channels, String peerName)
          This method allows to configure the CommunicationModule with a List of channels
 void dispose()
          Routine in order to release resources
 void dispose(List<ChannelDescriptor> channels)
          This method allows to reset the Communication module
 String getDescription()
           
 List<String> getGroupMembers(String group)
          * This method fetches the set of members that join to the group
 MessageListener getListenerByNameAndType(String name, Class clz)
          Returns the first MessageListener that is an instance of the given clz and has been registered under the given name.
 String getName()
           
 String getProvider()
           
 String getVersion()
           
 boolean hasChannel(String channelName)
          Determines whether a channel with the specified name exists.
 boolean init()
          This method configures the CommunicationModule: -to obtain the reference to all the CommunicationConnector present in the fw
 void loadConfigurations(Dictionary configurations)
           
 void messageReceived(ChannelMessage channelMessage)
          This method is invoked by the Connector layer as soon as a message arrives.
 void rejectedExecution(Runnable r, ThreadPoolExecutor executor)
           
 void removeMessageListener(MessageListener listener, String channelName)
          Method used by the upper layer to un-register themselves as message listener
 void send(ChannelMessage message, MessageListener listener, PeerCard receiver)
          Unicast
 void send(ChannelMessage message, PeerCard receiver)
          Unicast
 void sendAll(ChannelMessage message)
          Broadcast
 void sendAll(ChannelMessage message, List<PeerCard> recipients)
          Multicast
 void sendAll(ChannelMessage message, List<PeerCard> receivers, MessageListener listener)
          Multicast
 void sendAll(ChannelMessage message, MessageListener listener)
          Broadcast with message listener
 void sharedObjectAdded(Object sharedObj, Object removeHook)
           
 void sharedObjectRemoved(Object removeHook)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommunicationModuleImpl

public CommunicationModuleImpl(ModuleContext context)
Method Detail

init

public boolean init()
This method configures the CommunicationModule: -to obtain the reference to all the CommunicationConnector present in the fw

Specified by:
init in interface Module
Returns:

dispose

public void dispose(List<ChannelDescriptor> channels)
Description copied from interface: ConfigurableCommunicationModule
This method allows to reset the Communication module

Specified by:
dispose in interface ConfigurableCommunicationModule

dispose

public void dispose()
Description copied from interface: Module
Routine in order to release resources

Specified by:
dispose in interface Module

messageReceived

public void messageReceived(ChannelMessage channelMessage)
Description copied from interface: CommunicationModule
This method is invoked by the Connector layer as soon as a message arrives.

Specified by:
messageReceived in interface CommunicationModule

addMessageListener

public void addMessageListener(MessageListener listener,
                               String channelName)
Description copied from interface: CommunicationModule
Method used by the brokerage layer to add message listener

Specified by:
addMessageListener in interface CommunicationModule

getListenerByNameAndType

public MessageListener getListenerByNameAndType(String name,
                                                Class clz)
Description copied from interface: CommunicationModule
Returns the first MessageListener that is an instance of the given clz and has been registered under the given name.

Specified by:
getListenerByNameAndType in interface CommunicationModule
Returns:

removeMessageListener

public void removeMessageListener(MessageListener listener,
                                  String channelName)
Description copied from interface: CommunicationModule
Method used by the upper layer to un-register themselves as message listener

Specified by:
removeMessageListener in interface CommunicationModule

getDescription

public String getDescription()
Specified by:
getDescription in interface Module

getName

public String getName()
Specified by:
getName in interface Module

getProvider

public String getProvider()
Specified by:
getProvider in interface Module

getVersion

public String getVersion()
Specified by:
getVersion in interface Module

loadConfigurations

public void loadConfigurations(Dictionary configurations)
Specified by:
loadConfigurations in interface Module

rejectedExecution

public void rejectedExecution(Runnable r,
                              ThreadPoolExecutor executor)
Specified by:
rejectedExecution in interface RejectedExecutionHandler

configureChannels

public void configureChannels(List<ChannelDescriptor> channels,
                              String peerName)
Description copied from interface: ConfigurableCommunicationModule
This method allows to configure the CommunicationModule with a List of channels

Specified by:
configureChannels in interface ConfigurableCommunicationModule

send

public void send(ChannelMessage message,
                 MessageListener listener,
                 PeerCard receiver)
Unicast

Specified by:
send in interface CommunicationModule
listener - that will manage message failures

send

public void send(ChannelMessage message,
                 PeerCard receiver)
Unicast

Specified by:
send in interface CommunicationModule

sendAll

public void sendAll(ChannelMessage message,
                    List<PeerCard> receivers,
                    MessageListener listener)
Multicast

Specified by:
sendAll in interface CommunicationModule
Parameters:
message - Message to send
receivers - A list of receivers
listener - The listener manages failures during the message send

sendAll

public void sendAll(ChannelMessage message,
                    List<PeerCard> recipients)
Multicast

Specified by:
sendAll in interface CommunicationModule

sendAll

public void sendAll(ChannelMessage message)
Broadcast

Specified by:
sendAll in interface CommunicationModule

sendAll

public void sendAll(ChannelMessage message,
                    MessageListener listener)
Broadcast with message listener

Specified by:
sendAll in interface CommunicationModule
listener - The listener that will manage failures during the message send

sharedObjectAdded

public void sharedObjectAdded(Object sharedObj,
                              Object removeHook)
Specified by:
sharedObjectAdded in interface SharedObjectListener

sharedObjectRemoved

public void sharedObjectRemoved(Object removeHook)
Specified by:
sharedObjectRemoved in interface SharedObjectListener

getGroupMembers

public List<String> getGroupMembers(String group)
Description copied from interface: ConfigurableCommunicationModule
* This method fetches the set of members that join to the group

Specified by:
getGroupMembers in interface ConfigurableCommunicationModule
Returns:
List of addresses of the members

hasChannel

public boolean hasChannel(String channelName)
Description copied from interface: CommunicationModule
Determines whether a channel with the specified name exists.

Specified by:
hasChannel in interface CommunicationModule
Parameters:
channelName - name of the channel.
Returns:
true, iff the channel exists.


Copyright © 2014 universAAL Consortium. All Rights Reserved.