sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/04: Keep longer logger configuration for DataStores, and avoid the "internal" word in logger name.
Date Sun, 08 Sep 2019 15:40:49 GMT
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 <martin.desruisseaux@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;
     }
 }


Mime
View raw message