org.objectweb.jeremie.libs.services.registry.jndi
Class JRMIRegistryContext

java.lang.Object
  extended byorg.objectweb.jeremie.libs.services.registry.jndi.JRMIRegistryContext
All Implemented Interfaces:
javax.naming.Context

public class JRMIRegistryContext
extends java.lang.Object
implements javax.naming.Context

Provides an implementation of a JNDI context for the Jeremie registry.


Field Summary
 
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 
Constructor Summary
JRMIRegistryContext(JRMIRegistryContext ctx)
          Creates a Jeremie registry context from an existing context.
JRMIRegistryContext(java.lang.String host, int port, java.util.Hashtable env)
          Creates a registry context for a Jeremie registry running on a given host and port.
 
Method Summary
 java.lang.Object addToEnvironment(java.lang.String propName, java.lang.Object propVal)
          Sets the value of a property in the current context's environment.
 void bind(javax.naming.Name name, java.lang.Object obj)
          Binds the given name with the given object in the current context's registry.
 void bind(java.lang.String name, java.lang.Object obj)
          Binds the given stringified name with the given object in the current context's registry.
 void close()
          Closes this registry context.
 javax.naming.Name composeName(javax.naming.Name name, javax.naming.Name prefix)
          Composes two names, one being relative to the current context, the other being the name of the current context relative to one of its ancestors.
 java.lang.String composeName(java.lang.String name, java.lang.String prefix)
          Composes two stringified names, one being relative to the current context, the other being the stringified name of the current context relative to one of its ancestors.
 javax.naming.Context createSubcontext(javax.naming.Name name)
          Subcontexts are not supported by Jeremie registry contexts.
 javax.naming.Context createSubcontext(java.lang.String name)
          Subcontexts are not supported by Jeremie registry contexts.
 void destroySubcontext(javax.naming.Name name)
          Subcontexts are not supported by Jeremie registry contexts.
 void destroySubcontext(java.lang.String name)
          Subcontexts are not supported by Jeremie registry contexts.
 java.util.Hashtable getEnvironment()
          Returns the environment of the current context.
 java.lang.String getNameInNamespace()
          Retrieves the full name of the current context within its own namespace, in other words, the empty string "".
 javax.naming.NameParser getNameParser(javax.naming.Name name)
          Retrieves the current context's name parser.
 javax.naming.NameParser getNameParser(java.lang.String name)
          Retrieves the current context's name parser.
 javax.naming.NamingEnumeration list(javax.naming.Name name)
          Enumerates the names and the class names of the objects that they are bound to in the current context's registry.
 javax.naming.NamingEnumeration list(java.lang.String name)
          Enumerates the names and the class names of the objects that they are bound to in the current context's registry.
 javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
          Enumerates the names and objects that they are bound to in the current context's registry.
 javax.naming.NamingEnumeration listBindings(java.lang.String name)
          Enumerates the names and objects that they are bound to in the current context's registry.
 java.lang.Object lookup(javax.naming.Name name)
          Retrieves the object bound to the given name in the current context's registry.
 java.lang.Object lookup(java.lang.String name)
          Retrieves the object bound to the given stringified name in the current context's registry.
 java.lang.Object lookupLink(javax.naming.Name name)
          Links are not treated specially by Jeremie registry contexts.
 java.lang.Object lookupLink(java.lang.String name)
          Links are not treated specially by Jeremie registry contexts.
 void rebind(javax.naming.Name name, java.lang.Object obj)
          Rebinds the given name with the given object in the current context's registry.
 void rebind(java.lang.String name, java.lang.Object obj)
          Rebinds the given stringified name with the given object in the current context's registry.
 java.lang.Object removeFromEnvironment(java.lang.String propName)
          Undefines the value of a property in the current context's environment.
 void rename(javax.naming.Name oldname, javax.naming.Name newname)
          Renames an existing bound name in the current context's registry.
 void rename(java.lang.String oldname, java.lang.String newname)
          Renames an existing stringified bound name in the current context's registry.
 void unbind(javax.naming.Name name)
          Unbinds the given name from the current context's registry.
 void unbind(java.lang.String name)
          Unbinds the given stringified name from the current context's registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRMIRegistryContext

