| java.lang.Object org.springframework.jndi.JndiTemplate
JndiTemplate | public class JndiTemplate (Code) | | Helper class that simplifies JNDI operations. It provides methods to lookup and
bind objects, and allows implementations of the
JndiCallback interface
to perform any operation they like with a JNDI naming context provided.
author: Rod Johnson author: Juergen Hoeller See Also: JndiCallback See Also: JndiTemplate.execute |
Field Summary | |
final protected Log | logger |
Constructor Summary | |
public | JndiTemplate() Create a new JndiTemplate instance. | public | JndiTemplate(Properties environment) Create a new JndiTemplate instance, using the given environment. |
Method Summary | |
public void | bind(String name, Object object) Bind the given object to the current JNDI context, using the given name. | protected Context | createInitialContext() Create a new JNDI initial context. | public Object | execute(JndiCallback contextCallback) Execute the given JNDI context callback implementation. | public Properties | getEnvironment() Return the environment for the JNDI InitialContext, if any. | public Object | lookup(String name) Look up the object with the given name in the current JNDI context. | public Object | lookup(String name, Class requiredType) Look up the object with the given name in the current JNDI context.
Parameters: name - the JNDI name of the object Parameters: requiredType - type the JNDI object must match. | public void | rebind(String name, Object object) Rebind the given object to the current JNDI context, using the given name. | public void | setEnvironment(Properties environment) Set the environment for the JNDI InitialContext. | public void | unbind(String name) Remove the binding for the given name from the current JNDI context. |
logger | final protected Log logger(Code) | | |
JndiTemplate | public JndiTemplate()(Code) | | Create a new JndiTemplate instance.
|
JndiTemplate | public JndiTemplate(Properties environment)(Code) | | Create a new JndiTemplate instance, using the given environment.
|
bind | public void bind(String name, Object object) throws NamingException(Code) | | Bind the given object to the current JNDI context, using the given name.
Parameters: name - the JNDI name of the object Parameters: object - the object to bind throws: NamingException - thrown by JNDI, mostly name already bound |
createInitialContext | protected Context createInitialContext() throws NamingException(Code) | | Create a new JNDI initial context. Invoked by execute.
The default implementation use this template's environment settings.
Can be subclassed for custom contexts, e.g. for testing.
the initial Context instance throws: NamingException - in case of initialization errors |
getEnvironment | public Properties getEnvironment()(Code) | | Return the environment for the JNDI InitialContext, if any.
|
lookup | public Object lookup(String name) throws NamingException(Code) | | Look up the object with the given name in the current JNDI context.
Parameters: name - the JNDI name of the object object found (cannot be null ; if a not so well-behavedJNDI implementations returns null, a NamingException gets thrown) throws: NamingException - if there is no object with the givenname bound to JNDI |
lookup | public Object lookup(String name, Class requiredType) throws NamingException(Code) | | Look up the object with the given name in the current JNDI context.
Parameters: name - the JNDI name of the object Parameters: requiredType - type the JNDI object must match. Can be an interface orsuperclass of the actual class, or null for any match. For example,if the value is Object.class , this method will succeed whateverthe class of the returned instance. object found (cannot be null ; if a not so well-behavedJNDI implementations returns null, a NamingException gets thrown) throws: NamingException - if there is no object with the givenname bound to JNDI |
rebind | public void rebind(String name, Object object) throws NamingException(Code) | | Rebind the given object to the current JNDI context, using the given name.
Overwrites any existing binding.
Parameters: name - the JNDI name of the object Parameters: object - the object to rebind throws: NamingException - thrown by JNDI |
setEnvironment | public void setEnvironment(Properties environment)(Code) | | Set the environment for the JNDI InitialContext.
|
unbind | public void unbind(String name) throws NamingException(Code) | | Remove the binding for the given name from the current JNDI context.
Parameters: name - the JNDI name of the object throws: NamingException - thrown by JNDI, mostly name not found |
|
|