org.gxos.gndi.context
Class GxContext

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

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

GNDI provider and XMLObject implementer class.

$Id: GxContext.java,v 1.45 2001/10/09 18:58:26 balsoy Exp $


Field Summary
static java.lang.String CURRENT
          Name for the current context which is equal to "." or ""
static java.lang.String NULL
          Name defining null objects.
static java.lang.String SELF
          Name defining collection objects themselves like this, self, etc.
protected static javax.naming.Name SELF_NAME
           
static java.lang.String UNDEFINED
          Name defining undefined objects.
 
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
 void addNamespace(java.lang.String name, java.lang.String uri)
          Registers a namespace with a given URI into this context.
 void addObject(XMLObject object)
          Adds an XML object as a child XML object into this XML object.
 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.
protected  void bind(javax.naming.Name name, java.lang.Object object, boolean rebind)
          Binds an object with a given name, or rebinds a new or altered object with the same name.
 void bind(java.lang.String name, java.lang.Object obj)
          Binds an object with a given name.
protected  void bindMemory(java.lang.String name, java.lang.Object object)
           
 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 constructRootContext(java.lang.String name)
           
protected  javax.naming.Context createContext(java.lang.String name)
          Returns a new GNDI context with a given name.
 javax.naming.Context createSubcontext(javax.naming.Name name)
          Constructs a new sub context with a given name.
 javax.naming.Context createSubcontext(javax.naming.Name name, TreeObject gxchild)
          Constructs a new sub context with a given name and a GXOS collection object.
 javax.naming.Context createSubcontext(java.lang.String name)
          Constructs a new sub context with a given name.
 javax.naming.Context createSubcontext(java.lang.String name, TreeObject gxchild)
          Constructs a new sub context with a given name and a GXOS collection object.
 javax.naming.Context createSubcontext(TreeObject gxchild)
          Constructs a new sub context with a given GXOS collection object.
 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.
 void destroySubcontextAll(java.lang.String name)
          Destroys a sub context under this context.
 void destroySubcontextPhysically(javax.naming.Name name, boolean recursive)
          Destroys a sub context under this context.
 void destroySubcontextPhysically(java.lang.String name)
          Destroys a sub context under this context.
 java.util.Enumeration enumerateChildren()
          Returns an enumeration of child objects.
 XMLObject getChild(java.lang.String name)
          Returns the child object whose name is as given.
 java.lang.String[] getChildren()
          Returns a list of child XML objects' names.
 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.
 TreeObject getGxosObject()
          Returns the GXOS object for this context.
 java.lang.String getName()
          Returns the name of this XML object.
 java.lang.String getNameInNamespace()
          Retrieves the full GXOS name of this context within its GXOS namespace.
 java.lang.String getNameInNamespace(GxContext namespace)
          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)
           
 GxContext getNamespace(java.lang.String nsname)
          Returns the context object named as a namespace at this level.
 java.lang.Object getObject()
          Returns the unmarshalled GXOS object for this context using the associated XML file handle.
protected  java.lang.Object getObject(java.io.File file)
          Returns a memory object from a given XML file.
 java.lang.String getParameter(java.lang.String key)
          Returns the parameter value associated with this attribute value.
 java.util.Hashtable getParameters()
          Returns the hashtable which is a mapping to NodeProfile/TreeContext element in TreeObject.
protected  GxContext getParent()
          Returns the parenting context of this context.
 XMLObject getParentXMLObject()
          Returns the parent of this XML object.
protected  javax.naming.Name getPrefix(javax.naming.Name name)
           
 java.lang.String getURI()
          Returns the URI of this XML object.
 java.lang.String getXML()
          Returns contents of this XML object as an XML document.
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.
 void link(java.lang.String linkName, java.lang.Object linkedObject, GxContext parentCtx, boolean validate)
          Establishes a link from a context to an object under another context.
 void link(java.lang.String linkName, java.lang.String linkedObject, java.lang.String namespace)
          Establishes a link from a context to an object under another context.
 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(InternalND name)
          Returns the object corresponding to the given name.
 java.lang.Object lookup(LinkNode link)
          Returns the object linked with the given link object.
 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.
 void lookupAll()
          Brings all the GXOS objects in this context into the memory.
 java.lang.Object lookupLink(LinkNode link)
          Returns an object using a link.
 java.lang.Object lookupLink(javax.naming.Name name)
           
 java.lang.Object lookupLink(java.lang.String name)
          Returns an object using a link.
 void rebind()
           
 void rebind(javax.naming.Name name, java.lang.Object obj)
           
 void rebind(java.lang.String name, java.lang.Object obj)
           
 void relink(java.lang.String linkName, java.lang.String linkedObject, java.lang.String namespace)
          Resets a link from a context to an object under another context.
 java.lang.Object removeFromEnvironment(java.lang.String propName)
          Removes an environment property from the environment of this context.
 void removeNamespace(java.lang.String nsname)
          Removes a namespace from this context.
 void removeObject(java.lang.String name)
          Removes an XML object from children list of this XML object.
 void rename(javax.naming.Name oldname, javax.naming.Name newname)
           
 void rename(java.lang.String oldname, java.lang.String newname)
           
