org.gxos.gndi.context
Class GxContext

java.lang.Object
  |
  +--org.gxos.gndi.context.GxContext
All Implemented Interfaces:
javax.naming.Context
Direct Known Subclasses:
RootContext

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

GNDI provider class.

$Id: GxContext.java,v 1.19 2001/05/02 17:58:08 balsoy Exp $


Field Summary
static java.lang.String SELF
          Name defining collection objects themselves i.e.
 
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
GxContext(java.util.Hashtable environment)
          GNDI context constructor.
GxContext(java.lang.String name, javax.naming.Context ctx, java.util.Hashtable environment)
          GNDI context constructor.
 
Method Summary
 java.lang.Object addToEnvironment(java.lang.String propName, java.lang.Object propVal)
          Adds a new environment property to the environment of this context.
 void bind(javax.naming.Name name, java.lang.Object obj)
          Binds an object with a given name.
 void bind(java.lang.String name, java.lang.Object obj)
          Binds an object with a given name.
 void close()
          Closes this context.
 javax.naming.Name composeName(javax.naming.Name name, javax.naming.Name prefix)
           
 java.lang.String composeName(java.lang.String name, java.lang.String prefix)
           
protected  javax.naming.Context createContext(java.lang.String name)
           
 javax.naming.Context createSubcontext(javax.naming.Name name)
           
 javax.naming.Context createSubcontext(javax.naming.Name name, TreeObject gxchild)
           
 javax.naming.Context createSubcontext(java.lang.String name)
           
 javax.naming.Context createSubcontext(java.lang.String name, TreeObject gxchild)
           
 javax.naming.Context createSubcontext(TreeObject gxchild)
           
 void destroySubcontext(javax.naming.Name name)
          Destroys a sub context under this context.
 void destroySubcontext(java.lang.String name)
          Destroys a sub context under this context.
 java.util.Hashtable getEnvironment()
          Retrieves the environment in effect for this context.
protected  javax.naming.Context getFSContext()
          Returns the pointer to the sub JNDI provider this context uses.
 javax.naming.Name getGxosName()
          Retrieves the full GXOS name of this context within its GXOS namespace.
protected  TreeObject getGxosObject()
          Returns the GXOS object for this context.
 java.lang.String getNameInNamespace()
          Retrieves the full GXOS name of this context within its GXOS namespace.
 javax.naming.NameParser getNameParser(javax.naming.Name name)
           
 javax.naming.NameParser getNameParser(java.lang.String name)
           
 java.lang.Object getObject()
           
protected  java.lang.Object getObject(java.io.File x)
           
protected  javax.naming.Name getPrefix(javax.naming.Name name)
           
protected  java.io.File getXMLFile()
          Returns the file object which holds the XML content of this context.
protected  void init(java.util.Hashtable environment)
          Initializes sub JNDI provider; sets GXOS name to its initial value; creates a hashtable for child objects and contexts.
 javax.naming.NamingEnumeration list(javax.naming.Name name)
           
 javax.naming.NamingEnumeration list(java.lang.String name)
           
 javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
           
 javax.naming.NamingEnumeration listBindings(java.lang.String name)
           
 java.lang.Object lookup(javax.naming.Name name)
          Returns the object corresponding to the given name.
 java.lang.Object lookup(java.lang.String name)
          Returns the object corresponding to the given name.
 java.lang.Object lookupLink(javax.naming.Name name)
           
 java.lang.Object lookupLink(java.lang.String name)
           
 void rebind(javax.naming.Name name, java.lang.Object obj)
           
 void rebind(java.lang.String name, java.lang.Object obj)
           
 java.lang.Object removeFromEnvironment(java.lang.String propName)
          Removes an environment property from the environment of this context.
 void rename(javax.naming.Name oldname, javax.naming.Name newname)
           
 void rename(java.lang.String oldname, java.lang.String newname)
           
 void report(TreeObject t)
           
protected  void setGxosName(javax.naming.Name name)
          Sets this context's GXOS name to a new value.
protected  void setGxosName(java.lang.String name)
          Sets this context's GXOS name to a new value.
