org.atmosphere.plugin.rmi
Class RMIPeerManager

java.lang.Object
  extended by org.atmosphere.plugin.rmi.RMIPeerManager

public class RMIPeerManager
extends Object

This manager is in charge of sending all broadcasted 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

Since:
1.1.1
Version:
1.0
Author:
Guillaume DROUET

Method Summary
static RMIPeerManager getInstance()
           Gets the unique instance of RMIPeerManager.
 void sendAll(String broadcasterId, Object message)
           Sends the given message to the broadcaster identified by the given ID belonging to all the registered peers.
 void server(String broadcasterId, RMIBroadcastService service)
           Creates a service by binding the given service for the given broadcaster ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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(String broadcasterId,
                    Object message)

Sends the given message to the broadcaster identified by the given ID belonging to all the registered peers.

Parameters:
broadcasterId - the broadcaster ID
message - the message to be sent

server

public void server(String broadcasterId,
                   RMIBroadcastService service)

Creates a service by binding the given service for the given broadcaster ID.

Parameters:
broadcasterId - the broadcaster ID
service - the service to be bound


Copyright © 2013. All Rights Reserved.