dermi.registry.pastry
Class Naming

java.lang.Object
  extended by dermi.registry.pastry.Naming
All Implemented Interfaces:
Naming

public class Naming
extends java.lang.Object
implements Naming

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.

Version:
1.2
Author:
Carles Pairot , Ruben Mondejar

Nested Class Summary
protected  class Naming.NamingCommand
          Common superclass for data reception commands.
 
Method Summary
 void bind(java.lang.String name, ERemote ref)
          Binds the specified name to a remote object.
 void bind(java.lang.String name, java.util.Properties env)
          Binds the specified name to a remote object.
 void bindRoot()
          Special root ("p2p://") bind method
 boolean bindSecure(java.lang.String context, Id id, java.io.Serializable object, java.lang.String pass)
           
 boolean bindSecure(java.lang.String context, Id id, java.io.Serializable object, java.lang.String pass, boolean getcheck)
           
 boolean bindSer(Id id, java.io.Serializable object)
           
 boolean bindSer(java.lang.String context, Id id, java.io.Serializable object)
           
 boolean bindSer(java.lang.String name, java.io.Serializable object)
           
 boolean bindSer(java.lang.String context, java.lang.String name, java.io.Serializable object)
           
 DermiConnection getConnection()
          Method used to get the connection to the Pastry node (for reutilization purposes)
 java.util.Collection getIncomingLinks(java.lang.String context, Id id)
           
static Naming getInstance()
           
 java.util.Collection getOutgoingLinks(java.lang.String context, Id id)
           
 java.util.Hashtable getReplicaInfo()
           
 java.util.Hashtable getStorageInfo()
           
 void insert(java.lang.String context, java.lang.String keywords, java.lang.String key, java.io.Serializable value)
           
 void insertURL(java.lang.String context, Id id, java.net.URL url, java.lang.String field)
           
 boolean isConnected()
          Method used to know if the registry is already connected to a Pastry node
 void leave()
          It closes the connection and kills the node
 java.util.Collection list(java.lang.String root)
          Returns a Vector of the names bound in the registry.
 void loadRegistry(DermiConnection conn, java.util.Properties props)
          It connects to the decentralized registry
 void loadRegistry(java.lang.String ref)
          It connects to the Registry (by creating a node!)
 ERemote lookup(java.lang.String name)
          Returns a reference, a stub, for the remote object associated with the specified name.
 ERemote lookup(java.lang.String name, java.lang.String communityId, java.lang.String className)
          Returns a reference, a stub, for the remote object associated with the specified name.
 java.io.Serializable lookupSecure(java.lang.String context, Id id, java.lang.String pass)
           
 java.io.Serializable lookupSer(java.lang.String componentURL)
          Returns a serializable object associated with the specified name.
 java.io.Serializable lookupSer(java.lang.String context, Id id)
          Returns a serializable object associated with the specified name.
 java.io.Serializable lookupSer(java.lang.String context, Id id, java.lang.String field)
           
 java.io.Serializable lookupSer(java.lang.String context, java.lang.String componentURL)
           
 java.net.URL lookupURL(java.lang.String context, Id id, java.lang.String field)
           
 void modify(java.lang.String context, Id id, java.util.Collection values, java.lang.String field, boolean add)
           
 void modify(java.lang.String context, Id id, java.lang.Object value, java.lang.String field, boolean add)
           
 bunshin.util.ResultSortedQueue query(java.lang.String context, java.lang.String keywords)
           
 void rebind(java.lang.String name, ERemote ref)
          Rebinds the specified name in the registry.
 void remove(java.lang.String context, java.lang.String keywords, java.lang.String key)
           
 void removeRemoteListener(java.lang.String context, Id id, java.lang.String field)
           
 void removeSer(Id id)
           
 void removeSer(java.lang.String key)
           
 void removeSer(java.lang.String context, Id id, java.lang.String field)
           
 void setInfoContext(java.lang.String context, java.lang.String path, java.lang.String url, java.net.URL[] URLsList)
           
 void setRemoteListener(java.lang.String context, Id id, bunshin.RemoteListener listener, java.lang.String field)
           
 void unbind(java.lang.String name)
          Unbinds the specified name from a remote object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Naming getInstance()

loadRegistry