protected  void renameOld(javax.naming.Name oldname, javax.naming.Name newname)
           
 void report(TreeObject t)
           
protected  void setEnvironment(java.util.Hashtable newEnv)
          Sets the environment in effect for this context.
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.
 void setParameter(java.lang.String key, java.lang.String value)
          Returns the parameter value associated with this attribute value.
protected  java.lang.String translateName(java.lang.String gxosURI)
          Translates a GXOS name to sub JNDI name, i.e.
 void unbind(javax.naming.Name name)
           
 void unbind(java.lang.String name)
           
protected  void unbindMemory(java.lang.String name)
           
protected  void unbindObject(java.lang.String name)
           
 void updateObject()
          Writes any changes of XML object back to the database.
 void updateObject(XMLObject object)
          Replaces an XML object with a new one or updated one.
 
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 like this, self, etc.

SELF_NAME

protected static javax.naming.Name SELF_NAME

CURRENT

public static java.lang.String CURRENT
Name for the current context which is equal to "." or ""

UNDEFINED

public static java.lang.String UNDEFINED
Name defining undefined objects. If this name is looked up then NameNotFoundException is thrown. This is NOT a GXOS object.

NULL

public static java.lang.String NULL
Name defining null objects. If this name is looked up then nil object for the implementation language is returned. This is NOT a GXOS object.
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:
CannotProceedException - if object construction fails.
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
Returns a new GNDI context with a given name. New context duplicates environment variable of this context. This method is used internally by createSubcontext(Name,TreeObject) method.
Parameters:
name - name for the new GNDI context.
Returns:
a new GNDI context with a given name.
Throws:
javax.naming.NamingException - if a naming error is encountered.
See Also:
createSubcontext(Name,TreeObject)

constructRootContext

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

translateName

protected java.lang.String translateName(java.lang.String gxosURI)
                                  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
Constructs a new sub context with a given name. The name cannot be empty or null. This method is one of the standard methods in JNDI API.

In GNDI, there is another method defined, which replaces the standard methods: createSubcontext(Name,TreeObject) This method, as its second parameter, takes a GXOS collection object which the new sub context will be created from. However, the standard methods, createSubcontext(Name) and createSubcontext(String), call the GNDI method with a null parameter. This signals the GNDI method to create an empty collection object and use it as its sub context.

Specified by:
createSubcontext in interface javax.naming.Context
Parameters:
name - name for the sub context.
Returns:
a new GNDI context whose parent context is this context.
Throws:
javax.naming.NamingException - if a naming error is encountered.
See Also:
createSubcontext(Name,TreeObject), createSubcontext(String,TreeObject), createSubcontext(String), createSubcontext(TreeObject)

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name)
                                      throws javax.naming.NamingException
Constructs a new sub context with a given name. The name cannot be empty or null. This method is one of the methods in JNDI standard API.

See createSubcontext(Name) for more information.

Specified by:
createSubcontext in interface javax.naming.Context
Parameters:
name - name for the sub context.
Returns:
a new GNDI context whose parent context is this context.
Throws:
javax.naming.NamingException - if a naming error is encountered.
See Also:
createSubcontext(Name,TreeObject), createSubcontext(String,TreeObject), createSubcontext(Name), createSubcontext(TreeObject)

createSubcontext

public javax.naming.Context createSubcontext(TreeObject gxchild)
                                      throws javax.naming.NamingException
Constructs a new sub context with a given GXOS collection object. The object cannot be null.

This method uses the object's NodeName as its GNDI name and calls createSubcontext(Name,TreeObject).

