public class RMIPeerManager
extends java.lang.Object
This manager is in charge of sending all broadcast messages to a set of known peers (thanks to its
sendAll(String, Object) method) and to bind a RMIBroadcastService (thanks to
its method).
The manager is a singleton. To be instantiated successfully the first time its getInstance()
method is called, a property file at this location must exists
in the classpath. Both RMI server port and peers location must be declared. The port is associated to the key
RMI_SERVER_PORT_PROPERTY and each peer location will be associated to a key starting by
this prefix. Sample of properties file content :
rmi.server.port=4000
rmi.peer.server1=com.my.company.server1:4000
rmi.peer.server2=com.my.company.server2:4000
NOTE : the properties file should not contains the peer's URL of the server this manager is running on.
Moreover, any value declared in the properties file could be overridden with a system property. Each system property
must starts with this prefix followed by the property key as declared in
the properties file. For instance, if I want to override the value of the property 'rmi.peer.server1' declared in the
properties file, I will run my server with '-D org.atmosphere.rmi.peer.server1=my.overridden.host:port' in the command
line.
TODO : Should be enhanced to discover peers automatically thanks to multicast
| Modifier and Type | Method and Description |
|---|---|
static RMIPeerManager |
getInstance()
Gets the unique instance of
RMIPeerManager. |
void |
sendAll(java.lang.String broadcasterId,
java.lang.Object message)
Sends the given message to the broadcaster identified by the given ID belonging to all the registered peers.
|
void |
server(java.lang.String broadcasterId,
RMIBroadcastService service,
org.atmosphere.cpr.AtmosphereConfig config)
Creates a service by binding the given service for the given broadcaster ID.
|
public static RMIPeerManager getInstance()
Gets the unique instance of RMIPeerManager.
If this is the first time the method is called, the singleton will be instantiated here.
public void sendAll(java.lang.String broadcasterId,
java.lang.Object message)
Sends the given message to the broadcaster identified by the given ID belonging to all the registered peers.
broadcasterId - the broadcaster IDmessage - the message to be sentpublic void server(java.lang.String broadcasterId,
RMIBroadcastService service,
org.atmosphere.cpr.AtmosphereConfig config)
Creates a service by binding the given service for the given broadcaster ID.
broadcasterId - the broadcaster IDservice - the service to be boundconfig - the atmosphere configCopyright © 2018. All Rights Reserved.