org.springframework.mock.jndi
Class SimpleNamingContext

java.lang.Object
  extended byorg.springframework.mock.jndi.SimpleNamingContext
All Implemented Interfaces:
Context

public class SimpleNamingContext
extends Object
implements Context

Simple implementation of a JNDI naming context. Only supports binding plain Objects to String names. Mainly targetted at test environments, but also usable for standalone applications.

This class is not intended for direct usage by applications, although it can be used e.g. to override's JndiTemplate's createInitialContext method in unit tests. Use SimpleNamingContextBuilder to set up a JVM-level JNDI environment.

Author:
Rod Johnson, Juergen Hoeller
See Also:
SimpleNamingContextBuilder, JndiTemplate.createInitialContext()

Field Summary
 
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
SimpleNamingContext()
          Create a new naming context.
SimpleNamingContext(String root)
          Create a new naming context with the given naming root.
SimpleNamingContext(String root, Hashtable boundObjects, Hashtable environment)
          Create a new naming context with the given naming root, the given name/object map, and the JNDI environment entries.
 
Method Summary
 Object addToEnvironment(String propName, Object propVal)
           
 void bind(Name arg0, Object arg1)
           
 void bind(String name, Object obj)
          Bind the given object to the given name.
 void close()
           
 Name composeName(Name arg0, Name arg1)
           
 String composeName(String arg0, String arg1)
           
 Context createSubcontext(Name arg0)
           
 Context createSubcontext(String name)
           
 void destroySubcontext(Name arg0)
           
 void destroySubcontext(String name)
           
 Hashtable getEnvironment()
           
 String getNameInNamespace()
           
 NameParser getNameParser(Name arg0)
           
 NameParser getNameParser(String arg0)
           
 NamingEnumeration list(Name arg0)
           
 NamingEnumeration list(String root)
           
 NamingEnumeration listBindings(Name arg0)
           
 NamingEnumeration listBindings(String root)
           
 Object lookup(Name arg0)
           
 Object lookup(String pname)
          Look up the object with the given name.
 Object lookupLink(Name arg0)
           
 Object lookupLink(String name)
           
 void rebind(Name arg0, Object arg1)
           
 void rebind(String name, Object obj)
           
 Object removeFromEnvironment(String propName)
           
 void rename(Name arg0, Name arg1)
           
 void rename(String oldName, String newName)
           
 void unbind(Name arg0)
           
 void unbind(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleNamingContext

public SimpleNamingContext()
Create a new naming context.


SimpleNamingContext

public SimpleNamingContext(String root)
Create a new naming context with the given naming root.


SimpleNamingContext

public SimpleNamingContext(String root,
                           Hashtable boundObjects,
                           Hashtable environment)
Create a new naming context with the given naming root, the given name/object map, and the JNDI environment entries.

Method Detail

list

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

listBindings

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

lookup

public Object lookup(String pname)
              throws NameNotFoundException
Look up the object with the given name. Note: Not intended for direct use by applications. Will be used by any standard InitialContext JNDI lookups.

Specified by:
lookup in interface Context
Throws:
NameNotFoundException - if the object could not be found

lookupLink

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

bind

public void bind(String name,
                 Object obj)
Bind the given object to the given name. Note: Not intended for direct use by applications if setting up a JVM-level JNDI environment. Use SimpleNamingContextBuilder to set up JNDI bindings then.

Specified by:
bind in interface Context
See Also:
SimpleNamingContextBuilder.bind(java.lang.String, java.lang.Object)

unbind

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

rebind

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

rename

public void rename(String oldName,
                   String newName)
            throws NameNotFoundException
Specified by:
rename in interface Context
Throws:
NameNotFoundException

createSubcontext

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

destroySubcontext

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

getEnvironment

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

addToEnvironment

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

removeFromEnvironment

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

close

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

list

public NamingEnumeration list(Name arg0)
Specified by:
list in interface Context

listBindings

public NamingEnumeration listBindings(Name arg0)
Specified by:
listBindings in interface Context

lookup

public Object lookup(Name arg0)
Specified by:
lookup in interface Context

lookupLink

public Object lookupLink(Name arg0)
Specified by:
lookupLink in interface Context

bind

public void bind(Name arg0,
                 Object arg1)
Specified by:
bind in interface Context

unbind

public void unbind(Name arg0)
Specified by:
unbind in interface Context

rebind

public void rebind(Name arg0,
                   Object arg1)
Specified by:
rebind in interface Context

rename

public void rename(Name arg0,
                   Name arg1)
Specified by:
rename in interface Context

createSubcontext

public Context createSubcontext(Name arg0)
Specified by:
createSubcontext in interface Context

destroySubcontext

public void destroySubcontext(Name arg0)
Specified by:
destroySubcontext in interface Context

getNameInNamespace

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

getNameParser

public NameParser getNameParser(Name arg0)
Specified by:
getNameParser in interface Context

getNameParser

public NameParser getNameParser(String arg0)
Specified by:
getNameParser in interface Context

composeName

public Name composeName(Name arg0,
                        Name arg1)
Specified by:
composeName in interface Context

composeName

public String composeName(String arg0,
                          String arg1)
Specified by:
composeName in interface Context


Copyright (C) 2003-2004 The Spring Framework Project.