List of usage examples for javax.naming NameClassPair isRelative
public boolean isRelative()
list()
method). From source file:org.nuxeo.runtime.datasource.DataSourceHelper.java
public static Map<String, DataSource> getDatasources() throws NamingException { String prefix = getDataSourceJNDIPrefix(); Context naming = new InitialContext(); Context jdbc = (Context) naming.lookup(prefix); Enumeration<NameClassPair> namesPair = jdbc.list(""); Map<String, DataSource> datasourcesByName = new HashMap<String, DataSource>(); while (namesPair.hasMoreElements()) { NameClassPair pair = namesPair.nextElement(); String name = pair.getName(); if (pair.isRelative()) { name = prefix + "/" + name; }/* ww w.j a v a 2 s . co m*/ Object ds = naming.lookup(name); if (ds instanceof DataSource) { datasourcesByName.put(name, (DataSource) ds); } } return datasourcesByName; }