com.icecool.jndi.dbdir
Class DbDirFolder

java.lang.Object
  |
  +--com.icecool.jndi.dbdir.DbDirFolder
All Implemented Interfaces:
Context, DirContext

public class DbDirFolder
extends Object
implements DirContext

Represents a context in a hierarchical namespace. A DbDirFolder object contains names and subfolders (subcontexts). The DbDir directory consists of a root DbDirFolder and several other DbDirFolder subfolders with DbDir objects each associated with a JNDI name. This provides an implementation for all the JNDI DirContext interface methods.

Version:
0.1

Field Summary
protected  DAO _db
           
protected  Hashtable _myEnv
           
protected  String _myName
           
protected  NameParser _myParser
           
 
Fields inherited from interface javax.naming.directory.DirContext
ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE
 
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
protected DbDirFolder(String folderName, Hashtable inEnv)
          Protected method to construct a DbDirFolder.
protected DbDirFolder(String parent, String name, Hashtable inEnv, Attributes attrs)
          Protected method to construct a DbDirFolder.
 
Method Summary
 Object addToEnvironment(String propName, Object propVal)
           
 void bind(Name name, Object obj)
           
 void bind(Name name, Object obj, Attributes attrs)
          NOTE: Simplified implementation: add attributes and object nonatomically Does not accept null obj (throws NullPointerException)
 void bind(String name, Object obj)
           
 void bind(String name, Object obj, Attributes attrs)
           
protected  DirContext cloneCtx()
           
 void close()
           
 Name composeName(Name name, Name prefix)
           
 String composeName(String name, String prefix)
           
protected  DirContext createCtx(String parent, String name, Hashtable inEnv)
           
 Context createSubcontext(Name name)
           
 DirContext createSubcontext(Name name, Attributes attrs)
           
 Context createSubcontext(String name)
           
 DirContext createSubcontext(String name, Attributes attrs)
           
 void destroySubcontext(Name name)
           
 void destroySubcontext(String name)
           
 Attributes getAttributes(Name name)
           
 Attributes getAttributes(Name name, String[] attrIds)
           
 Attributes getAttributes(String name)
           
 Attributes getAttributes(String name, String[] attrIds)
           
 Hashtable getEnvironment()
           
protected  Name getMyComponents(Name name)
          Utility method for processing composite/compound name.
 String getNameInNamespace()
           
 NameParser getNameParser(Name name)
           
 NameParser getNameParser(String name)
           
 DirContext getSchema(Name name)
           
 DirContext getSchema(String name)
           
 DirContext getSchemaClassDefinition(Name name)
           
 DirContext getSchemaClassDefinition(String name)
           
 NamingEnumeration list(Name name)
           
 NamingEnumeration list(String name)
           
 NamingEnumeration listBindings(Name name)
           
 NamingEnumeration listBindings(String name)
           
 Object lookup(Name name)
           
 Object lookup(String name)
           
 Object lookupLink(Name name)
           
 Object lookupLink(String name)
           
