use of org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer in project osmosis by openstreetmap.
the class EntityDao method getEntityHistory.
private ReleasableIterator<EntityHistory<T>> getEntityHistory(String selectedEntityStatement, MapSqlParameterSource parameterSource) {
ReleasableContainer releasableContainer;
releasableContainer = new ReleasableContainer();
try {
ReleasableIterator<EntityHistory<T>> entityIterator;
ReleasableIterator<DbFeatureHistory<DbFeature<Tag>>> tagIterator;
List<FeatureHistoryPopulator<T, ?, ?>> featurePopulators;
EntityHistoryReader<T> entityHistoryReader;
entityIterator = releasableContainer.add(getFeaturelessEntityHistory(selectedEntityStatement, parameterSource));
tagIterator = releasableContainer.add(getTagHistory(selectedEntityStatement, parameterSource));
featurePopulators = getFeatureHistoryPopulators(selectedEntityStatement, parameterSource);
for (FeatureHistoryPopulator<T, ?, ?> featurePopulator : featurePopulators) {
releasableContainer.add(featurePopulator);
}
entityHistoryReader = new EntityHistoryReader<T>(entityIterator, tagIterator, featurePopulators);
// The sources are now all attached to the history reader so we don't want to release
// them in the finally block.
releasableContainer.clear();
return entityHistoryReader;
} finally {
releasableContainer.close();
}
}
Aggregations