org.gxos
Class ContextManager

java.lang.Object
  |
  +--org.gxos.ContextManager
All Implemented Interfaces:
Database

public class ContextManager
extends java.lang.Object
implements Database

Provides all the functionality needed for context management for GXOS such as initialization, root context creation, etc.

$Id: ContextManager.java,v 1.20 2001/10/19 03:23:48 balsoy Exp $


Constructor Summary
ContextManager()
           
 
Method Summary
 XMLObject constructRootContext(java.lang.String rootName)
          This function returns the root context, i.e.
 GxContext getContext()
          Returns the initial context for the context manager.
 XMLObject getRootContext(java.lang.String rootName)
          This function returns the root context, i.e.
 XMLObject getXMLObject(java.lang.String databaseName)
          Retrieves the root XML object for the given name.
 void initialize()
          Initializes the database with current environment variables and default configuration values.
 void initialize(java.util.Hashtable env)
          Initializes the context manages with the given environment settings.
 boolean isInitialized()
          Checks if context manager is initialized previously.
 void setContext(GxContext ctx)
          Sets initial context for the context manager.
 void setUpload(boolean load)
          Sets the flag for uploading all the GXOS objects at once.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextManager

public ContextManager()
Method Detail

getContext

public GxContext getContext()
Returns the initial context for the context manager.
Returns:
the initial context for the context manager.

setContext

public void setContext(GxContext ctx)
Sets initial context for the context manager. This holds "//" context.
Parameters:
ctx - Initial GXOS context.

setUpload

public void setUpload(boolean load)
Sets the flag for uploading all the GXOS objects at once.
Parameters:
load - set to true if objects are required to upload to the memory at once; false otherwise.

constructRootContext

public XMLObject constructRootContext(java.lang.String rootName)
                               throws javax.naming.NamingException

This function returns the root context, i.e. //GlobalRoot, //Education. If it does not exist, it creates a new one as well as other predefined subcontexts such as Admin, Documents, Events, etc.

Parameters:
rootName - Name for the root, i.e. Education, //University, //Education/University/CSDepartment
Returns:
a root context. If it does not exist, a new root context is created.
Throws:
NameAlreadyBoundException - if the name is bound to another object other than a root context.
javax.naming.NamingException - if a root context cannot be created or any other naming error is encountered.

getRootContext

public XMLObject getRootContext(java.lang.String rootName)
                         throws javax.naming.NamingException
This function returns the root context, i.e. //GlobalRoot, //Education.
Parameters:
rootName - Name for the root, i.e. Education, //University, //Education/University/CSDepartment
Returns:
Context for the root object.
Throws:
javax.naming.InvalidNameException - if given root name is empty or null.
NameNotFoundException - if the root context does not exist
javax.naming.NamingException - if any other naming error is encountered.

isInitialized

public boolean isInitialized()
Checks if context manager is initialized previously.
Specified by:
isInitialized in interface Database
Returns:
true if initialized correctly; false otherwise.
See Also:
initialize()

initialize

public void initialize()
                throws XMLException
Initializes the database with current environment variables and default configuration values. Configuration file is attemted to be found in the CLASSPATH.

Specified by:
initialize in interface Database
Throws:
XMLException - if the database is already initialized.

initialize

public void initialize(java.util.Hashtable env)
                throws XMLException
Initializes the context manages with the given environment settings.
Specified by:
initialize in interface Database
Parameters:
env - Current environment settings. It should include at least "java.naming.factory.initial".
Throws:
XMLException - if a naming error is encountered.

getXMLObject

public XMLObject getXMLObject(java.lang.String databaseName)
                       throws XMLException
Retrieves the root XML object for the given name. If there is no database under the given name, then a new database is constructed.

Specified by:
getXMLObject in interface Database
Parameters:
databaseName - name of the database to be retrieved or constructed.
Returns:
root XML object of this database.
Throws:
XMLException - if an error is encountered.