This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 52111c1cf2 Add `implements StoreResource` in some (not all) places
where it was missing.
52111c1cf2 is described below
commit 52111c1cf23b9510b461e5e065f739fb798dc8ba
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon Jun 6 18:56:22 2022 +0200
Add `implements StoreResource` in some (not all) places where it was
missing.
---
.../org/apache/sis/storage/landsat/BandGroup.java | 14 +++++++++--
.../apache/sis/storage/landsat/package-info.java | 2 +-
.../sis/storage/geotiff/MultiResolutionImage.java | 25 +++++++++++++++++--
.../org/apache/sis/internal/netcdf/Decoder.java | 5 ++--
.../sis/internal/netcdf/DiscreteSampling.java | 24 +++++++++++++++---
.../org/apache/sis/internal/netcdf/FeatureSet.java | 9 ++++---
.../apache/sis/internal/netcdf/RasterResource.java | 26 +++++++++++++++----
.../apache/sis/internal/netcdf/package-info.java | 2 +-
.../sis/internal/netcdf/ucar/DecoderWrapper.java | 5 ++--
.../sis/internal/netcdf/ucar/FeaturesWrapper.java | 5 ++--
.../sis/internal/netcdf/ucar/package-info.java | 2 +-
.../apache/sis/internal/netcdf/FeatureSetTest.java | 17 ++++++++++++-
.../apache/sis/internal/storage/StoreResource.java | 29 +++++++++++++++++++---
.../apache/sis/storage/event/StoreListeners.java | 19 +++++++++++---
.../org/apache/sis/storage/event/package-info.java | 2 +-
15 files changed, 151 insertions(+), 35 deletions(-)
diff --git
a/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/landsat/BandGroup.java
b/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/landsat/BandGroup.java
index 6cb675acdc..d161908052 100644
---
a/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/landsat/BandGroup.java
+++
b/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/landsat/BandGroup.java
@@ -28,8 +28,10 @@ import org.apache.sis.storage.Aggregate;
import org.apache.sis.storage.AbstractResource;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.event.StoreListeners;
+import org.apache.sis.internal.storage.StoreResource;
import org.apache.sis.internal.storage.MetadataBuilder;
import org.apache.sis.internal.util.UnmodifiableArrayList;
+import org.apache.sis.storage.DataStore;
import org.apache.sis.util.ArraysExt;
@@ -42,11 +44,11 @@ import org.apache.sis.util.ArraysExt;
* a sample dimension.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 1.1
* @module
*/
-final class BandGroup extends AbstractResource implements Aggregate {
+final class BandGroup extends AbstractResource implements Aggregate,
StoreResource {
/**
* The group of bands that this aggregate represents.
*/
@@ -99,6 +101,14 @@ final class BandGroup extends AbstractResource implements
Aggregate {
return ArraysExt.resize(aggregates, n);
}
+ /**
+ * Returns the data store that created this resource.
+ */
+ @Override
+ public DataStore getOriginator() {
+ return (DataStore) listeners.getParent().get().getSource();
+ }
+
/**
* Returns the resource persistent identifier if available.
*/
diff --git
a/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/landsat/package-info.java
b/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/landsat/package-info.java
index 2f50ae6813..ede32b70d4 100644
---
a/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/landsat/package-info.java
+++
b/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/landsat/package-info.java
@@ -27,7 +27,7 @@
* @author Thi Phuong Hao Nguyen (VNSC)
* @author Minh Chinh Vu (VNSC)
* @author Martin Desruisseaux (Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 1.1
* @module
*/
diff --git
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
index d5cf951dbe..4ed3aca47a 100644
---
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
+++
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java
@@ -18,6 +18,7 @@ package org.apache.sis.storage.geotiff;
import java.util.List;
import java.util.Arrays;
+import java.nio.file.Path;
import java.io.IOException;
import org.opengis.util.NameSpace;
import org.opengis.util.FactoryException;
@@ -31,9 +32,12 @@ import org.apache.sis.coverage.grid.GridExtent;
import org.apache.sis.coverage.grid.GridGeometry;
import org.apache.sis.coverage.grid.GridCoverage;
import org.apache.sis.storage.GridCoverageResource;
+import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.DataStoreReferencingException;
+import org.apache.sis.internal.storage.StoreResource;
import org.apache.sis.internal.storage.GridResourceWrapper;
+import org.apache.sis.internal.storage.ResourceOnFileSystem;
import org.apache.sis.internal.referencing.DirectPositionView;
import org.apache.sis.referencing.operation.matrix.MatrixSIS;
import org.apache.sis.referencing.CRS;
@@ -44,11 +48,11 @@ import org.apache.sis.referencing.CRS;
* and following entries are images at finer resolutions.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 1.2
* @module
*/
-final class MultiResolutionImage extends GridResourceWrapper {
+final class MultiResolutionImage extends GridResourceWrapper implements
ResourceOnFileSystem, StoreResource {
/**
* Name of the image at finest resolution.
* This is used as the namespace for overviews.
@@ -57,6 +61,7 @@ final class MultiResolutionImage extends GridResourceWrapper {
/**
* Descriptions of each <cite>Image File Directory</cite> (IFD) in the
GeoTIFF file.
+ * Should have at least 2 elements. The full-resolution image shall be at
index 0.
*/
private final ImageFileDirectory[] levels;
@@ -84,6 +89,22 @@ final class MultiResolutionImage extends GridResourceWrapper
{
resolutions = new double[levels.length][];
}
+ /**
+ * Returns the data store that produced this resource.
+ */
+ @Override
+ public final DataStore getOriginator() {
+ return levels[0].getOriginator();
+ }
+
+ /**
+ * Gets the paths to files used by this resource, or an empty array if
unknown.
+ */
+ @Override
+ public Path[] getComponentFiles() {
+ return levels[0].getComponentFiles();
+ }
+
/**
* Returns the object on which to perform all synchronizations for
thread-safety.
*/
diff --git
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
index 1c3d25254c..cbca54e07e 100644
---
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
+++
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
@@ -36,6 +36,7 @@ import org.opengis.util.NameFactory;
import org.opengis.referencing.datum.Datum;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.apache.sis.setup.GeometryLibrary;
+import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.event.StoreListeners;
import org.apache.sis.util.Utilities;
@@ -56,7 +57,7 @@ import ucar.nc2.constants.CF;
* Synchronizations are caller's responsibility.</p>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.1
+ * @version 1.3
* @since 0.3
* @module
*/
@@ -393,7 +394,7 @@ public abstract class Decoder extends
ReferencingFactoryContainer implements Clo
* @throws IOException if an I/O operation was necessary but failed.
* @throws DataStoreException if a logical error occurred.
*/
- public DiscreteSampling[] getDiscreteSampling(final Object lock) throws
IOException, DataStoreException {
+ public DiscreteSampling[] getDiscreteSampling(final DataStore lock) throws
IOException, DataStoreException {
final String type = stringValue(CF.FEATURE_TYPE);
if (type == null || type.equalsIgnoreCase(FeatureSet.TRAJECTORY)) try {
return FeatureSet.create(this, lock);
diff --git
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
index 2da2f47c92..744ddb4829 100644
---
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
+++
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
@@ -18,6 +18,8 @@ package org.apache.sis.internal.netcdf;
import org.apache.sis.setup.GeometryLibrary;
import org.apache.sis.internal.feature.Geometries;
+import org.apache.sis.internal.storage.StoreResource;
+import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.AbstractFeatureSet;
import org.apache.sis.storage.event.StoreListeners;
import org.apache.sis.util.resources.Errors;
@@ -30,11 +32,11 @@ import org.apache.sis.util.resources.Errors;
* and profiles.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 0.8
* @module
*/
-public abstract class DiscreteSampling extends AbstractFeatureSet {
+public abstract class DiscreteSampling extends AbstractFeatureSet implements
StoreResource {
/**
* The factory to use for creating geometries.
*/
@@ -43,11 +45,13 @@ public abstract class DiscreteSampling extends
AbstractFeatureSet {
/**
* The object to use for synchronization. For now we use a {@code
synchronized} statement,
* but it may be changed to {@link java.util.concurrent.locks.Lock} in a
future version.
+ * Current lock is the whole netCDF data store (so this field is
opportunistically used
+ * by {@link #getOriginator()}), but it may change in future version.
*
* @see RasterResource#lock
* @see #getSynchronizationLock()
*/
- private final Object lock;
+ private final DataStore lock;
/**
* Creates a new discrete sampling parser.
@@ -57,12 +61,24 @@ public abstract class DiscreteSampling extends
AbstractFeatureSet {
* @param lock the lock to use in {@code synchronized(lock)}
statements.
* @throws IllegalArgumentException if the given library is non-null but
not available.
*/
- protected DiscreteSampling(final GeometryLibrary library, final
StoreListeners listeners, final Object lock) {
+ protected DiscreteSampling(final GeometryLibrary library, final
StoreListeners listeners, final DataStore lock) {
super(listeners, false);
factory = Geometries.implementation(library);
this.lock = lock;
}
+ /**
+ * Returns the data store that produced this resource.
+ */
+ @Override
+ public final DataStore getOriginator() {
+ /*
+ * Could be replaced by `(DataStore)
listeners.getParent().get().getSource()`
+ * if a future version decides to use a different kind of lock.
+ */
+ return lock;
+ }
+
/**
* Returns the object on which to perform synchronizations for
thread-safety.
*
diff --git
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/FeatureSet.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/FeatureSet.java
index e908d6c8cd..2533061cab 100644
---
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/FeatureSet.java
+++
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/FeatureSet.java
@@ -39,6 +39,7 @@ import org.apache.sis.referencing.crs.DefaultTemporalCRS;
import org.apache.sis.coverage.grid.GridExtent;
import org.apache.sis.internal.feature.MovingFeatures;
import org.apache.sis.internal.util.Strings;
+import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.feature.builder.AttributeRole;
import org.apache.sis.feature.builder.FeatureTypeBuilder;
@@ -64,7 +65,7 @@ import org.opengis.feature.Attribute;
* It may be inefficient unless the {@link Decoder} uses a {@code
ChannelDataInput} backed by a direct buffer.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 0.8
* @module
*/
@@ -191,7 +192,7 @@ final class FeatureSet extends DiscreteSampling {
*/
private FeatureSet(final Decoder decoder, String name, final Vector
counts, final Variable[] properties,
final Variable[] dynamicProperties, final
Map<AxisType,Variable> selectedAxes,
- final boolean isTrajectory, final boolean hasTime,
final Object lock)
+ final boolean isTrajectory, final boolean hasTime,
final DataStore lock)
throws DataStoreException, IOException
{
super(decoder.geomlib, decoder.listeners, lock);
@@ -299,7 +300,7 @@ final class FeatureSet extends DiscreteSampling {
* @throws IllegalArgumentException if the geometric object library is not
available.
* @throws ArithmeticException if the size of a variable exceeds {@link
Integer#MAX_VALUE}, or other overflow occurs.
*/
- static FeatureSet[] create(final Decoder decoder, final Object lock)
throws IOException, DataStoreException {
+ static FeatureSet[] create(final Decoder decoder, final DataStore lock)
throws IOException, DataStoreException {
assert Thread.holdsLock(lock);
final List<FeatureSet> features = new ArrayList<>(3); // Will
usually contain at most one element.
final Map<Dimension,Boolean> done = new HashMap<>(); // Whether a
dimension has already been used.
@@ -387,7 +388,7 @@ final class FeatureSet extends DiscreteSampling {
*/
private static void addFeatureSet(final List<FeatureSet> features, final
Decoder decoder,
final Variable counts, final Dimension featureDimension, final
Dimension sampleDimension,
- final Object lock) throws IOException, DataStoreException
+ final DataStore lock) throws IOException, DataStoreException
{
final String featureName = featureDimension.getName();
if (featureName == null) {
diff --git
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/RasterResource.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/RasterResource.java
index 25ca8e6a05..0108f1c911 100644
---
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/RasterResource.java
+++
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/RasterResource.java
@@ -43,6 +43,7 @@ import org.apache.sis.coverage.grid.GridDerivation;
import org.apache.sis.coverage.grid.GridRoundingMode;
import org.apache.sis.coverage.IllegalSampleDimensionException;
import org.apache.sis.storage.AbstractGridCoverageResource;
+import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.DataStoreContentException;
import org.apache.sis.storage.Resource;
@@ -56,6 +57,7 @@ import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.internal.jdk9.JDK9;
import org.apache.sis.internal.storage.MetadataBuilder;
import org.apache.sis.internal.storage.RangeArgument;
+import org.apache.sis.internal.storage.StoreResource;
/**
@@ -66,11 +68,11 @@ import org.apache.sis.internal.storage.RangeArgument;
* @author Martin Desruisseaux (Geomatys)
* @author Johann Sorel (Geomatys)
* @author Alexis Manin (Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 1.0
* @module
*/
-public final class RasterResource extends AbstractGridCoverageResource
implements ResourceOnFileSystem {
+public final class RasterResource extends AbstractGridCoverageResource
implements StoreResource, ResourceOnFileSystem {
/**
* Words used in standard (preferred) or long (if no standard) variable
names which suggest
* that the variable is a component of a vector. Those words are used in
heuristic rules
@@ -168,11 +170,13 @@ public final class RasterResource extends
AbstractGridCoverageResource implement
/**
* The object to use for synchronization. For now we use a {@code
synchronized} statement,
* but it may be changed to {@link java.util.concurrent.locks.Lock} in a
future version.
+ * Current lock is the whole netCDF data store (so this field is
opportunistically used
+ * by {@link #getOriginator()}), but it may change in future version.
*
* @see DiscreteSampling#lock
* @see #getSynchronizationLock()
*/
- private final Object lock;
+ private final DataStore lock;
/**
* Creates a new resource. All variables in the {@code data} list shall
have the same domain and the same grid geometry.
@@ -186,7 +190,7 @@ public final class RasterResource extends
AbstractGridCoverageResource implement
* @param lock the lock to use in {@code synchronized(lock)}
statements.
*/
private RasterResource(final Decoder decoder, final String name, final
GridGeometry grid, final List<Variable> bands,
- final int numBands, final int bandDim, final Object lock)
+ final int numBands, final int bandDim, final DataStore lock)
{
super(decoder.listeners, false);
this.lock = lock;
@@ -210,7 +214,7 @@ public final class RasterResource extends
AbstractGridCoverageResource implement
* @throws IOException if an I/O operation was required and failed.
* @throws DataStoreException if a logical error occurred.
*/
- public static List<Resource> create(final Decoder decoder, final Object
lock) throws IOException, DataStoreException {
+ public static List<Resource> create(final Decoder decoder, final DataStore
lock) throws IOException, DataStoreException {
assert Thread.holdsLock(lock);
final Variable[] variables = decoder.getVariables().clone();
// Needs a clone because may be modified.
final List<Variable> siblings = new ArrayList<>(4);
// Usually has only 1 element, sometime 2.
@@ -749,6 +753,14 @@ public final class RasterResource extends
AbstractGridCoverageResource implement
return (location != null) ? new Path[] {location} : new Path[0];
}
+ /**
+ * Returns the data store that produced this resource.
+ */
+ @Override
+ public final DataStore getOriginator() {
+ return lock;
+ }
+
/**
* Returns the object on which to perform synchronizations for
thread-safety.
*
@@ -756,6 +768,10 @@ public final class RasterResource extends
AbstractGridCoverageResource implement
*/
@Override
protected final Object getSynchronizationLock() {
+ /*
+ * Could be replaced by `(DataStore)
listeners.getParent().get().getSource()`
+ * if a future version decides to use a different kind of lock.
+ */
return lock;
}
}
diff --git
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/package-info.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/package-info.java
index 7ee45ac926..481af98b18 100644
---
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/package-info.java
+++
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/package-info.java
@@ -38,7 +38,7 @@
* consistent vocabulary (more similar to the rest of Apache SIS).</p>
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 0.3
* @module
*/
diff --git
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
index 594713cfc9..634a3937df 100644
---
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
+++
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
@@ -51,6 +51,7 @@ import org.apache.sis.internal.netcdf.Node;
import org.apache.sis.internal.netcdf.Grid;
import org.apache.sis.internal.netcdf.DiscreteSampling;
import org.apache.sis.setup.GeometryLibrary;
+import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.event.StoreListeners;
@@ -59,7 +60,7 @@ import org.apache.sis.storage.event.StoreListeners;
* Provides netCDF decoding services based on the netCDF library.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 0.3
* @module
*/
@@ -455,7 +456,7 @@ public final class DecoderWrapper extends Decoder
implements CancelTask {
*/
@Override
@SuppressWarnings("null")
- public DiscreteSampling[] getDiscreteSampling(final Object lock) throws
IOException, DataStoreException {
+ public DiscreteSampling[] getDiscreteSampling(final DataStore lock) throws
IOException, DataStoreException {
final FeatureDataset features = getFeatureDataSet();
if (features instanceof FeatureDatasetPoint) {
final List<DsgFeatureCollection> fc = ((FeatureDatasetPoint)
features).getPointFeatureCollectionList();
diff --git
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/FeaturesWrapper.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/FeaturesWrapper.java
index cd9a7cf00c..1535c6320f 100644
---
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/FeaturesWrapper.java
+++
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/FeaturesWrapper.java
@@ -20,6 +20,7 @@ import java.util.stream.Stream;
import org.apache.sis.setup.GeometryLibrary;
import org.apache.sis.internal.netcdf.DiscreteSampling;
import org.apache.sis.storage.event.StoreListeners;
+import org.apache.sis.storage.DataStore;
import ucar.nc2.ft.DsgFeatureCollection;
// Branch-dependent imports
@@ -32,7 +33,7 @@ import org.opengis.feature.FeatureType;
* Created by {@link DecoderWrapper#getDiscreteSampling(Object)}.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.1
+ * @version 1.3
* @since 0.8
* @module
*
@@ -54,7 +55,7 @@ final class FeaturesWrapper extends DiscreteSampling {
* @throws IllegalArgumentException if the given library is non-null but
not available.
*/
FeaturesWrapper(final DsgFeatureCollection features, final GeometryLibrary
factory, final StoreListeners listeners,
- final Object lock)
+ final DataStore lock)
{
super(factory, listeners, lock);
this.features = features;
diff --git
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/package-info.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/package-info.java
index 533a1150d0..fca99358e9 100644
---
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/package-info.java
+++
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/package-info.java
@@ -20,7 +20,7 @@
* as wrappers around the UCAR netCDF library.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 0.3
* @module
*/
diff --git
a/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/FeatureSetTest.java
b/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/FeatureSetTest.java
index 5d7eefa2d5..95e9eca7c4 100644
---
a/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/FeatureSetTest.java
+++
b/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/FeatureSetTest.java
@@ -23,8 +23,10 @@ import java.util.Collection;
import java.io.IOException;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
+import java.util.Optional;
import org.opengis.referencing.crs.GeographicCRS;
import org.apache.sis.internal.feature.AttributeConvention;
+import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.test.DependsOn;
import org.junit.Test;
@@ -37,6 +39,8 @@ import org.opengis.feature.FeatureType;
import org.opengis.feature.PropertyType;
import org.opengis.feature.Attribute;
import org.opengis.feature.AttributeType;
+import org.opengis.metadata.Metadata;
+import org.opengis.parameter.ParameterValueGroup;
import org.opengis.test.dataset.TestData;
@@ -74,6 +78,17 @@ public strictfp class FeatureSetTest extends TestCase {
timeOrigin = Instant.parse("2014-11-29T00:00:00Z");
}
+ /**
+ * Returns a dummy data store implementation for the sole purpose of
providing a non-null lock.
+ */
+ private static DataStore lock() {
+ return new DataStore() {
+ @Override public Optional<ParameterValueGroup> getOpenParameters()
{return Optional.empty();}
+ @Override public Metadata getMetadata() {return null;}
+ @Override public void close() {}
+ };
+ }
+
/**
* Tests {@link FeatureSet} with a moving features file.
*
@@ -82,7 +97,7 @@ public strictfp class FeatureSetTest extends TestCase {
*/
@Test
public void testMovingFeatures() throws IOException, DataStoreException {
- final Object lock = new Object();
+ final DataStore lock = lock();
final FeatureSet[] features;
synchronized (lock) {
features =
FeatureSet.create(selectDataset(TestData.MOVING_FEATURES), lock);
diff --git
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java
index b5afcc2565..d05ca21994 100644
---
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java
+++
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java
@@ -16,16 +16,36 @@
*/
package org.apache.sis.internal.storage;
+import org.apache.sis.storage.Aggregate;
import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.Resource;
/**
- * A resource produced by a data store. This interface provides information
about which {@link DataStore}
- * produced that resource. It allows for example to fetch the parameters used
for opening the data store.
+ * A resource produced directly by a data store.
+ * This interface can be implemented by the following resources:
*
- * <p>This interface is not yet in public API. Whether we should commit this
interface in public API is an
- * open question. See <a
href="https://issues.apache.org/jira/browse/SIS-416">SIS-416</a>.</p>
+ * <ul>
+ * <li>{@link DataStore} itself, in which case {@code getOriginator()}
returns {@code this}.</li>
+ * <li>Resources returned by the {@link DataStore#findResource(String)}
method.</li>
+ * <li>If the data store is an aggregate, resources returned by {@link
Aggregate#components()}.</li>
+ * </ul>
+ *
+ * This interface should <em>not</em> be implemented by resources that are the
result of some operation,
+ * including filtering applied by {@code subset(Query)} methods.
+ *
+ * <h2>Use case</h2>
+ * This interface provides information about which {@link DataStore} produced
this resource.
+ * It allows for example to fetch the {@linkplain
DataStore#getOpenParameters() parameters}
+ * used for opening the data store. Combined with the {@linkplain
#getIdentifier() resource identifier},
+ * it makes possible to save information needed for reopening the same
resource later.
+ * This use case is the reason why this interface should be implemented only
by resources produced
+ * <em>directly</em> by a data store, because otherwise the parameters and
identifiers would not be
+ * sufficient information for identifying the resource.
+ *
+ * <h2>Future evolution</h2>
+ * This interface is not yet in public API. Whether we should commit this
interface in public API
+ * is an open question. See <a
href="https://issues.apache.org/jira/browse/SIS-416">SIS-416</a>.
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
@@ -36,6 +56,7 @@ import org.apache.sis.storage.Resource;
public interface StoreResource extends Resource {
/**
* Returns the data store that produced this resource.
+ * If this resource is already a {@link DataStore} instance, then this
method returns {@code this}.
*
* @return the data store that created this resource.
*/
diff --git
a/storage/sis-storage/src/main/java/org/apache/sis/storage/event/StoreListeners.java
b/storage/sis-storage/src/main/java/org/apache/sis/storage/event/StoreListeners.java
index c6c1164ecc..1ec498eaf7 100644
---
a/storage/sis-storage/src/main/java/org/apache/sis/storage/event/StoreListeners.java
+++
b/storage/sis-storage/src/main/java/org/apache/sis/storage/event/StoreListeners.java
@@ -20,6 +20,7 @@ import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.Locale;
+import java.util.Optional;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.logging.Level;
@@ -79,14 +80,14 @@ import org.apache.sis.storage.Resource;
* from multiple threads.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 1.0
* @module
*/
public class StoreListeners implements Localized {
/**
- * Parent manager to notify in addition to this manager.
- * This is used when a data store is created for reading components of a
larger data store.
+ * Parent set of listeners to notify in addition to this set of listeners,
or {@code null} if none.
+ * This is used when a resource is created for reading components of a
larger data store.
*/
private final StoreListeners parent;
@@ -265,6 +266,18 @@ public class StoreListeners implements Localized {
}
}
+ /**
+ * Returns the parent set of listeners that are notified in addition to
this set of listeners.
+ * This is the value of the {@code parent} argument given to the
constructor.
+ *
+ * @return parent set of listeners that are notified in addition to this
set of listeners.
+ *
+ * @since 1.3
+ */
+ public Optional<StoreListeners> getParent() {
+ return Optional.ofNullable(parent);
+ }
+
/**
* Returns the source of events. This value is specified at construction
time.
*
diff --git
a/storage/sis-storage/src/main/java/org/apache/sis/storage/event/package-info.java
b/storage/sis-storage/src/main/java/org/apache/sis/storage/event/package-info.java
index f8a7aaa8c5..eb549691b7 100644
---
a/storage/sis-storage/src/main/java/org/apache/sis/storage/event/package-info.java
+++
b/storage/sis-storage/src/main/java/org/apache/sis/storage/event/package-info.java
@@ -35,7 +35,7 @@
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @since 1.2
+ * @since 1.3
* @version 1.0
* @module
*/