protected  java.lang.String translateName(java.lang.String gxosURL)
          Translates a GXOS name to sub JNDI name, i.e.
 void unbind(javax.naming.Name name)
           
 void unbind(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELF

public static java.lang.String SELF
Name defining collection objects themselves i.e. this, self, etc.
Constructor Detail

GxContext

public GxContext(java.util.Hashtable environment)
          throws javax.naming.NamingException
GNDI context constructor. Copies environment variables and initialize other variables.
Parameters:
environment - Environment settings. Could be system properties as well as user defined variables.
Throws:
javax.naming.NamingException - if a naming error is encountered.
See Also:
GxContext(String,Context,Hashtable)

GxContext

public GxContext(java.lang.String name,
                 javax.naming.Context ctx,
                 java.util.Hashtable environment)
          throws javax.naming.NamingException
GNDI context constructor. Copies environment variables and initialize other variables.
Parameters:
name - Name of the context to be created.
ctx - Parent context of this context.
environment - Environment settings. Could be system properties as well as user defined variables.
Throws:
javax.naming.NamingException - if a naming error is encountered.
See Also:
GxContext(Hashtable)
Method Detail

init

protected void init(java.util.Hashtable environment)
             throws javax.naming.NamingException
Initializes sub JNDI provider; sets GXOS name to its initial value; creates a hashtable for child objects and contexts.
Throws:
javax.naming.NamingException - if a naming error is encountered.

createContext

protected javax.naming.Context createContext(java.lang.String name)
                                      throws javax.naming.NamingException

getGxosObject

protected TreeObject getGxosObject()
                            throws javax.naming.NamingException
Returns the GXOS object for this context. Since each container is also a GXOS collection, this methods returns a TreeObject.
Returns:
container object for this context; null if not found.
Throws:
javax.naming.NamingException - if a naming error is encountered.

translateName

protected java.lang.String translateName(java.lang.String gxosURL)
                                  throws javax.naming.NamingException
Translates a GXOS name to sub JNDI name, i.e. //Education to file:///gxosroot/Education.
Parameters:
gxosURL - GXOS name to be converted.
Returns:
converted name for the sub JNDI provider.
Throws:
javax.naming.NamingException - if a naming error is encountered.

getXMLFile

protected java.io.File getXMLFile()
Returns the file object which holds the XML content of this context.
Returns:
a file object of the XML file.

getFSContext

protected javax.naming.Context getFSContext()
Returns the pointer to the sub JNDI provider this context uses.
Returns:
a context object which serves to this context.

setGxosName

protected void setGxosName(java.lang.String name)
                    throws javax.naming.NamingException
Sets this context's GXOS name to a new value. This function gets a String name and calls setGxosName(Name).
Parameters:
name - new name for this context.
Throws:
NamingExpception - if a naming error is encountered.
See Also:
setGxosName(Name)

setGxosName

protected void setGxosName(javax.naming.Name name)
                    throws javax.naming.NamingException
Sets this context's GXOS name to a new value. This function gets a Name-type name.

Name should either start with Defaults.GXOS_ROOT_PREFIX or be a relative name, i.e. name1/name2/name3, etc.

Parameters:
name - new name for this context.
Throws:
NamingExpception - if a naming error is encountered such as empty names.
See Also:
setGxosName(String)

createSubcontext

public javax.naming.Context createSubcontext(javax.naming.Name name)
                                      throws javax.naming.NamingException
Specified by:
createSubcontext in interface javax.naming.Context

createSubcontext

public javax.naming.Context createSubcontext(TreeObject gxchild)
                                      throws javax.naming.NamingException

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name,
                                             TreeObject gxchild)
                                      throws javax.naming.NamingException

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name)
                                      throws javax.naming.NamingException
Specified by:
createSubcontext in interface javax.naming.Context

createSubcontext

public javax.naming.Context createSubcontext(javax.naming.Name name,
                                             TreeObject gxchild)
                                      throws javax.naming.NamingException

getObject

protected java.lang.Object getObject(java.io.File x)

getObject

public java.lang.Object getObject()

lookup

public java.lang.Object lookup(javax.naming.Name name)
                        throws javax.naming.NamingException
Returns the object corresponding to the given name. The name is of type javax.naming.Name.
Specified by:
lookup in interface javax.naming.Context
Parameters:
name - Associated name of the object which is searched for.
Returns:
Returns
  • the current context if name is empty,
  • a subcontext if name is bound to a context,
  • and an object if name is bound to an object.
