class GeoToolsLayer extends FeatureSourceRetriever implements VectorLayer {

	@Transactional(readOnly = true)
	public Iterator<?> getElements(Filter filter, int offset, int maxResultSize) throws LayerException {
		FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
		try {
			if (source instanceof FeatureStore<?, ?>) {
				SimpleFeatureStore store = (SimpleFeatureStore) source;
				transactionSynchronization.synchTransaction(store);
			}
			Query query = new Query();
			query.setFilter(filter);
			query.setMaxFeatures(maxResultSize > 0 ? maxResultSize : Integer.MAX_VALUE);
			query.setStartIndex(offset);
			FeatureCollection<SimpleFeatureType, SimpleFeature> fc = source.getFeatures(query);
			FeatureIterator<SimpleFeature> it = fc.features();
			transactionSynchronization.addIterator(it);
			return new JavaIterator(it);
		} catch (Throwable t) { // NOSONAR avoid errors (like NPE) as well
			throw new LayerException(t, ExceptionCode.UNEXPECTED_PROBLEM);
		}
	}

}