org.universAAL.middleware.bus.model
Class AbstractBus

Package class diagram package AbstractBus
java.lang.Object
  extended by org.universAAL.middleware.bus.model.AbstractBus
All Implemented Interfaces:
Broker, MessageListener
Direct Known Subclasses:
ContextBusImpl, ServiceBusImpl, UIBusImpl

public abstract class AbstractBus
extends Object
implements Broker, MessageListener

Defines a shared mechanisms realized by all concrete buses. This mainly means that it offers abstract view on the bus strategy and manages the bus message queue and by that reduces the implementation of the concrete bus strategy.

Author:
mtazari - Saied Tazari

Field Summary
protected static AALSpaceManager aalSpaceManager
           
protected  BusStrategy busStrategy
           
protected static CommunicationModule communicationModule
           
protected  ModuleContext context
           
protected  IRegistry registry
           
 
Constructor Summary
protected AbstractBus(ModuleContext module, String brokerName)
           
 
Method Summary
 boolean addRegistryListener(IRegistryListener listener)
           
 void brokerMessage(String senderID, BusMessage msg)
          Calls message handling in BusStrategy (gives sender ID and message to process on the bus).
protected abstract  BusStrategy createBusStrategy(CommunicationModule commModule)
           
protected  IRegistry createRegistry()
           
 void dispose()
          Stops the bus (deletes all bus members from the list, stops BusStrategy thread and announces that the bus is being stopped to its members).
 String getBrokerName()
           
 BusMember getBusMember(String memberID)
          Returns bus member instance based on its member ID.
 String getBusMemberID(BusMember bm)
          If the passed argument is indeed a registered member of this bus, returns the local ID with which it has been registered with the bus, otherwise null.
 BusMember[] getBusMembers()
           
 String[] getBusMembersByID()
           
static int getCurrentNumberOfPeers()
           
 PeerCard getPeerCard()
           
static PeerCard getPeerFromBusResourceURI(String uri)
           
 String getURI()
           
 boolean init()
           
static void initBrokerage(ModuleContext mc, AALSpaceManager aalSpaceMgr, CommunicationModule commModule)
           
 boolean isBusResourceURI(String uri)
           
 boolean isValidMember(String memberURI)
           
 void messageReceived(ChannelMessage message)
          Callback for the reception of messages
 String register(ModuleContext module, BusMember m, BusMemberType type)
          Registers a new bus member (adds a bus member to the list of all bus members but only if it has not been added before).
 boolean removeRegistryListener(IRegistryListener listener)
           
 BrokerMessage unmarshall(String serializedBusMessage)
          From String to Broker Message
 void unregister(String memberID, BusMember m)
          Unregisters bus member from the bus (if the bus member with given ID exists).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.universAAL.middleware.modules.listener.MessageListener
handleSendError
 

Field Detail

aalSpaceManager

protected static AALSpaceManager aalSpaceManager

communicationModule

protected static CommunicationModule communicationModule

context

protected ModuleContext context

registry

protected IRegistry registry

busStrategy

protected BusStrategy busStrategy
Constructor Detail

AbstractBus

protected AbstractBus(ModuleContext module,
                      String brokerName)
Method Detail

initBrokerage

public static void initBrokerage(ModuleContext mc,
                                 AALSpaceManager aalSpaceMgr,
                                 CommunicationModule commModule)

getCurrentNumberOfPeers

public static int getCurrentNumberOfPeers()

getPeerFromBusResourceURI

public static PeerCard getPeerFromBusResourceURI(String uri)

createRegistry

protected IRegistry createRegistry()

createBusStrategy

protected abstract BusStrategy createBusStrategy(CommunicationModule commModule)

getBusMember

public BusMember getBusMember(String memberID)
Returns bus member instance based on its member ID.

Parameters:
memberID - bus member ID
Returns:
bus member instance

getBusMemberID

public String getBusMemberID(BusMember bm)
If the passed argument is indeed a registered member of this bus, returns the local ID with which it has been registered with the bus, otherwise null.


getPeerCard

public PeerCard getPeerCard()

getBusMembers

public BusMember[] getBusMembers()
Returns:
all bus members in BusMember array

getBusMembersByID

public String[] getBusMembersByID()
Returns:
IDs of all bus members in array

register

public String register(ModuleContext module,
                       BusMember m,
                       BusMemberType type)
Registers a new bus member (adds a bus member to the list of all bus members but only if it has not been added before). Returns the URI with which the provided member will be known as a bus resource.


brokerMessage

public void brokerMessage(String senderID,
                          BusMessage msg)
Calls message handling in BusStrategy (gives sender ID and message to process on the bus).


init

public boolean init()
Specified by:
init in interface Broker

dispose

public void dispose()
Stops the bus (deletes all bus members from the list, stops BusStrategy thread and announces that the bus is being stopped to its members).

Specified by:
dispose in interface Broker

unregister

public void unregister(String memberID,
                       BusMember m)
Unregisters bus member from the bus (if the bus member with given ID exists).


messageReceived

public void messageReceived(ChannelMessage message)
Description copied from interface: MessageListener
Callback for the reception of messages

Specified by:
messageReceived in interface MessageListener

getBrokerName

public String getBrokerName()
Specified by:
getBrokerName in interface Broker

getURI

public String getURI()

isValidMember

public boolean isValidMember(String memberURI)

isBusResourceURI

public boolean isBusResourceURI(String uri)

unmarshall

public BrokerMessage unmarshall(String serializedBusMessage)
Description copied from interface: Broker
From String to Broker Message

Specified by:
unmarshall in interface Broker
Returns:

addRegistryListener

public boolean addRegistryListener(IRegistryListener listener)

removeRegistryListener

public boolean removeRegistryListener(IRegistryListener listener)


Copyright © 2014 universAAL Consortium. All Rights Reserved.