DATACMNS-223 - Added logging to ResourceReaderRepositoryPopulator.

Logging the read resources in INFO level, the individual elements persisted in DEBUG. Polished JavaDoc.
This commit is contained in:
Oliver Gierke
2012-09-04 10:02:32 +02:00
parent 5c54e7fef1
commit 8604de5597
2 changed files with 7 additions and 2 deletions

View File

@@ -30,8 +30,7 @@ import org.springframework.data.repository.support.Repositories;
import org.springframework.util.Assert;
/**
* A {@link RepositoryPopulator} using a {@link ResourceReader} to read objects from the configured {@link Resource}
* s.
* A {@link RepositoryPopulator} using a {@link ResourceReader} to read objects from the configured {@link Resource}s.
*
* @author Oliver Gierke
* @since 1.4
@@ -100,6 +99,8 @@ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator {
for (Resource resource : resources) {
LOG.info(String.format("Reading resource: %s", resource));
Object result = readObjectFrom(resource);
if (result instanceof Collection) {
@@ -137,7 +138,9 @@ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator {
* @param repositories must not be {@literal null}.
*/
private void persist(Object object, Repositories repositories) {
CrudRepository<Object, Serializable> repository = repositories.getRepositoryFor(object.getClass());
LOG.debug(String.format("Persisting %s using repository %s", object, repository));
repository.save(object);
}
}

View File

@@ -24,6 +24,8 @@ import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
/**
* Integration tests for {@link JacksonResourceReader}.
*
* @author Oliver Gierke
*/
public class JacksonResourceReaderIntegrationTests {