dermi
Class Naming

java.lang.Object
  extended by dermi.Naming

public class Naming
extends java.lang.Object

The Naming class provides methods for storing and obtaining references to remote objects in the remote object registry.

The dermi.Naming API (unlike Java RMI) does not use URLs, but properties objects or files containing connection parameters. It is then mandatory to call the loadRegistry method before using the functionality of the registry.

Author:
Carles Pairot , Ruben Mondejar

Nested Class Summary
protected  class Naming.NamingCommand
          Common superclass for data reception commands.
 
Constructor Summary
Naming()
           
 
Method Summary
static void bind(java.lang.String name, ERemote ref)
          Binds the specified name to a remote object.
static void bindRoot()
          Special root ("p2p://") bind method
static DermiConnection getConnection()
          Method used to get the connection to the Pastry node (for reutilization purposes)
static boolean isConnected()
          Method used to know if the registry is already connected to a Pastry node
static java.util.Collection list(java.lang.String root)
          Returns a Vector of the names bound in the registry.
static void loadRegistry(rice.p2p.commonapi.IdFactory FACTORY, rice.p2p.commonapi.Node pn, int REPLICATION_FACTOR)
          It connects to the decentralized registry
static void loadRegistry(java.lang.String ref)
          It connects to the Registry (by creating a pastry node!)
static ERemote lookup(java.lang.String name)
          Returns a reference, a stub, for the remote object associated with the specified name.
static java.io.Serializable lookupSer(rice.p2p.commonapi.Id id)
          Returns a reference, a stub, for the remote object associated with the specified name.
static void rebind(java.lang.String name, ERemote ref)
          Rebinds the specified name in the registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Naming

public Naming()
Method Detail

loadRegistry

public static void loadRegistry(rice.p2p.commonapi.IdFactory FACTORY,
                                rice.p2p.commonapi.Node pn,
                                int REPLICATION_FACTOR)
                         throws RemoteException
It connects to the decentralized registry

Parameters:
FACTORY - IdFactory Factory for Id creation
pn - Node The node where the registry will run on
REPLICATION_FACTOR - int Replication factor
Throws:
RemoteException - If registry cannot be created

loadRegistry

public static void loadRegistry(java.lang.String ref)
                         throws RemoteException
It connects to the Registry (by creating a pastry node!)

Parameters:
ref - Name of properties file containing connection parameters.
Throws:
RemoteException - If the connection with the event service fails.

lookup

public static ERemote lookup(java.lang.String name)
                      throws RemoteException
Returns a reference, a stub, for the remote object associated with the specified name.

Parameters:
name - Id of the remote object in the Registry
Returns:
Eremote Reference to the remote object
Throws:
RemoteException - If the connection with the event service fails.

lookupSer

public static java.io.Serializable lookupSer(rice.p2p.commonapi.Id id)
                                      throws RemoteException
Returns a reference, a stub, for the remote object associated with the specified name.

Parameters:
id - Id of the remote object in the Registry
Returns:
Eremote Reference to the remote object
Throws:
RemoteException - If the connection with the event service fails.

isConnected

public static boolean isConnected()
Method used to know if the registry is already connected to a Pastry node

Returns:
boolean true if it is connected

getConnection

public static DermiConnection getConnection()
Method used to get the connection to the Pastry node (for reutilization purposes)

Returns:
DermiConnection The connection

bind

public static void bind(java.lang.String name,
                        ERemote ref)
                 throws RemoteException
Binds the specified name to a remote object.

Parameters:
name - Id of the remote object
ref - remote object reference to bind
Throws:
RemoteException - If the connection with the event service fails.

bindRoot

public static void bindRoot()
                     throws RemoteException
Special root ("p2p://") bind method

Throws:
RemoteException - If the connection with the event service fails.

rebind

public static void rebind(java.lang.String name,
                          ERemote ref)
                   throws RemoteException
Rebinds the specified name in the registry.

Parameters:
name - Id of the remote object
ref - remote object reference to bind
Throws:
RemoteException - If the connection with the event service fails.

list

public static java.util.Collection list(java.lang.String root)
                                 throws RemoteException
Returns a Vector of the names bound in the registry. The Vector contains a snapshot of the names present in the registry at the time of the call.

Returns:
Vector A list of Ids from remote objects.
Throws:
dermi.RemoteException - If the connection with the event service fails.
RemoteException