See createSubcontext(Name,TreeObject) for more information.

Parameters:
gxchild - a GXOS collection object the new sub context will be constructed from.
Returns:
a new GNDI context whose parent context is this context.
Throws:
CannotProceedException - if given GXOS object is null
javax.naming.NamingException - if a naming error is encountered.
See Also:
createSubcontext(Name,TreeObject), createSubcontext(String,TreeObject), createSubcontext(String), createSubcontext(Name)

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name,
                                             TreeObject gxchild)
                                      throws javax.naming.NamingException
Constructs a new sub context with a given name and a GXOS collection object. The name cannot be empty or null.

This method calls createSubcontext(Name,TreeObject) after constructing a Name object from its first parameter name.

Parameters:
name - name for the sub context.
gxchild - a GXOS collection object the new sub context will be constructed from.
Returns:
a new GNDI context whose parent context is this context.
Throws:
javax.naming.NamingException - if a naming error is encountered.
See Also:
createSubcontext(Name,TreeObject), createSubcontext(Name), createSubcontext(String), createSubcontext(TreeObject)

createSubcontext

public javax.naming.Context createSubcontext(javax.naming.Name name,
                                             TreeObject gxchild)
                                      throws javax.naming.NamingException
Constructs a new sub context with a given name and a GXOS collection object. The name cannot be empty or null.

More information coming soon.

Parameters:
name - name for the sub context.
gxchild - a GXOS collection object the new sub context will be constructed from.
Returns:
a new GNDI context whose parent context is this context.
Throws:
javax.naming.InvalidNameException - if name parameter is either null or empty.
NameAlreadyBoundException - if a context with the same name already exists.
CannotProceedException - if sub context construction fails.
javax.naming.NamingException - if any other naming error is encountered.
See Also:
createSubcontext(String,TreeObject), createSubcontext(TreeObject), createSubcontext(Name), createSubcontext(String)

getGxosObject

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

getObject

protected java.lang.Object getObject(java.io.File file)
Returns a memory object from a given XML file. The root element in the XML document must be one of the classes preregistered in GxObjectFactory class. Otherwise, unmarshalling cannot be performed.
Parameters:
file - file handle for the XML document
Returns:
a memory object unmarshaled from an XML document in the file system; null if not found.

getObject

public java.lang.Object getObject()
Returns the unmarshalled GXOS object for this context using the associated XML file handle. This is usually handle to the file "context/self.xml".
Returns:
container object for this context; null if not found.
See Also:
getObject(File)

addNamespace

public void addNamespace(java.lang.String name,
                         java.lang.String uri)
                  throws javax.naming.NamingException
Registers a namespace with a given URI into this context. This new can be accessed by subcontexts.
Parameters:
name - name of the namespace
uri - GXOS name of the context the above name is assigned.
Throws:
javax.naming.InvalidNameException - if namespace name is null or empty.
javax.naming.NamingException - if a naming error is encountered.

getNamespace

public GxContext getNamespace(java.lang.String nsname)
                       throws javax.naming.NamingException
Returns the context object named as a namespace at this level. If the name is not registered at this level, the parent contexts will be searched up until the top root node. Named contexts can be anywhere within object tree. Credentials of accessor will be checked.
Parameters:
nsname - namespace name which is given as in nsname:object_name. If nsname is empty string, this context is returned.
Returns:
context associated with the given namespace name.
Throws:
NameNotFoundException - if namespace does not exist.
OperationNotSupportedException - if namespace does not refer to a context.
javax.naming.InvalidNameException - if namespace name is given as null.
javax.naming.NamingException - if any other error is encountered. Since lookup(Name) method is used in this method, also see the exceptions it throws.

removeNamespace

public void removeNamespace(java.lang.String nsname)
                     throws javax.naming.NamingException
Removes a namespace from this context. If the namespace is not found, search does not continue for the parent nodes. Removals can break object links. Extreme caution should be given these operations.
Parameters:
nsname - name of the namespace which will be removed from this context.
Throws:
NameNotFoundException - if namespace does not exist.
javax.naming.InvalidNameException - if namespace name is given as null or empty.
javax.naming.NamingException - if any other error is encountered.

getParent

protected GxContext getParent()
Returns the parenting context of this context.
Returns:
parent context of this context.

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.InvalidNameException - if the given name is null.
CannotProceedException - if context retrieval fails.
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)