public JRMIRegistryContext(JRMIRegistryContext ctx)
                    throws javax.naming.NamingException
Creates a Jeremie registry context from an existing context.

Parameters:
ctx - a given registry context.

JRMIRegistryContext

public JRMIRegistryContext(java.lang.String host,
                           int port,
                           java.util.Hashtable env)
                    throws javax.naming.NamingException
Creates a registry context for a Jeremie registry running on a given host and port.

Parameters:
host - a host on which a Jeremie registry is running;
port - a port on which the registry accepts connections;
env - a hashtable representing the environment.
Throws:
javax.naming.NamingException - if something goes wrong.
Method Detail

lookup

public java.lang.Object lookup(javax.naming.Name name)
                        throws javax.naming.NamingException
Retrieves the object bound to the given name in the current context's registry.

If the object returned is a Jeremie JNDI reference, then the javax.naming.spi.NamingManager is called to retrieve the target object referenced.

Specified by:
lookup in interface javax.naming.Context
Parameters:
name - the name of the object to be retrieved. If empty, then a new instance of this context is returned.
Returns:
the object bound to the name, or whose reference is bound to the name.
Throws:
javax.naming.NamingException - if something goes wrong.

lookup

public java.lang.Object lookup(java.lang.String name)
                        throws javax.naming.NamingException
Retrieves the object bound to the given stringified name in the current context's registry.

Specified by:
lookup in interface javax.naming.Context
Parameters:
name - the stringified name of the object to be retrieved. If empty, then a new instance of this context is returned.
Returns:
the object bound to the name, or whose reference is bound to the name.
Throws:
javax.naming.NamingException - if something goes wrong.

bind