public void loadRegistry(DermiConnection conn,
                         java.util.Properties props)
                  throws RemoteException
It connects to the decentralized registry

Parameters:
conn - DermiConnection The Dermi node where the registry will run on
Throws:
RemoteException - If registry cannot be created

loadRegistry

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

Specified by:
loadRegistry in interface Naming
Parameters:
ref - Name of properties file containing connection parameters.
Throws:
RemoteException - If the connection with the event service fails.

setInfoContext

public void setInfoContext(java.lang.String context,
                           java.lang.String path,
                           java.lang.String url,
                           java.net.URL[] URLsList)
                    throws RemoteException
Specified by:
setInfoContext in interface Naming
Throws:
RemoteException

leave

public void leave()
           throws RemoteException
It closes the connection and kills the node

Specified by:
leave in interface Naming
Throws:
RemoteException - If the connection with the event service fails.

lookup

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

Specified by:
lookup in interface Naming
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.

lookup

public ERemote lookup(java.lang.String name,
                      java.lang.String communityId,
                      java.lang.String className)
               throws RemoteException
Returns a reference, a stub, for the remote object associated with the specified name. Should this reference be not bound, start it remotely in the community, register it and return the newly-created reference

Specified by:
lookup in interface Naming
Parameters:
name - Id of the remote object in the Registry
communityId - Id of the community where the object is to be activated (if necessary)
Returns:
Eremote Reference to the remote object
Throws:
RemoteException - If the connection with the event service fails.

lookupSer

public java.io.Serializable lookupSer(java.lang.String context,
                                      Id id)
                               throws RemoteException
Returns a serializable object associated with the specified name.

Specified by:
lookupSer in interface Naming
Parameters:
id - Id of the remote object in the Registry
Returns:
Serializable Object's reference
Throws:
RemoteException - If the connection with the event service fails.

lookupSer

public java.io.Serializable lookupSer(java.lang.String context,
                                      Id id,
                                      java.lang.String field)
                               throws RemoteException
Specified by:
lookupSer in interface Naming
Throws:
RemoteException

lookupURL

public java.net.URL lookupURL(java.lang.String context,
                              Id id,
                              java.lang.String field)
                       throws RemoteException
Specified by:
lookupURL in interface Naming
Throws:
RemoteException

lookupSer

public java.io.Serializable lookupSer(java.lang.String context,
                                      java.lang.String componentURL)
                               throws RemoteException
Specified by:
lookupSer in interface Naming
Throws:
RemoteException

lookupSer

public java.io.Serializable lookupSer(java.lang.String componentURL)
                               throws RemoteException
Description copied from interface: Naming
Returns a serializable object associated with the specified name.

Specified by:
lookupSer in interface Naming
Returns:
Serializable Object's value
Throws:
RemoteException - If the connection with the event service fails.

removeSer

public void removeSer(java.lang.String context,
                      Id id,
                      java.lang.String field)
               throws RemoteException
Specified by:
removeSer in interface Naming
Throws:
RemoteException

removeSer

public void removeSer(Id id)
               throws RemoteException
Specified by:
removeSer in interface Naming
Throws:
RemoteException

removeSer

public void removeSer(java.lang.String key)
               throws RemoteException
Specified by:
removeSer in interface Naming
Throws:
RemoteException

isConnected

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

Specified by:
isConnected in interface Naming
Returns:
boolean true if it is connected

getConnection

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

Specified by:
getConnection in interface Naming
Returns:
DermiConnection The connection

bind

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

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

bind

public void bind(java.lang.String name,
                 java.util.Properties env)
          throws RemoteException
Binds the specified name to a remote object.

Specified by:
bind in interface Naming
Parameters:
name - Id of the remote object
env - Object properties
Throws:
RemoteException - If the connection with the event service fails.

bindSer

public boolean bindSer(Id id,
                       java.io.Serializable object)
                throws RemoteException
Specified by:
bindSer in interface Naming
Throws:
RemoteException

bindSer

public boolean bindSer(java.lang.String context,
                       Id id,
                       java.io.Serializable object)
                throws RemoteException
Specified by:
bindSer in interface Naming
Throws:
RemoteException

bindSer

public boolean bindSer(java.lang.String context,
                       java.lang.String name,
                       java.io.Serializable object)
                throws RemoteException
