@Test public void testGetJndiDataSources() { getJndiDataSources(); setProperty(Parameter.DATASOURCES, ""); getJndiDataSources(); setProperty(Parameter.DATASOURCES, "testDataSource"); getJndiDataSources(); setProperty(Parameter.DATASOURCES, null); }
static Map<String, DataSource> getJndiDataSources() throws NamingException { final Map<String, DataSource> dataSources = new LinkedHashMap<String, DataSource>(2); final String datasourcesParameter = Parameter.DATASOURCES.getValue(); if (datasourcesParameter == null) { dataSources.putAll(getJndiDataSourcesAt("java:comp/env/jdbc")); dataSources.putAll(getJndiDataSourcesAt("java:/jdbc")); dataSources.putAll(getJndiDataSourcesAt("java:global/jdbc")); dataSources.putAll(getJndiDataSourcesAt("jdbc")); } else if (!datasourcesParameter.trim().isEmpty()) { final InitialContext initialContext = new InitialContext(); for (final String datasource : datasourcesParameter.split(",")) { final String jndiName = datasource.trim(); final DataSource dataSource = (DataSource) initialContext.lookup(jndiName); dataSources.put(jndiName, dataSource); } initialContext.close(); } return Collections.unmodifiableMap(dataSources); }
JdbcWrapperHelper { static Map<String, DataSource> getJndiDataSources() throws NamingException { final Map<String, DataSource> dataSources = new LinkedHashMap<String, DataSource>(2); final String datasourcesParameter = Parameter.DATASOURCES.getValue(); if (datasourcesParameter == null) { dataSources.putAll(getJndiDataSourcesAt("java:comp/env/jdbc")); dataSources.putAll(getJndiDataSourcesAt("java:/jdbc")); dataSources.putAll(getJndiDataSourcesAt("java:global/jdbc")); dataSources.putAll(getJndiDataSourcesAt("jdbc")); } else if (!datasourcesParameter.trim().isEmpty()) { final InitialContext initialContext = new InitialContext(); for (final String datasource : datasourcesParameter.split(",")) { final String jndiName = datasource.trim(); final DataSource dataSource = (DataSource) initialContext.lookup(jndiName); dataSources.put(jndiName, dataSource); } initialContext.close(); } return Collections.unmodifiableMap(dataSources); } }
JdbcWrapperHelper { static Map<String, DataSource> getJndiDataSources() throws NamingException { final Map<String, DataSource> dataSources = new LinkedHashMap<String, DataSource>(2); final String datasourcesParameter = Parameter.DATASOURCES.getValue(); if (datasourcesParameter == null) { dataSources.putAll(getJndiDataSourcesAt("java:comp/env/jdbc")); dataSources.putAll(getJndiDataSourcesAt("java:/jdbc")); dataSources.putAll(getJndiDataSourcesAt("java:global/jdbc")); dataSources.putAll(getJndiDataSourcesAt("jdbc")); } else if (!datasourcesParameter.trim().isEmpty()) { final InitialContext initialContext = new InitialContext(); for (final String datasource : datasourcesParameter.split(",")) { final String jndiName = datasource.trim(); final DataSource dataSource = (DataSource) initialContext.lookup(jndiName); dataSources.put(jndiName, dataSource); } initialContext.close(); } return Collections.unmodifiableMap(dataSources); } private  JdbcWrapperHelper(); }
JdbcWrapperHelper { static Map<String, DataSource> getJndiDataSources() throws NamingException { final Map<String, DataSource> dataSources = new LinkedHashMap<String, DataSource>(2); final String datasourcesParameter = Parameter.DATASOURCES.getValue(); if (datasourcesParameter == null) { dataSources.putAll(getJndiDataSourcesAt("java:comp/env/jdbc")); dataSources.putAll(getJndiDataSourcesAt("java:/jdbc")); dataSources.putAll(getJndiDataSourcesAt("java:global/jdbc")); dataSources.putAll(getJndiDataSourcesAt("jdbc")); } else if (!datasourcesParameter.trim().isEmpty()) { final InitialContext initialContext = new InitialContext(); for (final String datasource : datasourcesParameter.split(",")) { final String jndiName = datasource.trim(); final DataSource dataSource = (DataSource) initialContext.lookup(jndiName); dataSources.put(jndiName, dataSource); } initialContext.close(); } return Collections.unmodifiableMap(dataSources); } private  JdbcWrapperHelper();  }
JdbcWrapperHelper { static Map<String, DataSource> getJndiDataSources() throws NamingException { final Map<String, DataSource> dataSources = new LinkedHashMap<String, DataSource>(2); final String datasourcesParameter = Parameter.DATASOURCES.getValue(); if (datasourcesParameter == null) { dataSources.putAll(getJndiDataSourcesAt("java:comp/env/jdbc")); dataSources.putAll(getJndiDataSourcesAt("java:/jdbc")); dataSources.putAll(getJndiDataSourcesAt("java:global/jdbc")); dataSources.putAll(getJndiDataSourcesAt("jdbc")); } else if (!datasourcesParameter.trim().isEmpty()) { final InitialContext initialContext = new InitialContext(); for (final String datasource : datasourcesParameter.split(",")) { final String jndiName = datasource.trim(); final DataSource dataSource = (DataSource) initialContext.lookup(jndiName); dataSources.put(jndiName, dataSource); } initialContext.close(); } return Collections.unmodifiableMap(dataSources); } private  JdbcWrapperHelper();   }