sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1832243 - in /sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage: StoreResource.java URIDataStore.java folder/Store.java
Date Fri, 25 May 2018 14:29:33 GMT
Author: desruisseaux
Date: Fri May 25 14:29:33 2018
New Revision: 1832243

URL: http://svn.apache.org/viewvc?rev=1832243&view=rev
Log:
Add a StoreResource interface, only internal for now (waiting to see how it works in practice).
https://issues.apache.org/jira/browse/SIS-416

Added:
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java
  (with props)
Modified:
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java

Added: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java?rev=1832243&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java
[UTF-8] Fri May 25 14:29:33 2018
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.storage;
+
+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.
+ *
+ * <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>
+ *
+ * @author  Johann Sorel (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+public interface StoreResource extends Resource {
+    /**
+     * Returns the data store that produced this resource.
+     *
+     * @return the data store that created this resource.
+     */
+    DataStore getOriginator();
+}

Propchange: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreResource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java?rev=1832243&r1=1832242&r2=1832243&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
[UTF-8] Fri May 25 14:29:33 2018
@@ -44,7 +44,7 @@ import org.apache.sis.internal.storage.i
  * @since   0.8
  * @module
  */
-public abstract class URIDataStore extends DataStore {
+public abstract class URIDataStore extends DataStore implements StoreResource {
     /**
      * The {@link DataStoreProvider#LOCATION} parameter value, or {@code null} if none.
      */
@@ -63,6 +63,16 @@ public abstract class URIDataStore exten
     }
 
     /**
+     * Returns the originator of this resource, which is this data store itself.
+     *
+     * @return {@code this}.
+     */
+    @Override
+    public final DataStore getOriginator() {
+        return this;
+    }
+
+    /**
      * Returns the parameters used to open this data store.
      *
      * @return parameters used for opening this {@code DataStore}, or {@code null} if not
available.

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java?rev=1832243&r1=1832242&r2=1832243&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
[UTF-8] Fri May 25 14:29:33 2018
@@ -47,6 +47,7 @@ import org.apache.sis.util.collection.Ba
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.internal.storage.StoreUtilities;
+import org.apache.sis.internal.storage.StoreResource;
 import org.apache.sis.internal.storage.Resources;
 import org.apache.sis.storage.event.ChangeEvent;
 import org.apache.sis.storage.event.ChangeListener;
@@ -74,14 +75,19 @@ import org.apache.sis.storage.event.Chan
  * @since   0.8
  * @module
  */
-class Store extends DataStore implements Aggregate, DirectoryStream.Filter<Path> {
+class Store extends DataStore implements StoreResource, Aggregate, DirectoryStream.Filter<Path>
{
+    /**
+     * The data store for the root directory specified by the user.
+     */
+    private final DataStore originator;
+
     /**
      * The {@link FolderStoreProvider#LOCATION} parameter value, or {@code null} if none.
      */
     protected final Path location;
 
     /**
-     * Formating conventions of dates and numbers, or {@code null} if unspecified.
+     * Formatting conventions of dates and numbers, or {@code null} if unspecified.
      */
     protected final Locale locale;
 
@@ -147,11 +153,12 @@ class Store extends DataStore implements
             throws DataStoreException, IOException
     {
         super(provider, connector);
-        location = path;
-        locale   = connector.getOption(OptionKey.LOCALE);
-        timezone = connector.getOption(OptionKey.TIMEZONE);
-        encoding = connector.getOption(OptionKey.ENCODING);
-        children = new ConcurrentHashMap<>();
+        originator = this;
+        location   = path;
+        locale     = connector.getOption(OptionKey.LOCALE);
+        timezone   = connector.getOption(OptionKey.TIMEZONE);
+        encoding   = connector.getOption(OptionKey.ENCODING);
+        children   = new ConcurrentHashMap<>();
         children.put(path.toRealPath(), this);
         componentProvider = format;
     }
@@ -165,6 +172,7 @@ class Store extends DataStore implements
      */
     private Store(final Store parent, final StorageConnector connector) throws DataStoreException
{
         super(parent, connector);
+        originator        = parent;
         location          = connector.getStorageAs(Path.class);
         locale            = connector.getOption(OptionKey.LOCALE);
         timezone          = connector.getOption(OptionKey.TIMEZONE);
@@ -174,6 +182,14 @@ class Store extends DataStore implements
     }
 
     /**
+     * Returns the data store for the root directory specified by the user.
+     */
+    @Override
+    public DataStore getOriginator() {
+        return originator;
+    }
+
+    /**
      * Returns the parameters used to open this data store.
      */
     @Override



Mime
View raw message