@Test public void testLoadConfigurationNotExists() { final ScopePathBuilderFactory factory = getConfigService().getScopePathBuilderFactory(TestConfiguration.class); final ComplexConfigDTO result = persister.loadConfiguration(factory.annotatedPath().create()); Assert.assertNull(result); }
@Override public ComplexConfigDTO loadConfiguration(final ScopePath scopePath) { Assert.paramNotNull(scopePath, "scope"); final ComplexConfigDTO result = new JdbcTemplate<ComplexConfigDTO>(dataSource).perform(new DbCallable() { @Override public Object execute(final Connection con) throws Exception { InputStream in = null; PreparedStatement stmt = null; try { stmt = con.prepareStatement(queryGen.createSelectEqualsItemQuery( configColumnName, configTableName, scopePathColumnName)); stmt.setString(1, createColumnPath(scopePath)); final ResultSet resultSet = stmt.executeQuery(); Blob result = null; if (resultSet.next()) { result = resultSet.getBlob(configColumnName); } if (result != null) { in = result.getBinaryStream(); final ComplexConfigDTO configDTO = marshaller.unmarshal(in); if (configDTO.getVersion() < 1) { throw new StoreConfigException( "Illegal config version. Must be 1 or higher. Occures at scope Path '" + configDTO.getDefiningScopePath() + "'!"); } return configDTO; } return null; } finally { dbUtils.closeQuietly(stmt); dbUtils.closeQuietly(in); } } }); return result; }
DbConfigPersister implements ConfigPersister { @Override public ComplexConfigDTO loadConfiguration(final ScopePath scopePath) { Assert.paramNotNull(scopePath, "scope"); final ComplexConfigDTO result = new JdbcTemplate<ComplexConfigDTO>(dataSource).perform(new DbCallable() { @Override public Object execute(final Connection con) throws Exception { InputStream in = null; PreparedStatement stmt = null; try { stmt = con.prepareStatement(queryGen.createSelectEqualsItemQuery( configColumnName, configTableName, scopePathColumnName)); stmt.setString(1, createColumnPath(scopePath)); final ResultSet resultSet = stmt.executeQuery(); Blob result = null; if (resultSet.next()) { result = resultSet.getBlob(configColumnName); } if (result != null) { in = result.getBinaryStream(); final ComplexConfigDTO configDTO = marshaller.unmarshal(in); if (configDTO.getVersion() < 1) { throw new StoreConfigException( "Illegal config version. Must be 1 or higher. Occures at scope Path '" + configDTO.getDefiningScopePath() + "'!"); } return configDTO; } return null; } finally { dbUtils.closeQuietly(stmt); dbUtils.closeQuietly(in); } } }); return result; } }
DbConfigPersister implements ConfigPersister { @Override public ComplexConfigDTO loadConfiguration(final ScopePath scopePath) { Assert.paramNotNull(scopePath, "scope"); final ComplexConfigDTO result = new JdbcTemplate<ComplexConfigDTO>(dataSource).perform(new DbCallable() { @Override public Object execute(final Connection con) throws Exception { InputStream in = null; PreparedStatement stmt = null; try { stmt = con.prepareStatement(queryGen.createSelectEqualsItemQuery( configColumnName, configTableName, scopePathColumnName)); stmt.setString(1, createColumnPath(scopePath)); final ResultSet resultSet = stmt.executeQuery(); Blob result = null; if (resultSet.next()) { result = resultSet.getBlob(configColumnName); } if (result != null) { in = result.getBinaryStream(); final ComplexConfigDTO configDTO = marshaller.unmarshal(in); if (configDTO.getVersion() < 1) { throw new StoreConfigException( "Illegal config version. Must be 1 or higher. Occures at scope Path '" + configDTO.getDefiningScopePath() + "'!"); } return configDTO; } return null; } finally { dbUtils.closeQuietly(stmt); dbUtils.closeQuietly(in); } } }); return result; } DbConfigPersister(
		final String configTableName,
		final String scopePathColumnName,
		final String configVersionColumnName,
		final String configColumnName,
		final ConfigMarshaller marshaller,
		final DataSource dataSource); }