static void main(String[] args)
           
 void modifyAttributes(Name name, int mod_op, Attributes attrs)
           
 void modifyAttributes(Name name, ModificationItem[] mods)
           
 void modifyAttributes(String name, int mod_op, Attributes attrs)
           
 void modifyAttributes(String name, ModificationItem[] mods)
           
 void rebind(Name name, Object obj)
           
 void rebind(Name name, Object o, Attributes attrs)
           
 void rebind(String name, Object obj)
           
 void rebind(String name, Object obj, Attributes attrs)
           
 Object removeFromEnvironment(String propName)
           
 void rename(Name oldname, Name newname)
           
 void rename(String oldname, String newname)
           
 NamingEnumeration search(Name name, Attributes matchingAttrs)
           
 NamingEnumeration search(Name name, Attributes matchingAttrs, String[] attrsRet)
           
 NamingEnumeration search(Name name, String filterExpr, Object[] filterArgs, SearchControls cons)
           
 NamingEnumeration search(Name name, String filter, SearchControls cons)
           
 NamingEnumeration search(String name, Attributes matchingAttrs)
           
 NamingEnumeration search(String name, Attributes matchingAttrs, String[] attrsRet)
           
 NamingEnumeration search(String name, String filterExpr, Object[] filterArgs, SearchControls cons)
           
 NamingEnumeration search(String name, String filter, SearchControls cons)
           
 String toString()
           
 void unbind(Name name)
           
 void unbind(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_myEnv

protected Hashtable _myEnv

_myParser

protected final NameParser _myParser

_myName

protected String _myName

_db

protected DAO _db
Constructor Detail

DbDirFolder

protected DbDirFolder(String folderName,
                      Hashtable inEnv)
Protected method to construct a DbDirFolder.

Parameters:
folderName - Absolute name for the folder. Name components should be separated by forward slashes and the folderName should begin and end with a forward slash.
inEnv - Hashtable of JNDI properties.

DbDirFolder

protected DbDirFolder(String parent,
                      String name,
                      Hashtable inEnv,
                      Attributes attrs)
Protected method to construct a DbDirFolder.

Parameters:
parent - Absolute name of the parent folder.
name - Name of the folder relative to parent.
inEnv - Hashtable of JNDI properties.
attrs - JNDI Attributes object.
Method Detail

createCtx

protected DirContext createCtx(String parent,
                               String name,
                               Hashtable inEnv)

cloneCtx

protected DirContext cloneCtx()

getAttributes

public Attributes getAttributes(String name)
                         throws NamingException
Specified by:
getAttributes in interface DirContext
NamingException

getAttributes

public Attributes getAttributes(Name name)
                         throws NamingException
Specified by:
getAttributes in interface DirContext
NamingException

getAttributes

public Attributes getAttributes(String name,
                                String[] attrIds)
                         throws NamingException
Specified by:
getAttributes in interface DirContext
NamingException

getAttributes

public Attributes getAttributes(Name name,
                                String[] attrIds)
                         throws NamingException
Specified by:
getAttributes in interface DirContext
NamingException

modifyAttributes

public void modifyAttributes(String name,
                             int mod_op,
                             Attributes attrs)
                      throws NamingException
Specified by:
modifyAttributes in interface DirContext
NamingException

modifyAttributes

public void modifyAttributes(Name name,
                             int mod_op,
                             Attributes attrs)
                      throws NamingException
Specified by:
modifyAttributes in interface DirContext
NamingException

modifyAttributes

public void modifyAttributes(String name,
                             ModificationItem[] mods)
                      throws NamingException
Specified by:
modifyAttributes in interface DirContext
NamingException

modifyAttributes

public void modifyAttributes(Name name,
                             ModificationItem[] mods)
                      throws NamingException
Specified by:
modifyAttributes in interface DirContext
NamingException

bind

public void bind(Name name,
                 Object obj)
          throws NamingException
Specified by:
bind in interface Context
NamingException

bind

public void bind(String name,
                 Object obj)
          throws NamingException
Specified by:
bind in interface Context
NamingException

bind

public void bind(String name,
                 Object obj,
                 Attributes attrs)
          throws NamingException
Specified by:
bind in interface DirContext
NamingException

bind

public void bind(Name name,
                 Object obj,
                 Attributes attrs)
          throws NamingException
NOTE: Simplified implementation: add attributes and object nonatomically Does not accept null obj (throws NullPointerException)

Specified by:
bind in interface DirContext
NamingException

rebind

public void rebind(Name name,
                   Object obj)
            throws NamingException
Specified by:
rebind in interface Context
NamingException

rebind

public void rebind(String name,
                   Object obj)
            throws NamingException
Specified by:
rebind in interface Context
NamingException

rebind

public void rebind(String name,
                   Object obj,
                   Attributes attrs)
            throws NamingException
Specified by:
rebind in interface DirContext
NamingException

rebind

public void rebind(Name name,
                   Object o,
                   Attributes attrs)
            throws NamingException
Specified by:
rebind in interface DirContext
NamingException

createSubcontext

public DirContext createSubcontext(String name,
                                   Attributes attrs)
                            throws NamingException
Specified by:
createSubcontext in interface DirContext
NamingException

createSubcontext

public Context createSubcontext(String name)
                         throws NamingException
Specified by:
createSubcontext in interface Context
NamingException

createSubcontext

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

createSubcontext

public DirContext createSubcontext(Name name,
                                   Attributes attrs)
                            throws NamingException
Specified by:
createSubcontext in interface DirContext
NamingException

destroySubcontext

public void destroySubcontext(String name)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
NamingException

destroySubcontext

public void destroySubcontext(Name name)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
NamingException

getSchema

public DirContext getSchema(String name)
                     throws NamingException
Specified by:
getSchema in interface DirContext
NamingException

getSchema

public DirContext getSchema(Name name)
                     throws NamingException
Specified by:
getSchema in interface DirContext
NamingException

getSchemaClassDefinition

public DirContext getSchemaClassDefinition(String name)
                                    throws NamingException
Specified by:
getSchemaClassDefinition in interface DirContext
NamingException

getSchemaClassDefinition

public DirContext getSchemaClassDefinition(Name name)
                                    throws NamingException
Specified by:
getSchemaClassDefinition in interface DirContext
NamingException

search

public NamingEnumeration search(String name,
                                Attributes matchingAttrs)
                         throws NamingException
Specified by:
search in interface DirContext
NamingException

search

public NamingEnumeration search(Name name,
                                Attributes matchingAttrs)
                         throws NamingException
Specified by:
search in interface DirContext
NamingException

search

public NamingEnumeration search(String name,
                                Attributes matchingAttrs,
                                String[] attrsRet)
                         throws NamingException
Specified by:
search in interface DirContext
NamingException

search

public NamingEnumeration search(Name name,
                                Attributes matchingAttrs,
                                String[] attrsRet)
                         throws NamingException
Specified by:
search in interface DirContext
NamingException

search

public NamingEnumeration search(String name,
                                String filterExpr,
                                Object[] filterArgs,
                                SearchControls cons)
                         throws NamingException
Specified by:
search in interface DirContext
NamingException

search

public NamingEnumeration search(Name name,
                                String filterExpr,
                                Object[] filterArgs,
                                SearchControls cons)
                         throws NamingException
Specified by:
search in interface DirContext
NamingException

search

public NamingEnumeration search(String name,
                                String filter,
                                SearchControls cons)
                         throws NamingException
Specified by:
search in interface DirContext
NamingException

search

public NamingEnumeration search(Name name,
                                String filter,
                                SearchControls cons)
                         throws NamingException
Specified by:
search in interface DirContext
NamingException

lookup

public Object lookup(String name)
              throws NamingException
Specified by:
lookup in interface Context
NamingException

lookup

public Object lookup(Name name)
              throws NamingException
Specified by:
lookup in interface Context
NamingException

unbind

public void unbind(String name)
            throws NamingException
Specified by:
unbind in interface Context
NamingException

unbind

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

rename

public void rename(String oldname,
                   String newname)
            throws NamingException
Specified by:
rename in interface Context
NamingException

rename

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

list

public NamingEnumeration list(String name)
                       throws NamingException
Specified by:
list in interface Context
NamingException

list

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

listBindings

public NamingEnumeration listBindings(String name)
                               throws NamingException
Specified by:
listBindings in interface Context
NamingException

listBindings

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

lookupLink

public Object lookupLink(String name)
                  throws NamingException
Specified by:
lookupLink in interface Context
NamingException

lookupLink

public Object lookupLink(Name name)
                  throws NamingException
Specified by:
lookupLink in interface Context
NamingException

getNameParser

public NameParser getNameParser(String name)
                         throws NamingException
Specified by:
getNameParser in interface Context
NamingException

getNameParser

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

composeName

public String composeName(String name,
                          String prefix)
                   throws NamingException
Specified by:
composeName in interface Context
NamingException

composeName

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

addToEnvironment

public Object addToEnvironment(String propName,
                               Object propVal)
                        throws NamingException
Specified by:
addToEnvironment in interface Context
NamingException

removeFromEnvironment

public Object removeFromEnvironment(String propName)
                             throws NamingException
Specified by:
removeFromEnvironment in interface Context
NamingException

getEnvironment

public Hashtable getEnvironment()
                         throws NamingException
Specified by:
getEnvironment in interface Context
NamingException

getNameInNamespace

public String getNameInNamespace()
                          throws NamingException
Specified by:
getNameInNamespace in interface Context
NamingException

toString

public String toString()
Overrides:
toString in class Object

close

public void close()
           throws NamingException
Specified by:
close in interface Context
NamingException

getMyComponents

protected Name getMyComponents(Name name)
                        throws NamingException
Utility method for processing composite/compound name.

Parameters:
name - The non-null composite or compound name to process.
Returns:
The non-null string name in this namespace to be processed.
NamingException

main

public static void main(String[] args)