Throws:
NameNotFoundException - if the given name is not bound to an object or a sub context.
javax.naming.NamingException - if there is any other problem.
See Also:
lookup(String)

lookup

public java.lang.Object lookup(java.lang.String name)
                        throws javax.naming.NamingException
Returns the object corresponding to the given name. The name is of type java.lang.String.
Specified by:
lookup in interface javax.naming.Context
Parameters:
name - Associated name of the object which is searched for.
Returns:
Returns
  • the current context if name is empty,
  • a subcontext if name is bound to a context,
  • and an object if name is bound to an object.
Throws:
NameNotFoundException - if the given name is not bound to an object or a sub context.
javax.naming.NamingException - if there is any other problem.
See Also:
lookup(Name)

bind

public void bind(java.lang.String name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Binds an object with a given name. The name is of type javax.naming.String. See bind(String,Object).
Specified by:
bind in interface javax.naming.Context
Parameters:
name - A binding name to the object to retrieve at a later time.
obj - Object which is to be bound to the given name.
Throws:
javax.naming.InvalidNameException - if the given name is null or empty string.
OperationNotSupported - if the object is not a descendent of TreeObject.
NameAlreadyBoundException - if the name is already bound to another object.
javax.naming.NamingException - if there is any other problem.
See Also:
bind(Name,Object), TreeObject

bind

public void bind(javax.naming.Name name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Binds an object with a given name. The name is of type javax.naming.Name.
Specified by:
bind in interface javax.naming.Context
Parameters:
name - A binding name to the object to retrieve at a later time.
obj - Object which is to be bound to the given name.
Throws:
javax.naming.InvalidNameException - if the given name is null or empty string.
OperationNotSupported - if the object is not a descendent of TreeObject.
NameAlreadyBoundException - if the name is already bound to another object.
javax.naming.NamingException - if there is any other problem.
See Also:
bind(String,Object), TreeObject

rebind

public void rebind(java.lang.String name,
                   java.lang.Object obj)
            throws javax.naming.NamingException
Specified by:
rebind in interface javax.naming.Context

rebind

public void rebind(javax.naming.Name name,
                   java.lang.Object obj)
            throws javax.naming.NamingException
Specified by:
rebind in interface javax.naming.Context

getPrefix

protected javax.naming.Name getPrefix(javax.naming.Name name)
                               throws javax.naming.NamingException

unbind

public void unbind(java.lang.String name)
            throws javax.naming.NamingException
Specified by:
unbind in interface javax.naming.Context

unbind

public void unbind(javax.naming.Name name)
            throws javax.naming.NamingException
Specified by:
unbind in interface javax.naming.Context

rename

public void rename(java.lang.String oldname,
                   java.lang.String newname)
            throws javax.naming.NamingException
Specified by:
rename in interface javax.naming.Context

rename

public void rename(javax.naming.Name oldname,
                   javax.naming.Name newname)
            throws javax.naming.NamingException
Specified by:
rename in interface javax.naming.Context

list

public javax.naming.NamingEnumeration list(java.lang.String name)
                                    throws javax.naming.NamingException
Specified by:
list in interface javax.naming.Context

list

public javax.naming.NamingEnumeration list(javax.naming.Name name)
                                    throws javax.naming.NamingException
Specified by:
list in interface javax.naming.Context

listBindings

public javax.naming.NamingEnumeration listBindings(java.lang.String name)
                                            throws javax.naming.NamingException
Specified by:
listBindings in interface javax.naming.Context

listBindings

public javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
                                            throws javax.naming.NamingException
Specified by:
listBindings in interface javax.naming.Context

destroySubcontext

public void destroySubcontext(java.lang.String name)
                       throws javax.naming.NamingException
Destroys a sub context under this context. See destroySubcontext(Name).
Specified by:
destroySubcontext in interface javax.naming.Context
Parameters:
name - name of the subcontext to be destroyed.
Throws:
javax.naming.NamingException - if a naming error is encountered.

destroySubcontext

public void destroySubcontext(javax.naming.Name name)
                       throws javax.naming.NamingException
Destroys a sub context under this context. If the sub context is not empty, then this methods throws an exception.
Specified by:
destroySubcontext in interface javax.naming.Context
Parameters:
name - name of the subcontext to be destroyed.
Throws:
CannotProceedException - if the sub context does not belong to this context.
javax.naming.NamingException - if this context is not empty, or another naming error is encountered.
See Also:
destroySubcontext(String)

lookupLink

public java.lang.Object lookupLink(java.lang.String name)
                            throws javax.naming.NamingException
Specified by:
lookupLink in interface javax.naming.Context

lookupLink

public java.lang.Object lookupLink(javax.naming.Name name)
                            throws javax.naming.NamingException
Specified by:
lookupLink in interface javax.naming.Context

getNameParser

public javax.naming.NameParser getNameParser(java.lang.String name)
                                      throws javax.naming.NamingException
Specified by:
getNameParser in interface javax.naming.Context

getNameParser

public javax.naming.NameParser getNameParser(javax.naming.Name name)
                                      throws javax.naming.NamingException
Specified by:
getNameParser in interface javax.naming.Context

composeName

public java.lang.String composeName(java.lang.String name,
                                    java.lang.String prefix)
                             throws javax.naming.NamingException
Specified by:
composeName in interface javax.naming.Context

composeName

public javax.naming.Name composeName(javax.naming.Name name,
                                     javax.naming.Name prefix)
                              throws javax.naming.NamingException
Specified by:
composeName in interface javax.naming.Context

addToEnvironment

public java.lang.Object addToEnvironment(java.lang.String propName,
                                         java.lang.Object propVal)
                                  throws javax.naming.NamingException
Adds a new environment property to the environment of this context. If the property already exists, its value is overwritten.
Specified by:
addToEnvironment in interface javax.naming.Context
Parameters:
propName - the name of the environment property to add; may not be null
propVal - the value of the property to add; may not be null
Returns:
the previous value of the property, or null if the property was not in the environment before
Throws:
javax.naming.NamingException - if a naming exception is encountered
See Also:
getEnvironment(), removeFromEnvironment(String)

removeFromEnvironment

public java.lang.Object removeFromEnvironment(java.lang.String propName)
                                       throws javax.naming.NamingException
Removes an environment property from the environment of this context.
Specified by:
removeFromEnvironment in interface javax.naming.Context
Parameters:
propName - the name of the environment property to remove; may not be null
Returns:
the previous value of the property, or null if the property was not in the environment
Throws:
javax.naming.NamingException - if a naming exception is encountered
See Also:
getEnvironment(), addToEnvironment(String, Object)

getEnvironment

public java.util.Hashtable getEnvironment()
                                   throws javax.naming.NamingException

Retrieves the environment in effect for this context.

The caller should not make any changes to the object returned: their effect on the context is undefined. The environment of this context may be changed using addToEnvironment() and removeFromEnvironment().

Specified by:
getEnvironment in interface javax.naming.Context
Returns:
the environment of this context; never null
Throws:
javax.naming.NamingException - if a naming exception is encountered
See Also:
addToEnvironment(String, Object), removeFromEnvironment(String)

getGxosName

public javax.naming.Name getGxosName()
Retrieves the full GXOS name of this context within its GXOS namespace.
Returns:
this context's name in its own namespace; never null. The returned value is of type Name.
See Also:
getNameInNamespace()

getNameInNamespace

public java.lang.String getNameInNamespace()
                                    throws javax.naming.NamingException
Retrieves the full GXOS name of this context within its GXOS namespace.
Specified by:
getNameInNamespace in interface javax.naming.Context
Returns:
this context's name in its own namespace; never null. The returned value is of type String.
Throws:
javax.naming.NamingException - - if a naming exception is encountered.
See Also:
getGxosName()

close

public void close()
           throws javax.naming.NamingException
Closes this context. This method releases this context's resources immediately, instead of waiting for them to be released automatically by the garbage collector.

This method is idempotent: invoking it on a context that has already been closed has no effect. Invoking any other method on a closed context is not allowed, and results in undefined behaviour.

Specified by:
close in interface javax.naming.Context
Throws:
javax.naming.NamingException - if a naming exception is encountered.

report

public void report(TreeObject t)