DbConfigPersister implements ConfigPersister { @Override public ComplexConfigDTO loadConfiguration(final ScopePath scopePath) { Assert.paramNotNull(scopePath, "scope"); final ComplexConfigDTO result = new JdbcTemplate<ComplexConfigDTO>(dataSource).perform(new DbCallable() { @Override public Object execute(final Connection con) throws Exception { InputStream in = null; PreparedStatement stmt = null; try { stmt = con.prepareStatement(queryGen.createSelectEqualsItemQuery( configColumnName, configTableName, scopePathColumnName)); stmt.setString(1, createColumnPath(scopePath)); final ResultSet resultSet = stmt.executeQuery(); Blob result = null; if (resultSet.next()) { result = resultSet.getBlob(configColumnName); } if (result != null) { in = result.getBinaryStream(); final ComplexConfigDTO configDTO = marshaller.unmarshal(in); if (configDTO.getVersion() < 1) { throw new StoreConfigException( "Illegal config version. Must be 1 or higher. Occures at scope Path '" + configDTO.getDefiningScopePath() + "'!"); } return configDTO; } return null; } finally { dbUtils.closeQuietly(stmt); dbUtils.closeQuietly(in); } } }); return result; } DbConfigPersister(
		final String configTableName,
		final String scopePathColumnName,
		final String configVersionColumnName,
		final String configColumnName,
		final ConfigMarshaller marshaller,
		final DataSource dataSource); @Override String getId(); @Override ComplexConfigDTO loadConfiguration(final ScopePath scopePath); @Override void saveConfiguration(final ComplexConfigDTO configDTO); @Override void updateConfiguration(final ComplexConfigDTO configDTO); @Override void delete(final ScopePath scope, final boolean deleteChildren); @Override void deleteAllOccurences(final String scopeName, final Map<String, String> properties); @Override Collection<ScopePath> listScopes(final String scopeName, final Map<String, String> properties); }
DbConfigPersister implements ConfigPersister { @Override public ComplexConfigDTO loadConfiguration(final ScopePath scopePath) { Assert.paramNotNull(scopePath, "scope"); final ComplexConfigDTO result = new JdbcTemplate<ComplexConfigDTO>(dataSource).perform(new DbCallable() { @Override public Object execute(final Connection con) throws Exception { InputStream in = null; PreparedStatement stmt = null; try { stmt = con.prepareStatement(queryGen.createSelectEqualsItemQuery( configColumnName, configTableName, scopePathColumnName)); stmt.setString(1, createColumnPath(scopePath)); final ResultSet resultSet = stmt.executeQuery(); Blob result = null; if (resultSet.next()) { result = resultSet.getBlob(configColumnName); } if (result != null) { in = result.getBinaryStream(); final ComplexConfigDTO configDTO = marshaller.unmarshal(in); if (configDTO.getVersion() < 1) { throw new StoreConfigException( "Illegal config version. Must be 1 or higher. Occures at scope Path '" + configDTO.getDefiningScopePath() + "'!"); } return configDTO; } return null; } finally { dbUtils.closeQuietly(stmt); dbUtils.closeQuietly(in); } } }); return result; } DbConfigPersister(
		final String configTableName,
		final String scopePathColumnName,
		final String configVersionColumnName,
		final String configColumnName,
		final ConfigMarshaller marshaller,
		final DataSource dataSource); @Override String getId(); @Override ComplexConfigDTO loadConfiguration(final ScopePath scopePath); @Override void saveConfiguration(final ComplexConfigDTO configDTO); @Override void updateConfiguration(final ComplexConfigDTO configDTO); @Override void delete(final ScopePath scope, final boolean deleteChildren); @Override void deleteAllOccurences(final String scopeName, final Map<String, String> properties); @Override Collection<ScopePath> listScopes(final String scopeName, final Map<String, String> properties); static final String ID; }