Package org.springframework.mock.jndi
Class SimpleNamingContext
- java.lang.Object
- org.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 for test environments, but also usable for standalone applications.This class is not intended for direct usage by applications, although it can be used for example to override JndiTemplate's
createInitialContextmethod in unit tests. Typically, SimpleNamingContextBuilder will be used 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
Constructors Constructor Description SimpleNamingContext()Create a new naming context.SimpleNamingContext(String root)Create a new naming context with the given naming root.SimpleNamingContext(String root, Hashtable<String,Object> boundObjects, Hashtable<String,Object> env)Create a new naming context with the given naming root, the given name/object map, and the JNDI environment entries.
Method Summary
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.
Method Detail
list
public NamingEnumeration<NameClassPair> list(String root) throws NamingException
- Specified by:
listin interfaceContext- Throws:
NamingException
listBindings
public NamingEnumeration<Binding> listBindings(String root) throws NamingException
- Specified by:
listBindingsin interfaceContext- Throws:
NamingException
lookup
public Object lookup(String lookupName) 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:
lookupin interfaceContext- Throws:
NameNotFoundException- if the object could not be found
lookupLink
public Object lookupLink(String name) throws NameNotFoundException
- Specified by:
lookupLinkin interfaceContext- 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:
bindin interfaceContext- See Also:
SimpleNamingContextBuilder.bind(java.lang.String, java.lang.Object)
rename
public void rename(String oldName, String newName) throws NameNotFoundException
- Specified by:
renamein interfaceContext- Throws:
NameNotFoundException
createSubcontext
public Context createSubcontext(String name)
- Specified by:
createSubcontextin interfaceContext
destroySubcontext
public void destroySubcontext(String name)
- Specified by:
destroySubcontextin interfaceContext
composeName
public String composeName(String name, String prefix)
- Specified by:
composeNamein interfaceContext
getEnvironment
public Hashtable<String,Object> getEnvironment()
- Specified by:
getEnvironmentin interfaceContext
addToEnvironment
public Object addToEnvironment(String propName, Object propVal)
- Specified by:
addToEnvironmentin interfaceContext
removeFromEnvironment
public Object removeFromEnvironment(String propName)
- Specified by:
removeFromEnvironmentin interfaceContext
list
public NamingEnumeration<NameClassPair> list(Name name) throws NamingException
- Specified by:
listin interfaceContext- Throws:
NamingException
listBindings
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException
- Specified by:
listBindingsin interfaceContext- Throws:
NamingException
lookup
public Object lookup(Name name) throws NamingException
- Specified by:
lookupin interfaceContext- Throws:
NamingException
lookupLink
public Object lookupLink(Name name) throws NamingException
- Specified by:
lookupLinkin interfaceContext- Throws:
NamingException
bind
public void bind(Name name, Object obj) throws NamingException
- Specified by:
bindin interfaceContext- Throws:
NamingException
unbind
public void unbind(Name name) throws NamingException
- Specified by:
unbindin interfaceContext- Throws:
NamingException
rebind
public void rebind(Name name, Object obj) throws NamingException
- Specified by:
rebindin interfaceContext- Throws:
NamingException
rename
public void rename(Name oldName, Name newName) throws NamingException
- Specified by:
renamein interfaceContext- Throws:
NamingException
createSubcontext
public Context createSubcontext(Name name) throws NamingException
- Specified by:
createSubcontextin interfaceContext- Throws:
NamingException
destroySubcontext
public void destroySubcontext(Name name) throws NamingException
- Specified by:
destroySubcontextin interfaceContext- Throws:
NamingException
getNameInNamespace
public String getNameInNamespace() throws NamingException
- Specified by:
getNameInNamespacein interfaceContext- Throws:
NamingException
getNameParser
public NameParser getNameParser(Name name) throws NamingException
- Specified by:
getNameParserin interfaceContext- Throws:
NamingException
getNameParser
public NameParser getNameParser(String name) throws NamingException
- Specified by:
getNameParserin interfaceContext- Throws:
NamingException
composeName
public Name composeName(Name name, Name prefix) throws NamingException
- Specified by:
composeNamein interfaceContext- Throws:
NamingException