lookup

public java.lang.Object lookup(InternalND name)
                        throws javax.naming.NamingException
Returns the object corresponding to the given name. The name is of type InternalND.
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)

lookup

public java.lang.Object lookup(LinkNode link)
                        throws javax.naming.NamingException
Returns the object linked with the given link object. See lookup(Name) for details.
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)

lookupAll

public void lookupAll()
               throws javax.naming.NamingException
Brings all the GXOS objects in this context into the memory.
Throws:
javax.naming.NamingException - if any error is encountered.

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(Name,Object,boolean) for more information.
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 empty string, or does not match with object's NodeName field.
OperationNotSupported - if the object is not a descendent of TreeObject, or it is a collection object. In such cases, createSubcontext must be used.
NameAlreadyBoundException - if the name is already bound to another object.
javax.naming.NamingException - if there is any other problem.
See Also:
bind(Name,Object), bind(Name,Object,boolean), 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. See bind(Name,Object,boolean) for more information.
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 empty string, or does not match with object's NodeName field.
OperationNotSupported - if the object is not a descendent of TreeObject, or it is a collection object. In such cases, createSubcontext must be used.
NameAlreadyBoundException - if the name is already bound to another object.
javax.naming.NamingException - if there is any other problem.
See Also:
bind(String,Object), bind(Name,Object,boolean), TreeObject

bind

protected void bind(javax.naming.Name name,
                    java.lang.Object object,
                    boolean rebind)
             throws javax.naming.NamingException
Binds an object with a given name, or rebinds a new or altered object with the same name. The name is of type javax.naming.Name.
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.
rebind - Four possibilities exist:
  • false and object does not exist: object is bound with the name.
  • false and object exists: NameAlreadyBoundException is thrown.
  • true and object does not exist: NameNotFoundException is thrown.
  • true and object exists: object bound to this name is replaced with the new one
Throws:
javax.naming.InvalidNameException - if the given name is null empty string, or does not match with object's NodeName field.
OperationNotSupportedException - if the object is not a descendent of TreeObject, or it is a collection object. In such cases, createSubcontext must be used.
NameAlreadyBoundException - if the name is already bound to another object.
javax.naming.NamingException - if there is any other problem.
See Also:
bind(String,Object), bind(Name,Object), TreeObject

rebind

public void rebind()
            throws javax.naming.NamingException

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

unbindObject