Specified by:
bindSer in interface Naming
Throws:
RemoteException

bindSer

public boolean bindSer(java.lang.String name,
                       java.io.Serializable object)
                throws RemoteException
Specified by:
bindSer in interface Naming
Throws:
RemoteException

unbind

public void unbind(java.lang.String name)
            throws RemoteException
Unbinds the specified name from a remote object.

Specified by:
unbind in interface Naming
Parameters:
name - Id of the remote object
Throws:
dermi.NotBoundException - - if the Registry does not contains this Id.
dermi.RemoteException - - if the connection with the event service fails.
RemoteException - If the connection with the event service fails.

bindRoot

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

Specified by:
bindRoot in interface Naming
Throws:
RemoteException - If the connection with the event service fails.

rebind

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

Specified by:
rebind in interface Naming
Parameters:
name - Id of the remote object
ref - remote object reference to bind
Throws:
RemoteException - If the connection with the event service fails.

getStorageInfo

public java.util.Hashtable getStorageInfo()
                                   throws RemoteException
Specified by:
getStorageInfo in interface Naming
Throws:
RemoteException

getReplicaInfo

public java.util.Hashtable getReplicaInfo()
                                   throws RemoteException
Specified by:
getReplicaInfo in interface Naming
Throws:
RemoteException

list

public 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.

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

bindSecure

public boolean bindSecure(java.lang.String context,
                          Id id,
                          java.io.Serializable object,
                          java.lang.String pass)
                   throws RemoteException
Specified by:
bindSecure in interface Naming
Throws:
RemoteException

bindSecure

public boolean bindSecure(java.lang.String context,
                          Id id,
                          java.io.Serializable object,
                          java.lang.String pass,
                          boolean getcheck)
                   throws RemoteException
Specified by:
bindSecure in interface Naming
Throws:
RemoteException

lookupSecure

public java.io.Serializable lookupSecure(java.lang.String context,
                                         Id id,
                                         java.lang.String pass)
                                  throws RemoteException
Specified by:
lookupSecure in interface Naming
Throws:
RemoteException

insertURL

public void insertURL(java.lang.String context,
                      Id id,
                      java.net.URL url,
                      java.lang.String field)
               throws RemoteException
Specified by:
insertURL in interface Naming
Throws:
RemoteException

modify

public void modify(java.lang.String context,
                   Id id,
                   java.lang.Object value,
                   java.lang.String field,
                   boolean add)
            throws RemoteException
Specified by:
modify in interface Naming
Throws:
RemoteException

modify

public void modify(java.lang.String context,
                   Id id,
                   java.util.Collection values,
                   java.lang.String field,
                   boolean add)
            throws RemoteException
Specified by:
modify in interface Naming
Throws:
RemoteException

setRemoteListener

public void setRemoteListener(java.lang.String context,
                              Id id,
                              bunshin.RemoteListener listener,
                              java.lang.String field)
                       throws RemoteException
Specified by:
setRemoteListener in interface Naming
Throws:
RemoteException

removeRemoteListener

public void removeRemoteListener(java.lang.String context,
                                 Id id,
                                 java.lang.String field)
                          throws RemoteException
Specified by:
removeRemoteListener in interface Naming
Throws:
RemoteException

getIncomingLinks

public java.util.Collection getIncomingLinks(java.lang.String context,
                                             Id id)
                                      throws RemoteException
Specified by:
getIncomingLinks in interface Naming
Throws:
RemoteException

getOutgoingLinks

public java.util.Collection getOutgoingLinks(java.lang.String context,
                                             Id id)
                                      throws RemoteException
Specified by:
getOutgoingLinks in interface Naming
Throws:
RemoteException

insert

public void insert(java.lang.String context,
                   java.lang.String keywords,
                   java.lang.String key,
                   java.io.Serializable value)
            throws RemoteException
Specified by:
insert in interface Naming
Throws:
RemoteException

query

public bunshin.util.ResultSortedQueue query(java.lang.String context,
                                            java.lang.String keywords)
                                     throws RemoteException
Specified by:
query in interface Naming
Throws:
RemoteException

remove

public void remove(java.lang.String context,
                   java.lang.String keywords,
                   java.lang.String key)
            throws RemoteException
Specified by:
remove in interface Naming
Throws:
RemoteException