public class SpaceModuleImpl extends Object implements SpaceModule, MessageListener, SharedObjectListener, ServiceListener, Broker
Constructor and Description |
---|
SpaceModuleImpl(ModuleContext context) |
Modifier and Type | Method and Description |
---|---|
void |
addPeer(SpaceDescriptor spaceDescriptor,
PeerCard newPeer)
This method allows to add a new Peer to the Space.
|
void |
announceNewPeer(SpaceCard spaceCard,
PeerCard peerCard)
This method propagates the event of new PeerAdded to the whole Space
|
void |
configureSpaceChannel()
This method configures the channel used in order to send/receive
Space messages
|
void |
destroySpace(SpaceCard spaceCard)
Destroy a Space
|
void |
dispose()
Routine in order to release resources
|
String |
getBrokerName() |
String |
getDescription() |
String |
getName() |
List<String> |
getPeersAddress()
This method fetches the list of peer address joining to the same
Space
|
String |
getProvider() |
List<SpaceCard> |
getSpaces()
This method fetches a list of Spaces without any filter
|
List<SpaceCard> |
getSpaces(Dictionary<String,String> filters)
This method fetches a list of Spaces according to a filter
|
String |
getVersion() |
void |
handleSendError(ChannelMessage message,
CommunicationConnectorException exception)
Callback for error handling
|
boolean |
init()
This method configures the SpaceModule: -to obtain the reference to
all the DiscoveryConnector present in the fw -to obtain the reference to
the CommunicationModdule -to obtain the reference to the ControlBroker
|
void |
joinSpace(PeerCard spaceCoordinator,
SpaceCard spaceCard)
This method allows to join to an existing Space
|
void |
leaveSpace(PeerCard spaceCoordinator,
SpaceCard spaceCard)
This method allows to leave a Space
|
void |
loadConfigurations(Dictionary configurations) |
void |
messageFromSpace(SpaceMessage message,
PeerCard sender)
This method is called as soon as an SpaceMessage has been received
|
void |
messageReceived(ChannelMessage message)
Callback for the reception of messages
|
void |
newSpace(SpaceCard spaceCard)
This method creates a new Space
|
void |
newSpacesFound(Set<SpaceCard> spaceCards)
Called when a new Space has been found
|
void |
renewSpace(SpaceCard spaceCard)
This method renews the Space
|
void |
requestPeerCard(SpaceDescriptor spaceDescriptor,
String peerAddress)
This method allows to send a request for the PeerCard of the peer with
the specified address
|
void |
requestToLeave(SpaceDescriptor spaceDescriptor)
This method announces to all the peers to leave the space
|
void |
sharedObjectAdded(Object arg0,
Object arg1) |
void |
sharedObjectRemoved(Object arg0) |
void |
spaceLost(SpaceCard spaceCard)
Called when an Space has been destroyed
|
BrokerMessage |
unmarshall(String message)
From String to Broker Message
|
public SpaceModuleImpl(ModuleContext context)
public boolean init()
public List<SpaceCard> getSpaces()
SpaceModule
getSpaces
in interface SpaceModule
public List<SpaceCard> getSpaces(Dictionary<String,String> filters) throws SpaceModuleException
SpaceModule
getSpaces
in interface SpaceModule
filters
- A set of key, value pairs for filtering the SpacesSpaceModuleException
public void newSpace(SpaceCard spaceCard) throws SpaceModuleException
SpaceModule
newSpace
in interface SpaceModule
SpaceModuleException
public String getDescription()
getDescription
in interface Module
public String getProvider()
getProvider
in interface Module
public String getVersion()
getVersion
in interface Module
public void loadConfigurations(Dictionary configurations)
loadConfigurations
in interface Module
public void leaveSpace(PeerCard spaceCoordinator, SpaceCard spaceCard)
SpaceModule
leaveSpace
in interface SpaceModule
spaceCard
- Space Card of the Space to leavepublic void requestToLeave(SpaceDescriptor spaceDescriptor)
SpaceModule
requestToLeave
in interface SpaceModule
public void requestPeerCard(SpaceDescriptor spaceDescriptor, String peerAddress)
SpaceModule
requestPeerCard
in interface SpaceModule
spaceDescriptor
- the Space descriptorpeerAddress
- the address of the peerpublic void newSpacesFound(Set<SpaceCard> spaceCards)
ServiceListener
newSpacesFound
in interface ServiceListener
public void joinSpace(PeerCard spaceCoordinator, SpaceCard spaceCard)
SpaceModule
joinSpace
in interface SpaceModule
spaceCoordinator
- The PeerCard of the Space coordinator to which to sent the
requestspaceCard
- The SpaceCard of the space the peer aims to joinpublic void addPeer(SpaceDescriptor spaceDescriptor, PeerCard newPeer)
SpaceModule
addPeer
in interface SpaceModule
spaceDescriptor
- All the information regarding the Space for the new PeernewPeer
- The Peer to add to the Spacepublic void announceNewPeer(SpaceCard spaceCard, PeerCard peerCard)
SpaceModule
announceNewPeer
in interface SpaceModule
spaceCard
- The Space where to propagate the eventpeerCard
- The new peer addedpublic void messageFromSpace(SpaceMessage message, PeerCard sender) throws SpaceModuleException
SpaceModule
messageFromSpace
in interface SpaceModule
SpaceModuleException
public void configureSpaceChannel()
SpaceModule
configureSpaceChannel
in interface SpaceModule
public void messageReceived(ChannelMessage message)
MessageListener
messageReceived
in interface MessageListener
public void handleSendError(ChannelMessage message, CommunicationConnectorException exception) throws SpaceModuleException
MessageListener
handleSendError
in interface MessageListener
SpaceModuleException
public void destroySpace(SpaceCard spaceCard)
SpaceModule
destroySpace
in interface SpaceModule
spaceCard
- Space to destroypublic void spaceLost(SpaceCard spaceCard)
ServiceListener
spaceLost
in interface ServiceListener
spaceCard
- Information about the Spacepublic void sharedObjectAdded(Object arg0, Object arg1)
sharedObjectAdded
in interface SharedObjectListener
public void sharedObjectRemoved(Object arg0)
sharedObjectRemoved
in interface SharedObjectListener
public String getBrokerName()
getBrokerName
in interface Broker
public void dispose()
Module
public List<String> getPeersAddress()
SpaceModule
getPeersAddress
in interface SpaceModule
public void renewSpace(SpaceCard spaceCard)
SpaceModule
renewSpace
in interface SpaceModule
public BrokerMessage unmarshall(String message)
Broker
unmarshall
in interface Broker
Copyright © 2018 universAAL Consortium. All rights reserved.