protected void unbindObject(java.lang.String 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

renameOld

protected void renameOld(javax.naming.Name oldname,
                         javax.naming.Name newname)
                  throws javax.naming.NamingException

bindMemory

protected void bindMemory(java.lang.String name,
                          java.lang.Object object)
                   throws javax.naming.NamingException

unbindMemory

protected void unbindMemory(java.lang.String name)
                     throws javax.naming.NamingException

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.

destroySubcontextAll

public void destroySubcontextAll(java.lang.String 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.
Parameters:
name - name of the subcontext to be destroyed.
Throws:
CannotProceedException - if the sub context is not empty.
javax.naming.NamingException - if this context is not empty, or another naming error is encountered.
See Also:
destroySubcontext(String)

destroySubcontextPhysically

public void destroySubcontextPhysically(java.lang.String 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.
Parameters:
name - name of the subcontext to be destroyed.
Throws:
CannotProceedException - if the sub context is not empty.
javax.naming.NamingException - if this context is not empty, or another naming error is encountered.
See Also:
destroySubcontextPhysically(Name,boolean), destroySubcontext(String)

destroySubcontextPhysically

public void destroySubcontextPhysically(javax.naming.Name name,
                                        boolean recursive)
                                 throws javax.naming.NamingException
Destroys a sub context under this context. If the sub context is not empty, then this methods throws an exception.
Parameters:
name - name of the subcontext to be destroyed.
recursive - a boolean value which forces to destroy sub objects to be deleted recursively.
Throws:
CannotProceedException - if the sub context is not empty.
javax.naming.NamingException - if this context is not empty, or another naming error is encountered.
See Also:
destroySubcontext(String)

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:
OperationNotSupportedException - if name is not bound to a context.
NameNotFoundException - if name is not found.
javax.naming.NamingException - if a naming error is encountered.
See Also:
destroySubcontext(String)

link

public void link(java.lang.String linkName,
                 java.lang.Object linkedObject,
                 GxContext parentCtx,
                 boolean validate)
          throws javax.naming.NamingException
Establishes a link from a context to an object under another context. Destination object must exist for the process to complete.
Parameters:
linkName - name of the link to be established with this call
linkedObject - object under another context
parentCtx - parent context of the destination object
validate - true if validation of the object and parent is requested; false otherwise. Validation is more costly.
Throws:
javax.naming.InvalidNameException - if the link name is given as empty or null
OperationNotSupportedException - if the linked object is null
NameNotFoundException - if object to be linked does not exist
NameAlreadyBoundException - if link already exists
javax.naming.NamingException - if an naming error is encountered.

link

public void link(java.lang.String linkName,
                 java.lang.String linkedObject,
                 java.lang.String namespace)
          throws javax.naming.NamingException
Establishes a link from a context to an object under another context. Destination object must exist for the process to complete.
Parameters:
linkName - name of the link to be established with this call
linkedObject - object under another context
parentCtx - parent context of the destination object
Throws:
javax.naming.InvalidNameException - if the link name is given as empty or null
OperationNotSupportedException - if the linked object is null
NameNotFoundException - if object to be linked does not exist
NameAlreadyBoundException - if link already exists
javax.naming.NamingException - if an naming error is encountered.

relink

public void relink(java.lang.String linkName,
                   java.lang.String linkedObject,
                   java.lang.String namespace)
            throws javax.naming.NamingException
Resets a link from a context to an object under another context. Destination object must exist for the process to complete.
Parameters:
linkName - name of the link to be established with this call
linkedObject - object under another context
parentCtx - parent context of the destination object
Throws:
javax.naming.InvalidNameException - if the link name is given as empty or null
OperationNotSupportedException - if the linked object name is null
NameNotFoundException - if object to be linked does not exist
LinkException - if name refers to a non-link object.
javax.naming.NamingException - if an naming error is encountered.

lookupLink

public java.lang.Object lookupLink(LinkNode link)
                            throws javax.naming.NamingException
Returns an object using a link. If the object with a given name is not a link but a valid GXOS object, then the object is returned. If a link is linked to another link, then lookup continues until a non-link object is found.
Parameters:
link - link to an GXOS object.
Returns:
object which is bound to the name
Throws:
javax.naming.InvalidNameException - if the link name is given as empty or null
OperationNotSupportedException - if the linked object is null
javax.naming.NamingException - if an naming error is encountered. This method uses lookup(String) method. Please see this method for further exceptions.
See Also:
lookup(String), lookupLink(Name)

lookupLink

public java.lang.Object lookupLink(java.lang.String name)
                            throws javax.naming.NamingException
Returns an object using a link. If the object with a given name is not a link but a valid GXOS object, then the object is returned. If a link is linked to another link, then lookup continues until a non-link object is found.
Specified by:
lookupLink in interface javax.naming.Context
Parameters:
name - name of a link to retrieve an object
Throws:
javax.naming.InvalidNameException - if the link name is given as empty or null
OperationNotSupportedException - if the linked object is null
javax.naming.NamingException - if an naming error is encountered. This method uses lookup(String) method. Please see this method for further exceptions.
See Also:
lookup(String)

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)

setEnvironment

protected void setEnvironment(java.util.Hashtable newEnv)
                       throws javax.naming.NamingException
Sets the environment in effect for this context.

Parameters:
the - new environment of this context
Throws:
javax.naming.NamingException - if a naming exception is encountered
See Also:
getEnvironment(), 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()

getName

public java.lang.String getName()
                         throws XMLException
Returns the name of this XML object. This is relative to its parent.

Specified by:
getName in interface XMLObject
Returns:
name of this XML object.
Throws:
XMLException - if an error is encountered.
See Also:
getGxosName(), 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()

getNameInNamespace

public java.lang.String getNameInNamespace(GxContext namespace)
                                    throws javax.naming.NamingException
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 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)

getParameters

public java.util.Hashtable getParameters()
Returns the hashtable which is a mapping to NodeProfile/TreeContext element in TreeObject. The format of TreeContext is as follows:
 <TreeContext>
    <parametervalue name="key1">value1</parametervalue>
    <parametervalue name="key2">value2</parametervalue>
    ...
 <TreeContext>

This structure is represented by a hashmap, the name attribute being the key, and values are the parametervalue objects holding the key/value pairs. This is to allow users to alter the content of parameter values so that when content is commited, the alterations should be reflected in XML.

Example:

 Parametervalue pv = context.getParameters().get("key");
 if(pv != null && pv.getContent().equals("somevalue"))
      pv.setContent("new content");
 

getParameter

public java.lang.String getParameter(java.lang.String key)
                              throws XMLException
Description copied from interface: XMLObject
Returns the parameter value associated with this attribute value. If not found, search continues for ancestor contexts until the root node is reached.
Specified by:
getParameter in interface XMLObject
Following copied from interface: org.gxos.xml.XMLObject
Parameters:
key - key to retrieve a parameter value
Returns:
parameter value; null if key not found.
See Also:
XMLObject.setParameter(java.lang.String, java.lang.String)

setParameter

public void setParameter(java.lang.String key,
                         java.lang.String value)
                  throws XMLException
Returns the parameter value associated with this attribute value. If not found, search continues for ancestor contexts until the root node is reached.
Specified by:
setParameter in interface XMLObject
Parameters:
key - key that the value will be associated.
value - value to retrive with the given key.
Throws:
XMLException - if an error is encountered.
See Also:
getParameter(java.lang.String)

getURI

public java.lang.String getURI()
                        throws XMLException
Returns the URI of this XML object. This is the absolute name of this object.

Specified by:
getURI in interface XMLObject
Returns:
URI of this XML object.
Throws:
XMLException - if an error is encountered.

getParentXMLObject

public XMLObject getParentXMLObject()
                             throws XMLException
Returns the parent of this XML object.

Specified by:
getParentXMLObject in interface XMLObject
Returns:
parent of this XML object.
Throws:
XMLException - if an error is encountered.

getChild

public XMLObject getChild(java.lang.String name)
                   throws XMLException
Returns the child object whose name is as given. Name is relative to this XML object. Immediate children are refered by their names. Children objects at deeper levels are refered by their paths including their ancestors. As an example, if this is the hierarchy:
    this object
    . child_1
        . grandchild_1
    . child_2
        . grandchild_2
        . grandchild_3
 
then object retrieval can be this.getChild("child_1") or this.getChild("child_2/grandchild_3") and so on.

Specified by:
getChild in interface XMLObject
Parameters:
name - name of the XML object
Returns:
child XML object
Throws:
XMLException - if an error is encountered.

addObject

public void addObject(XMLObject object)
               throws XMLException
Description copied from interface: XMLObject
Adds an XML object as a child XML object into this XML object.

Specified by:
addObject in interface XMLObject
Following copied from interface: org.gxos.xml.XMLObject
Parameters:
object - any XML object.
Throws:
XMLException - if an error is encountered.

updateObject

public void updateObject()
                  throws XMLException
Writes any changes of XML object back to the database.

Specified by:
updateObject in interface XMLObject
Throws:
XMLException - if an error is encountered.
See Also:
updateObject(XMLObject)

updateObject

public void updateObject(XMLObject object)
                  throws XMLException
Replaces an XML object with a new one or updated one. New object's name must be the same as the old one.

Specified by:
updateObject in interface XMLObject
Parameters:
object - any XML object.
Throws:
XMLException - if an error is encountered.
See Also:
updateObject()

removeObject

public void removeObject(java.lang.String name)
                  throws XMLException
Removes an XML object from children list of this XML object. Name is relative to this object. See getChild(String) for name usage.

Specified by:
removeObject in interface XMLObject
Parameters:
name - name of the child object to be removed.
Throws:
XMLException - if an error is encountered.

getXML

public java.lang.String getXML()
                        throws XMLException
Returns contents of this XML object as an XML document.

Specified by:
getXML in interface XMLObject
Returns:
XML content as Java String object.
Throws:
XMLException - if an error is encountered.

getChildren

public java.lang.String[] getChildren()
                               throws XMLException
Returns a list of child XML objects' names.

Specified by:
getChildren in interface XMLObject
Returns:
an array of XML object names; null if there is no child.
Throws:
XMLException - if an error is encountered.

enumerateChildren

public java.util.Enumeration enumerateChildren()
                                        throws XMLException
Returns an enumeration of child objects. Each object has to be casted to XMLObject.

Specified by:
enumerateChildren in interface XMLObject
Returns:
enumeration of child XML objects
Throws:
XMLException - if an error is encountered.