You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2019/09/08 15:40:48 UTC
[sis] branch geoapi-4.0 updated (d756a19 -> 5aa174a)
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git.
from d756a19 Deprecate WarningListener, replaced by the more generic StoreListener. In module that do not depend on org.apache.sis.storage, use java.util.logging.Filter.
new 26e5a8a Keep longer logger configuration for DataStores, and avoid the "internal" word in logger name.
new 7663ff9 Edit project description.
new fe2cbc1 Throws an exception on attempt to use a closed StorageConnector. This is necessary for avoiding NullPointerException later.
new 5aa174a Safety against a wrong parameter type specified by user.
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/sis/metadata/MetadataCopier.java | 40 +++++++++++++++-------
pom.xml | 21 +++++-------
.../apache/sis/storage/sql/SQLStoreProvider.java | 6 +++-
.../org/apache/sis/internal/storage/Resources.java | 5 +++
.../sis/internal/storage/Resources.properties | 1 +
.../sis/internal/storage/Resources_fr.properties | 1 +
.../storage/folder/FolderStoreProvider.java | 3 +-
.../org/apache/sis/storage/DataStoreProvider.java | 19 +++++++---
.../org/apache/sis/storage/StorageConnector.java | 11 ++++--
9 files changed, 75 insertions(+), 32 deletions(-)
[sis] 04/04: Safety against a wrong parameter type specified by
user.
Posted by de...@apache.org.
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
commit 5aa174a0c2edc35f5f252bf1eef22d2922514b71
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun Sep 8 17:32:23 2019 +0200
Safety against a wrong parameter type specified by user.
---
.../org/apache/sis/metadata/MetadataCopier.java | 40 +++++++++++++++-------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataCopier.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataCopier.java
index b0ecffc..42f85a9 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataCopier.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataCopier.java
@@ -76,13 +76,6 @@ public class MetadataCopier extends MetadataVisitor<Object> {
private Object target;
/**
- * Creates a new {@code MetadataCopier} instance.
- */
- private MetadataCopier() {
- standard = null;
- }
-
- /**
* Creates a new metadata copier.
*
* @param standard the default metadata standard to use for object that are not {@link AbstractMetadata} instances,
@@ -93,6 +86,17 @@ public class MetadataCopier extends MetadataVisitor<Object> {
}
/**
+ * Returns the metadata standard to use for the given metadata object, or {@code null} if unknown.
+ */
+ private MetadataStandard getStandard(final Object metadata) {
+ if (metadata instanceof AbstractMetadata) {
+ final MetadataStandard std = ((AbstractMetadata) metadata).getStandard();
+ if (std != null) return std;
+ }
+ return standard;
+ }
+
+ /**
* Creates a new metadata copier which avoid copying unmodifiable metadata.
* More specifically, any {@link ModifiableMetadata} instance in
* {@linkplain ModifiableMetadata.State#FINAL final state} will be kept <i>as-is</i>;
@@ -134,6 +138,9 @@ public class MetadataCopier extends MetadataVisitor<Object> {
/**
* Performs a potentially deep copy of the given metadata object.
* This method is preferred to {@link #copy(Object)} when the type is known.
+ * The specified type should be an interface, not an implementation
+ * (for example {@link org.opengis.metadata.Metadata}, not
+ * {@link org.apache.sis.metadata.iso.DefaultMetadata}).
*
* @param <T> compile-time value of the {@code type} argument.
* @param type the interface of the metadata object to copy.
@@ -144,7 +151,19 @@ public class MetadataCopier extends MetadataVisitor<Object> {
*/
public <T> T copy(final Class<T> type, final T metadata) {
ArgumentChecks.ensureNonNull("type", type);
- return type.cast(copyRecursively(type, metadata));
+ Class<?> interfaceType = type;
+ if (interfaceType != null) {
+ final MetadataStandard std = getStandard(metadata);
+ if (std != null) {
+ /*
+ * In case the user specified an implementation despite the documentation warning.
+ * It will work most of the time, but may also result in a ClassCastException thrown
+ * at the end of this method. But the user has bee warned.
+ */
+ interfaceType = std.getInterface(type);
+ }
+ }
+ return type.cast(copyRecursively(interfaceType, metadata));
}
/**
@@ -163,10 +182,7 @@ public class MetadataCopier extends MetadataVisitor<Object> {
*/
protected Object copyRecursively(final Class<?> type, final Object metadata) {
if (metadata != null) {
- MetadataStandard std = standard;
- if (metadata instanceof AbstractMetadata) {
- std = ((AbstractMetadata) metadata).getStandard();
- }
+ final MetadataStandard std = getStandard(metadata);
if (std != null) {
final Object result = walk(std, type, metadata, false);
if (result != null) {
[sis] 01/04: Keep longer logger configuration for DataStores,
and avoid the "internal" word in logger name.
Posted by de...@apache.org.
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
commit 26e5a8ad923f2674e62f7507ded1f310f7cd3653
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun Sep 8 15:55:27 2019 +0200
Keep longer logger configuration for DataStores, and avoid the "internal" word in logger name.
---
.../org/apache/sis/storage/sql/SQLStoreProvider.java | 6 +++++-
.../internal/storage/folder/FolderStoreProvider.java | 3 ++-
.../org/apache/sis/storage/DataStoreProvider.java | 19 +++++++++++++++----
3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStoreProvider.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStoreProvider.java
index a03a1b2..d5b8cbe 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStoreProvider.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStoreProvider.java
@@ -30,6 +30,8 @@ import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterNotFoundException;
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.sql.feature.Resources;
+import org.apache.sis.internal.storage.Capability;
+import org.apache.sis.internal.storage.StoreMetadata;
import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreProvider;
import org.apache.sis.storage.DataStoreException;
@@ -53,11 +55,13 @@ import static org.apache.sis.internal.sql.feature.Database.WILDCARD;
* @since 1.0
* @module
*/
+@StoreMetadata(formatName = SQLStoreProvider.NAME,
+ capabilities = Capability.READ)
public class SQLStoreProvider extends DataStoreProvider {
/**
* The format name.
*/
- private static final String NAME = "SQL";
+ static final String NAME = "SQL";
/**
* Name of the parameter for the list of qualified table names.
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
index 9f8f707..6e3d5a4 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
@@ -60,7 +60,8 @@ import org.apache.sis.setup.OptionKey;
* @since 0.8
* @module
*/
-@StoreMetadata(formatName=FolderStoreProvider.NAME, capabilities={Capability.READ, Capability.WRITE})
+@StoreMetadata(formatName = FolderStoreProvider.NAME,
+ capabilities = {Capability.READ, Capability.WRITE})
public final class FolderStoreProvider extends DataStoreProvider {
/**
* A short name or abbreviation for the data format.
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
index 09a7e4a..fd206c5 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
@@ -110,6 +110,16 @@ public abstract class DataStoreProvider {
public static final String CREATE = "create";
/**
+ * The logger where to reports warnings or change events. Created when first needed and kept
+ * by strong reference for avoiding configuration lost if the logger if garbage collected.
+ * This strategy assumes that {@code URIDataStore.Provider} instances are kept alive for
+ * the duration of JVM lifetime, which is the case with {@link DataStoreRegistry}.
+ *
+ * @see #getLogger()
+ */
+ private volatile Logger logger;
+
+ /**
* Creates a new provider.
*/
protected DataStoreProvider() {
@@ -339,9 +349,10 @@ public abstract class DataStoreProvider {
* @since 1.0
*/
public Logger getLogger() {
- String name = getClass().getName();
- final int separator = name.lastIndexOf('.');
- name = (separator >= 1) ? name.substring(0, separator) : "";
- return Logging.getLogger(name);
+ Logger lg = logger;
+ if (lg == null) {
+ logger = lg = Logging.getLogger(getClass());
+ }
+ return lg;
}
}
[sis] 02/04: Edit project description.
Posted by de...@apache.org.
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
commit 7663ff9dc4f92ea4ca56477e8cfe037248a20371
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun Sep 8 16:51:43 2019 +0200
Edit project description.
---
pom.xml | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/pom.xml b/pom.xml
index ceba5e8..0197a32 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,16 +55,13 @@
<name>Apache SIS</name>
<url>http://sis.apache.org</url>
<description>
- Apache SIS is a free software, Java language library for developing geospatial applications.
- SIS provides data structures for geographic data and associated metadata along with methods
- to manipulate those data structures. The SIS metadata module forms the base of the library
- and enables the creation of metadata objects which comply with the ISO 19115 metadata model
- and which can be read from or written to ISO 19115-3 compliant XML documents.
- The SIS referencing module will enable the construction of geodetic data structures for
- geospatial referencing based on the ISO 19111 model such as axis, projection and coordinate
- reference system definitions, along with the associated operations which enable the mathematical
- conversion of coordinates between different systems of reference.
- The SIS storage modules will provide a common approach to the reading and writing of grid coverages
+ Apache Spatial Information System (SIS) is a free software, Java language library for developing geospatial applications.
+ SIS provides data structures for geographic features and associated metadata along with methods to manipulate those data structures.
+ The library is an implementation of GeoAPI 3.0.1 interfaces and can be used for desktop or server applications.
+ The SIS metadata module forms the base of the library and enables the creation of metadata objects which comply with the ISO 19115 international standard.
+ The SIS referencing module enable the construction of geodetic data structures for geospatial referencing as defined by ISO 19111 standard,
+ along with the associated operations which enable the transformation of coordinates between different reference systems.
+ The SIS storage modules provide a common approach to the reading and writing of metadata, features and coverages
applicable to simple imagery as to many dimensional data structures.
</description>
<inceptionYear>2010</inceptionYear>
@@ -86,7 +83,7 @@
<ciManagement>
<system>jenkins</system>
- <url>https://builds.apache.org/job/sis-dev</url>
+ <url>https://builds.apache.org/job/sis</url>
</ciManagement>
<issueManagement>
@@ -524,7 +521,7 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.22</version> <!-- Must matches the version used by netCDF. -->
- <scope>runtime</scope> <!-- Should never be needed at compile time. -->
+ <scope>test</scope> <!-- Should never be needed at compile time. -->
</dependency>
</dependencies>
</dependencyManagement>
[sis] 03/04: Throws an exception on attempt to use a closed
StorageConnector. This is necessary for avoiding NullPointerException
later.
Posted by de...@apache.org.
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
commit fe2cbc1694d4c531c87b6cd11b135d598e122a82
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun Sep 8 17:07:41 2019 +0200
Throws an exception on attempt to use a closed StorageConnector.
This is necessary for avoiding NullPointerException later.
---
.../main/java/org/apache/sis/internal/storage/Resources.java | 5 +++++
.../java/org/apache/sis/internal/storage/Resources.properties | 1 +
.../org/apache/sis/internal/storage/Resources_fr.properties | 1 +
.../main/java/org/apache/sis/storage/StorageConnector.java | 11 +++++++++--
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
index 03bc371..c062fab 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
@@ -122,6 +122,11 @@ public final class Resources extends IndexedResourceBundle {
public static final short ClosedReader_1 = 4;
/**
+ * This storage connector is closed.
+ */
+ public static final short ClosedStorageConnector = 56;
+
+ /**
* This {0} writer is closed.
*/
public static final short ClosedWriter_1 = 5;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
index a6d6ecc..39a707a 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
@@ -30,6 +30,7 @@ CanNotReadFile_3 = Can not read line {2} of \u201c{1}\u201d as
CanNotReadFile_4 = Can not read after column {3} of line {2} of \u201c{1}\u201d as part of a file in the {0} format.
CanNotRemoveResource_2 = Can not remove resource \u201c{1}\u201d from aggregate \u201c{0}\u201d.
CanNotStoreResourceType_2 = Can not save resources of type \u2018{1}\u2019 in a \u201c{0}\u201d store.
+ClosedStorageConnector = This storage connector is closed.
ClosedReader_1 = This {0} reader is closed.
ClosedWriter_1 = This {0} writer is closed.
ConcurrentRead_1 = One or more read operations are in progress in the \u201c{0}\u201d data store.
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
index 6fbc132..0294938 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
@@ -35,6 +35,7 @@ CanNotReadFile_3 = Ne peut pas lire la ligne {2} de \u00ab\u202
CanNotReadFile_4 = Ne peut pas lire apr\u00e8s la colonne {3} de la ligne {2} de \u00ab\u202f{1}\u202f\u00bb comme une partie d\u2019un fichier au format {0}.
CanNotRemoveResource_2 = Ne peut pas supprimer la ressource \u00ab\u202f{1}\u202f\u00bb de l\u2019agr\u00e9gat \u00ab\u202f{0}\u202f\u00bb.
CanNotStoreResourceType_2 = Ne peut pas enregistrer des ressources de type \u2018{1}\u2019 dans un entrep\u00f4t de donn\u00e9es \u00ab\u202f{0}\u202f\u00bb.
+ClosedStorageConnector = Ce connecteur est ferm\u00e9.
ClosedReader_1 = Ce lecteur {0} est ferm\u00e9.
ClosedWriter_1 = Cet encodeur {0} est ferm\u00e9.
ConcurrentRead_1 = Une ou plusieurs op\u00e9rations de lecture sont en cours sur les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
index 363177d..8f0521c 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
@@ -86,7 +86,7 @@ import org.apache.sis.setup.OptionKey;
* is serializable.</p>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -225,8 +225,9 @@ public class StorageConnector implements Serializable {
private Map<OptionKey<?>, Object> options;
/**
- * Views of {@link #storage} as instances of different types than the type of the object given to the constructor.
+ * Views of {@link #storage} as instances of types different than the type of the object given to the constructor.
* The {@code null} reference can appear in various places:
+ *
* <ul>
* <li>A non-existent entry (equivalent to an entry associated to the {@code null} value) means that the value
* has not yet been computed.</li>
@@ -236,6 +237,8 @@ public class StorageConnector implements Serializable {
* <li>By convention, the {@code null} key is associated to the {@link #storage} value.</li>
* </ul>
*
+ * An empty map means that this {@code StorageConnector} has been closed.
+ *
* @see #addView(Class, Object, Class, byte)
* @see #getView(Class)
* @see #getStorageAs(Class)
@@ -757,6 +760,7 @@ public class StorageConnector implements Serializable {
* types listed in javadoc but no view can be created for the source given at construction time.
* @throws IllegalArgumentException if the given {@code type} argument is not one of the supported types
* listed in this javadoc or in subclass javadoc.
+ * @throws IllegalStateException if this {@code StorageConnector} has been {@linkplain #closeAllExcept closed}.
* @throws DataStoreException if an error occurred while opening a stream or database connection.
*
* @see #getStorage()
@@ -764,6 +768,9 @@ public class StorageConnector implements Serializable {
*/
public <T> T getStorageAs(final Class<T> type) throws IllegalArgumentException, DataStoreException {
ArgumentChecks.ensureNonNull("type", type);
+ if (views != null && views.isEmpty()) {
+ throw new IllegalStateException(Resources.format(Resources.Keys.ClosedStorageConnector));
+ }
/*
* Verify if the cache contains an instance created by a previous invocation of this method.
* Note that InputStream may need to be reseted if it has been used indirectly by other kind