public void bind(javax.naming.Name name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Binds the given name with the given object in the current context's registry. The object being bound must be either a remote object, or a JNDI reference or referenceable object.

Before binding, the javax.naming.spi.NamingManager is called to consult any possible state factories concerning the object.

Specified by:
bind in interface javax.naming.Context
Parameters:
name - the (non-empty) name to bind;
obj - the object to bind which must be either Remote, Reference, or javax.naming.Referenceable.
Throws:
javax.naming.NamingException - if something goes wrong.

bind

public void bind(java.lang.String name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Binds the given stringified name with the given object in the current context's registry. The object being bound must be either a remote object, or a JNDI reference or referenceable object.

Specified by:
bind in interface javax.naming.Context
Parameters:
name - the (non-empty) stringified name to bind;
obj - the object to bind which must be either Remote, Reference, or javax.naming.Referenceable.
Throws:
javax.naming.NamingException - if something goes wrong.

rebind

public void rebind(javax.naming.Name name,
                   java.lang.Object obj)
            throws javax.naming.NamingException
Rebinds the given name with the given object in the current context's registry. The object being bound must be either a remote object, or a JNDI reference or referenceable object.

Before binding, the javax.naming.spi.NamingManager is called to consult any possible state factories concerning the object.

Specified by:
rebind in interface javax.naming.Context
Parameters:
name - the (non-empty) name to rebind;
obj - the object to bind which must be either Remote, Reference, or javax.naming.Referenceable.
Throws:
javax.naming.NamingException - if something goes wrong.

rebind

public void rebind(java.lang.String name,
                   java.lang.Object obj)
            throws javax.naming.NamingException
Rebinds the given stringified name with the given object in the current context's registry. The object being bound must be either a remote object, or a JNDI reference or referenceable object.

Specified by:
rebind in interface javax.naming.Context
Parameters:
name - the (non-empty) stringified name to rebind;
obj - the object to bind which must be either Remote, Reference, or javax.naming.Referenceable.
Throws:
javax.naming.NamingException - if something goes wrong.

unbind

public void unbind(javax.naming.Name name)
            throws javax.naming.NamingException
Unbinds the given name from the current context's registry.

Specified by:
unbind in interface javax.naming.Context
Parameters:
name - the name to unbind.
Throws:
javax.naming.NamingException - if something goes wrong.

unbind

public void unbind(java.lang.String name)
            throws javax.naming.NamingException
Unbinds the given stringified name from the current context's registry.

Specified by:
unbind in interface javax.naming.Context
Parameters:
name - the name to unbind.
Throws:
javax.naming.NamingException - if something goes wrong.

rename

public void rename(javax.naming.Name oldname,
                   javax.naming.Name newname)
            throws javax.naming.NamingException
Renames an existing bound name in the current context's registry.

Specified by:
rename in interface javax.naming.Context
Throws:
javax.naming.NamingException - if something goes wrong.

rename

public void rename(java.lang.String oldname,
                   java.lang.String newname)
            throws javax.naming.NamingException
Renames an existing stringified bound name in the current context's registry.

Specified by:
rename in interface javax.naming.Context
Throws:
javax.naming.NamingException - if something goes wrong.

list

public javax.naming.NamingEnumeration list(javax.naming.Name name)
                                    throws javax.naming.NamingException
Enumerates the names and the class names of the objects that they are bound to in the current context's registry. The input name must be empty so that it signifies the current context. For each (name, class name) pair, the class name is java.lang.Object.

Specified by:
list in interface javax.naming.Context
Parameters:
name - the name of the context to list; must be empty.
Returns:
an enumeration of the (name, class name) pairs in the registry.
Throws:
javax.naming.NamingException - if something goes wrong.

list

public javax.naming.NamingEnumeration list(java.lang.String name)
                                    throws javax.naming.NamingException
Enumerates the names and the class names of the objects that they are bound to in the current context's registry. The input stringified name must be "" so that it signifies the current context. For each (name, class name) pair, the class name is java.lang.Object.

Specified by:
list in interface javax.naming.Context
Parameters:
name - the stringifed name of the context to list; must be "".
Returns:
an enumeration of the (name, class name) pairs in the registry.
Throws:
javax.naming.NamingException - if something goes wrong.

listBindings

public javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
                                            throws javax.naming.NamingException
Enumerates the names and objects that they are bound to in the current context's registry. The input name must be empty so that it signifies the current context.

Specified by:
listBindings in interface javax.naming.Context
Parameters:
name - the name of the context to list; must be empty.
Returns:
an enumeration of the (name, object) pairs in the registry.
Throws:
javax.naming.NamingException - if something goes wrong.

listBindings

public javax.naming.NamingEnumeration listBindings(java.lang.String name)
                                            throws javax.naming.NamingException
Enumerates the names and objects that they are bound to in the current context's registry. The input stringified name must be "" so that it signifies the current context.

Specified by:
listBindings in interface javax.naming.Context
Parameters:
name - the stringified name of the context to list; must be "".
Returns:
an enumeration of the (name, object) pairs in the registry.
Throws:
javax.naming.NamingException - if something goes wrong.

createSubcontext

public javax.naming.Context createSubcontext(javax.naming.Name name)
                                      throws javax.naming.NamingException
Subcontexts are not supported by Jeremie registry contexts.

Specified by:
createSubcontext in interface javax.naming.Context
Throws:
javax.naming.OperationNotSupportedException
javax.naming.NamingException

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name)
                                      throws javax.naming.NamingException
Subcontexts are not supported by Jeremie registry contexts.

Specified by:
createSubcontext in interface javax.naming.Context
Throws:
javax.naming.OperationNotSupportedException
javax.naming.NamingException

destroySubcontext

public void destroySubcontext(javax.naming.Name name)
                       throws javax.naming.NamingException
Subcontexts are not supported by Jeremie registry contexts.

Specified by:
destroySubcontext in interface javax.naming.Context
Throws:
javax.naming.OperationNotSupportedException
javax.naming.NamingException

destroySubcontext

public void destroySubcontext(java.lang.String name)
                       throws javax.naming.NamingException
Subcontexts are not supported by Jeremie registry contexts.

Specified by:
destroySubcontext in interface javax.naming.Context
Throws:
javax.naming.OperationNotSupportedException
javax.naming.NamingException

lookupLink

public java.lang.Object lookupLink(javax.naming.Name name)
                            throws javax.naming.NamingException
Links are not treated specially by Jeremie registry contexts. This method does the same as the lookup(Name) method.

Specified by:
lookupLink in interface javax.naming.Context
Parameters:
name - the name of the object to be retrieved. If empty, then a new instance of this context is returned.
Returns:
the object bound to the name, or whose reference is bound to the name.
Throws:
javax.naming.NamingException - if something goes wrong.
See Also:
lookup(Name)

lookupLink

public java.lang.Object lookupLink(java.lang.String name)
                            throws javax.naming.NamingException
Links are not treated specially by Jeremie registry contexts. This method does the same as the lookup(String) method.

Specified by:
lookupLink in interface javax.naming.Context
Parameters:
name - the name of the object to be retrieved. If empty, then a new instance of this context is returned.
Returns:
the object bound to the name, or whose reference is bound to the name.
Throws:
javax.naming.NamingException - if something goes wrong.
See Also:
lookup(String)

getNameParser

public javax.naming.NameParser getNameParser(javax.naming.Name name)
                                      throws javax.naming.NamingException
Retrieves the current context's name parser.

Specified by:
getNameParser in interface javax.naming.Context
Parameters:
name - the name of the context from which to get the parser; ignored.
Returns:
the name parser of the current registry context.
Throws:
javax.naming.NamingException - if something goes wrong.

getNameParser

public javax.naming.NameParser getNameParser(java.lang.String name)
                                      throws javax.naming.NamingException
Retrieves the current context's name parser.

Specified by:
getNameParser in interface javax.naming.Context
Parameters:
name - the stringified name of the context from which to get the parser; ignored.
Returns:
the name parser of the current registry context.
Throws:
javax.naming.NamingException - if something goes wrong.

composeName

public javax.naming.Name composeName(javax.naming.Name name,
                                     javax.naming.Name prefix)
                              throws javax.naming.NamingException
Composes two names, one being relative to the current context, the other being the name of the current context relative to one of its ancestors.

Specified by:
composeName in interface javax.naming.Context
Parameters:
name - a name relative to this registry context;
prefix - the name of this context relative to one of its ancestors.
Returns:
a composed name.
Throws:
javax.naming.NamingException - if something goes wrong.

composeName

public java.lang.String composeName(java.lang.String name,
                                    java.lang.String prefix)
                             throws javax.naming.NamingException
Composes two stringified names, one being relative to the current context, the other being the stringified name of the current context relative to one of its ancestors.

Specified by:
composeName in interface javax.naming.Context
Parameters:
name - a stringified name relative to this registry context;
prefix - the stringified name of this context relative to one of its ancestors.
Returns:
a composed stringified name.
Throws:
javax.naming.NamingException - if something goes wrong.

getEnvironment

public java.util.Hashtable getEnvironment()
                                   throws javax.naming.NamingException
Returns the environment of the current context.

Specified by:
getEnvironment in interface javax.naming.Context
Returns:
the possibly empty environment of this context.
Throws:
javax.naming.NamingException

addToEnvironment

public java.lang.Object addToEnvironment(java.lang.String propName,
                                         java.lang.Object propVal)
                                  throws javax.naming.NamingException
Sets the value of a property in the current context's environment. Overwrites any previous value of the property.

Specified by:
addToEnvironment in interface javax.naming.Context
Parameters:
propName - the name of the property;
propVal - the value of the property.
Returns:
the previous value of the property, possibly null.
Throws:
javax.naming.NamingException - if something goes wrong.

removeFromEnvironment

public java.lang.Object removeFromEnvironment(java.lang.String propName)
                                       throws javax.naming.NamingException
Undefines the value of a property in the current context's environment.

Specified by:
removeFromEnvironment in interface javax.naming.Context
Parameters:
propName - the name of the property;
Returns:
the previous value of the property, possibly null.
Throws:
javax.naming.NamingException - if something goes wrong.

getNameInNamespace

public java.lang.String getNameInNamespace()
                                    throws javax.naming.NamingException
Retrieves the full name of the current context within its own namespace, in other words, the empty string "".

Specified by:
getNameInNamespace in interface javax.naming.Context
Returns:
the full name of the current context.
Throws:
javax.naming.NamingException - if something goes wrong.

close

public void close()
           throws javax.naming.NamingException
Closes this registry context.

Specified by:
close in interface javax.naming.Context
Throws:
javax.naming.NamingException - if something goes wrong.