@Test public void testConfigSourceStatic() throws Exception { assertEquals(config.getValue("application.currency", String.class), "Euro"); assertEquals(config.getValue("application.country", String.class), "PT"); assertEquals(applicationBean.getApplicationCurrrency(), "Euro"); assertEquals(applicationBean.getApplicationCountry(), "PT"); assertEquals(ConfigProvider.getConfig().getValue("application.currency", String.class), "Euro"); assertEquals(ConfigProvider.getConfig().getValue("application.country", String.class), "PT"); }
@Override public String getValue(final String propertyName) { try { final Connection connection = dataSource.getConnection(); final PreparedStatement query = connection.prepareStatement("SELECT VALUE FROM CONFIGURATIONS WHERE NAME = ?"); query.setString(1, propertyName); final ResultSet value = query.executeQuery(); if (value.next()) { return value.getString(1); } DbUtils.closeQuietly(value); DbUtils.closeQuietly(query); DbUtils.closeQuietly(connection); } catch (final SQLException e) { e.printStackTrace(); } return null; }
DatabaseConfigSource implements ConfigSource { @Override public String getValue(final String propertyName) { try { final Connection connection = dataSource.getConnection(); final PreparedStatement query = connection.prepareStatement("SELECT VALUE FROM CONFIGURATIONS WHERE NAME = ?"); query.setString(1, propertyName); final ResultSet value = query.executeQuery(); if (value.next()) { return value.getString(1); } DbUtils.closeQuietly(value); DbUtils.closeQuietly(query); DbUtils.closeQuietly(connection); } catch (final SQLException e) { e.printStackTrace(); } return null; } }
DatabaseConfigSource implements ConfigSource { @Override public String getValue(final String propertyName) { try { final Connection connection = dataSource.getConnection(); final PreparedStatement query = connection.prepareStatement("SELECT VALUE FROM CONFIGURATIONS WHERE NAME = ?"); query.setString(1, propertyName); final ResultSet value = query.executeQuery(); if (value.next()) { return value.getString(1); } DbUtils.closeQuietly(value); DbUtils.closeQuietly(query); DbUtils.closeQuietly(connection); } catch (final SQLException e) { e.printStackTrace(); } return null; } DatabaseConfigSource(); }
DatabaseConfigSource implements ConfigSource { @Override public String getValue(final String propertyName) { try { final Connection connection = dataSource.getConnection(); final PreparedStatement query = connection.prepareStatement("SELECT VALUE FROM CONFIGURATIONS WHERE NAME = ?"); query.setString(1, propertyName); final ResultSet value = query.executeQuery(); if (value.next()) { return value.getString(1); } DbUtils.closeQuietly(value); DbUtils.closeQuietly(query); DbUtils.closeQuietly(connection); } catch (final SQLException e) { e.printStackTrace(); } return null; } DatabaseConfigSource(); @Override Map<String, String> getProperties(); @Override String getValue(final String propertyName); @Override String getName(); }
DatabaseConfigSource implements ConfigSource { @Override public String getValue(final String propertyName) { try { final Connection connection = dataSource.getConnection(); final PreparedStatement query = connection.prepareStatement("SELECT VALUE FROM CONFIGURATIONS WHERE NAME = ?"); query.setString(1, propertyName); final ResultSet value = query.executeQuery(); if (value.next()) { return value.getString(1); } DbUtils.closeQuietly(value); DbUtils.closeQuietly(query); DbUtils.closeQuietly(connection); } catch (final SQLException e) { e.printStackTrace(); } return null; } DatabaseConfigSource(); @Override Map<String, String> getProperties(); @Override String getValue(final String propertyName); @Override String getName();  }