Class RMIPeerManager
- java.lang.Object
-
- org.atmosphere.plugin.rmi.RMIPeerManager
-
public class RMIPeerManager extends java.lang.ObjectThis 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 aRMIBroadcastService(thanks to itsmethod).The manager is a singleton. To be instantiated successfully the first time its
getInstance()method is called, a property file atthislocation must exists in the classpath. Both RMI server port and peers location must be declared. The port is associated to the keyRMI_SERVER_PORT_PROPERTYand each peer location will be associated to a key starting bythisprefix. Sample of properties file content :rmi.server.port=4000 rmi.peer.server1=com.my.company.server1:4000 rmi.peer.server2=com.my.company.server2:4000NOTE : 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
thisprefix 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
- Since:
- 1.1.1
- Version:
- 1.0
- Author:
- Guillaume DROUET
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RMIPeerManagergetInstance()Gets the unique instance ofRMIPeerManager.voidsendAll(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.voidserver(java.lang.String broadcasterId, RMIBroadcastService service, org.atmosphere.cpr.AtmosphereConfig config)Creates a service by binding the given service for the given broadcaster ID.
-
-
-
Method Detail
-
getInstance
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.
- Returns:
- the unique instance
-
sendAll
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.
- Parameters:
broadcasterId- the broadcaster IDmessage- the message to be sent
-
server
public 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.
- Parameters:
broadcasterId- the broadcaster IDservice- the service to be boundconfig- the atmosphere config
-
-