org.objectweb.jeremie.services.registry.jndi

Class JRMIRegistryContext

Implemented Interfaces:
Context

public class JRMIRegistryContext
extends Object
implements Context

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

Constructor Summary

JRMIRegistryContext(String host, int port, Hashtable env)
Creates a registry context for a Jeremie registry running on a given host and port.
JRMIRegistryContext(JRMIRegistryContext ctx)
Creates a Jeremie registry context from an existing context.

Method Summary

Object
addToEnvironment(String propName, Object propVal)
Sets the value of a property in the current context's environment.
void
bind(Name name, Object obj)
Binds the given name with the given object in the current context's registry.
void
bind(String name, Object obj)
Binds the given stringified name with the given object in the current context's registry.
void
close()
Closes this registry context.
Name
composeName(Name name, 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.
String
composeName(String name, 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.
Context
createSubcontext(Name name)
Subcontexts are not supported by Jeremie registry contexts.
Context
createSubcontext(String name)
Subcontexts are not supported by Jeremie registry contexts.
void
destroySubcontext(Name name)
Subcontexts are not supported by Jeremie registry contexts.
void
destroySubcontext(String name)
Subcontexts are not supported by Jeremie registry contexts.
Hashtable
getEnvironment()
Returns the environment of the current context.
String
getNameInNamespace()
Retrieves the full name of the current context within its own namespace, in other words, the empty string "".
NameParser
getNameParser(Name name)
Retrieves the current context's name parser.
NameParser
getNameParser(String name)
Retrieves the current context's name parser.
NamingEnumeration
list(Name name)
Enumerates the names and the class names of the objects that they are bound to in the current context's registry.
NamingEnumeration
list(String name)
Enumerates the names and the class names of the objects that they are bound to in the current context's registry.
NamingEnumeration
listBindings(Name name)
Enumerates the names and objects that they are bound to in the current context's registry.
NamingEnumeration
listBindings(String name)
Enumerates the names and objects that they are bound to in the current context's registry.
Object
lookup(Name name)
Retrieves the object bound to the given name in the current context's registry.
Object
lookup(String name)
Retrieves the object bound to the given stringified name in the current context's registry.
Object
lookupLink(Name name)
Links are not treated specially by Jeremie registry contexts.
Object
lookupLink(String name)
Links are not treated specially by Jeremie registry contexts.
void
rebind(Name name, Object obj)
Rebinds the given name with the given object in the current context's registry.
void
rebind(String name, Object obj)
Rebinds the given stringified name with the given object in the current context's registry.
Object
removeFromEnvironment(String propName)
Undefines the value of a property in the current context's environment.
void
rename(Name oldname, Name newname)
Renames an existing bound name in the current context's registry.
void
rename(String oldname, String newname)
Renames an existing stringified bound name in the current context's registry.
void
unbind(Name name)
Unbinds the given name from the current context's registry.
void
unbind(String name)
Unbinds the given stringified name from the current context's registry.

Constructor Details

JRMIRegistryContext

public JRMIRegistryContext(String host,
                           int port,
                           Hashtable env)
            throws 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.


JRMIRegistryContext

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

Parameters:
ctx - a given registry context.

Method Details

addToEnvironment

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

Parameters:
propName - the name of the property;
propVal - the value of the property.

Returns:
the previous value of the property, possibly null.


bind

public void bind(Name name,
                 Object obj)
            throws 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. javax.naming.Reference, or javax.naming.Referenceable.

Parameters:
name - the (non-empty) name to bind;
obj - the object to bind which must be either java.rmi.Remote,


bind

public void bind(String name,
                 Object obj)
            throws 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. javax.naming.Reference, or javax.naming.Referenceable.

Parameters:
name - the (non-empty) stringified name to bind;
obj - the object to bind which must be either java.rmi.Remote,


close

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


composeName

public Name composeName(Name name,
                        Name prefix)
            throws 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.

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.


composeName

public String composeName(String name,
                          String prefix)
            throws 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.

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.


createSubcontext

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


createSubcontext

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


destroySubcontext

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


destroySubcontext

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


getEnvironment

public Hashtable getEnvironment()
            throws NamingException
Returns the environment of the current context.

Returns:
the possibly empty environment of this context.


getNameInNamespace

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

Returns:
the full name of the current context.


getNameParser

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

Parameters:
name - the name of the context from which to get the parser; ignored.

Returns:
the name parser of the current registry context.


getNameParser

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

Parameters:
name - the stringified name of the context from which to get the parser; ignored.

Returns:
the name parser of the current registry context.


list

public NamingEnumeration list(Name name)
            throws 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.

Parameters:
name - the name of the context to list; must be empty.

Returns:
an enumeration of the (name, class name) pairs in the registry.


list

public NamingEnumeration list(String name)
            throws 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.

Parameters:
name - the stringifed name of the context to list; must be "".

Returns:
an enumeration of the (name, class name) pairs in the registry.


listBindings

public NamingEnumeration listBindings(Name name)
            throws 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.

Parameters:
name - the name of the context to list; must be empty.

Returns:
an enumeration of the (name, object) pairs in the registry.


listBindings

public NamingEnumeration listBindings(String name)
            throws 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.

Parameters:
name - the stringified name of the context to list; must be "".

Returns:
an enumeration of the (name, object) pairs in the registry.


lookup

public Object lookup(Name name)
            throws 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.

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.


lookup

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

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.


lookupLink

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

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.

See Also:
lookup(Name)


lookupLink

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

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.

See Also:
lookup(String)


rebind

public void rebind(Name name,
                   Object obj)
            throws 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. javax.naming.Reference, or javax.naming.Referenceable.

Parameters:
name - the (non-empty) name to rebind;
obj - the object to bind which must be either java.rmi.Remote,


rebind

public void rebind(String name,
                   Object obj)
            throws 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. javax.naming.Reference, or javax.naming.Referenceable.

Parameters:
name - the (non-empty) stringified name to rebind;
obj - the object to bind which must be either java.rmi.Remote,


removeFromEnvironment

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

Parameters:
propName - the name of the property;

Returns:
the previous value of the property, possibly null.


rename

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

Parameters:


rename

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

Parameters:


unbind

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

Parameters:
name - the name to unbind.


unbind

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

Parameters:
name - the name to unbind.