public abstract class AbstractBus extends Object implements Broker, MessageListener
Modifier and Type | Field and Description |
---|---|
protected BusStrategy |
busStrategy |
protected static CommunicationModule |
communicationModule |
protected ModuleContext |
context |
static String |
OPTIONAL_URI_PREFIX
Additional prefix for
SPACE_INSTANCE_URI_PREFIX and
MW_INSTANCE_URI_PREFIX to make it start with a valid URI
scheme. |
protected IRegistry |
registry |
protected static SpaceManager |
spaceManager |
Modifier | Constructor and Description |
---|---|
protected |
AbstractBus(ModuleContext module,
String brokerName) |
Modifier and Type | Method and Description |
---|---|
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).
|
String |
createBusSpecificID(String module,
String type) |
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,
SpaceManager spaceMgr,
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).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handleSendError
public static final String OPTIONAL_URI_PREFIX
SPACE_INSTANCE_URI_PREFIX
and
MW_INSTANCE_URI_PREFIX
to make it start with a valid URI
scheme.
For example, this prefix could be urn:space:
protected static SpaceManager spaceManager
protected static CommunicationModule communicationModule
protected ModuleContext context
protected IRegistry registry
protected BusStrategy busStrategy
protected AbstractBus(ModuleContext module, String brokerName)
public static void initBrokerage(ModuleContext mc, SpaceManager spaceMgr, CommunicationModule commModule)
public static int getCurrentNumberOfPeers()
protected IRegistry createRegistry()
protected abstract BusStrategy createBusStrategy(CommunicationModule commModule)
public BusMember getBusMember(String memberID)
memberID
- bus member IDpublic String getBusMemberID(BusMember bm)
public PeerCard getPeerCard()
public BusMember[] getBusMembers()
public String[] getBusMembersByID()
public final String register(ModuleContext module, BusMember m, BusMemberType type)
public void brokerMessage(String senderID, BusMessage msg)
public void dispose()
public void unregister(String memberID, BusMember m)
public void messageReceived(ChannelMessage message)
MessageListener
messageReceived
in interface MessageListener
public String getBrokerName()
getBrokerName
in interface Broker
public String getURI()
public boolean isValidMember(String memberURI)
public boolean isBusResourceURI(String uri)
public BrokerMessage unmarshall(String serializedBusMessage)
Broker
unmarshall
in interface Broker
public boolean addRegistryListener(IRegistryListener listener)
public boolean removeRegistryListener(IRegistryListener listener)
Copyright © 2018 universAAL Consortium. All rights reserved.