You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A more elegant way to lookup typed properties (New in 0.14.0)
h-thurow edited this page May 13, 2017
·
1 revision
0.14.0 can cooperate with org.apache.commons.configuration.JNDIConfiguration as contained in Apache Commons Configuration 1.10. JNDIConfiguration takes a java.naming.Context and offers some convenience methods that return typed properties, e.g.:
public String getString(String key)
public String getString(String key, String defaultValue)
public short getShort(String key)
public short getShort(String key, short defaultValue)
public Short getShort(String key, Short defaultValue)
public Long getLong(String key, Long defaultValue)
public long getLong(String key, long defaultValue)
public long getLong(String key)
public BigInteger getBigInteger(String key)
public BigInteger getBigInteger(String key, BigInteger defaultValue)
public BigDecimal getBigDecimal(String key)
public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
and so on. The code to leverage JNDIConfiguration looks like this
Context ctx = new InitialContext();
final JNDIConfiguration jndiConf = new JNDIConfiguration(ctx);
int myInt = jndiConf.getInt("...")
So you can avoid to clutter your property files with Simple-JNDI specific type declarations.
There are some things to note to make Simple-JNDI and JNDIConfiguration cooperate with each other
With org.osjava.sj.delimiter set to "." (default) you have to set jndi.syntax.separator to "/".