Integration with JNDI (Extension Module)

Tamaya JNDI is an extension module. Refer to the extensions documentation for further details.

What functionality this module provides ?

Tamaya JNDI provides a simple PropertySource that reads values from a JNDI context.


The module is based on Java 7, so it will not run on Java 7 and beyond.


To use jndi as a configuration backend you only must add the corresponding dependency to your module:


The Functionality Provided

Main artifact is the JNDIPropertySource class, which implements a property source based on a JNDI context:

public class JNDIPropertySource extends BasePropertySource {

    public JNDIPropertySource(String name, Context context);
    public JNDIPropertySource(String name) throws NamingException;
    public JNDIPropertySource() throws NamingException;

    public void setScannable(boolean scannable);


By default the property source is non scannable, so a call the getProperties() will return an empty map instance. After calling setScannable(true); a call to getProperties() will return a String representation of the JNDI tree. Hereby leaves of the tree are converted using String.valueOf(leaveObject).

This module automatically registers an instance of JNDIPropertySource with a default ordinal of 200.

You can extend this class or manually instantiate it, e.g. as part of a PropertySourceProvider. If no Context is passed explicitly, a new InitialContext is created, without any environment parameters set.