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 362154b28d Remove usage of `org.opengis.temporal.TemporalFactory`. The 
latter was related to ISO 19108, which has not been updated since 2002, 
overlaps with `java.time`, overlaps with ISO 19111 and may overlap with the 
ongoing work in OGC temporal working group.
362154b28d is described below

commit 362154b28d64d0fcd910017790c6763279e5c20c
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Thu May 9 11:26:48 2024 +0200

    Remove usage of `org.opengis.temporal.TemporalFactory`.
    The latter was related to ISO 19108, which has not been updated since 2002,
    overlaps with `java.time`, overlaps with ISO 19111 and may overlap with the
    ongoing work in OGC temporal working group.
---
 .../org.apache.sis.metadata/main/module-info.java  |  1 -
 .../sis/metadata/iso/extent/DefaultExtent.java     |  2 -
 .../metadata/iso/extent/DefaultTemporalExtent.java |  4 +-
 .../apache/sis/metadata/iso/extent/Extents.java    |  4 --
 .../metadata/iso/lineage/DefaultProcessStep.java   |  2 +-
 .../apache/sis/pending/temporal/DefaultPeriod.java |  7 +++
 .../org/apache/sis/pending/temporal/Primitive.java | 13 ++---
 .../temporal}/TemporalUtilities.java               | 59 ++++-----------------
 .../apache/sis/pending/temporal/package-info.java  |  6 ++-
 .../org/apache/sis/xml/bind/gml/TM_Primitive.java  |  2 +-
 .../src/org.apache.sis.util/main/module-info.java  |  3 --
 .../pending/temporal/DefaultTemporalFactory.java   | 60 ----------------------
 geoapi/snapshot                                    |  2 +-
 13 files changed, 28 insertions(+), 137 deletions(-)

diff --git a/endorsed/src/org.apache.sis.metadata/main/module-info.java 
b/endorsed/src/org.apache.sis.metadata/main/module-info.java
index 0105a2f2f9..fdb3d50d7c 100644
--- a/endorsed/src/org.apache.sis.metadata/main/module-info.java
+++ b/endorsed/src/org.apache.sis.metadata/main/module-info.java
@@ -52,7 +52,6 @@ module org.apache.sis.metadata {
     uses org.apache.sis.metadata.sql.privy.Initializer;
     uses org.apache.sis.xml.bind.AdapterReplacement;
     uses org.apache.sis.xml.bind.TypeRegistration;
-    uses org.opengis.temporal.TemporalFactory;
 
     /*
      * Public API open to everyone.
diff --git 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultExtent.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultExtent.java
index fa0dfbb2d8..d89ea059ba 100644
--- 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultExtent.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultExtent.java
@@ -323,8 +323,6 @@ public class DefaultExtent extends ISOMetadata implements 
Extent {
      * @throws IllegalArgumentException if two elements to intersect are not 
compatible (e.g. mismatched
      *         {@linkplain DefaultGeographicBoundingBox#getInclusion() 
bounding box inclusion status} or
      *         mismatched {@linkplain DefaultVerticalExtent#getVerticalCRS() 
vertical datum}).
-     * @throws UnsupportedOperationException if a {@code TemporalFactory} is 
required but no implementation
-     *         has been found on the module path.
      *
      * @see Extents#intersection(Extent, Extent)
      * @see org.apache.sis.geometry.GeneralEnvelope#intersect(Envelope)
diff --git 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
index cd5dd14d9a..cff6577ffc 100644
--- 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
@@ -27,8 +27,8 @@ import org.opengis.metadata.extent.TemporalExtent;
 import org.opengis.metadata.extent.SpatialTemporalExtent;
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.metadata.iso.ISOMetadata;
-import org.apache.sis.metadata.privy.TemporalUtilities;
 import org.apache.sis.metadata.privy.ReferencingServices;
+import org.apache.sis.pending.temporal.TemporalUtilities;
 import org.apache.sis.xml.NilObject;
 import org.apache.sis.xml.NilReason;
 
@@ -242,8 +242,6 @@ public class DefaultTemporalExtent extends ISOMetadata 
implements TemporalExtent
      * If either this extent or the specified extent has nil primitive, then 
the intersection result will also be nil.
      *
      * @param  other  the temporal extent to intersect with this extent.
-     * @throws UnsupportedOperationException if no implementation of {@code 
TemporalFactory} has been found
-     *         on the module path.
      *
      * @see Extents#intersection(TemporalExtent, TemporalExtent)
      * @see org.apache.sis.geometry.GeneralEnvelope#intersect(Envelope)
diff --git 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java
index 14478406e7..2459f6ce53 100644
--- 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/Extents.java
@@ -736,8 +736,6 @@ public final class Extents extends Static {
      * @param  e2  the second extent, or {@code null}.
      * @return the intersection (may be any of the {@code e1} or {@code e2} 
argument if unchanged),
      *         or {@code null} if the two given extents are null.
-     * @throws UnsupportedOperationException if no implementation of {@code 
TemporalFactory} has been found
-     *         on the module path.
      *
      * @see DefaultTemporalExtent#intersect(TemporalExtent)
      *
@@ -766,8 +764,6 @@ public final class Extents extends Static {
      * @throws IllegalArgumentException if two elements to intersect are not 
compatible (e.g. mismatched
      *         {@linkplain DefaultGeographicBoundingBox#getInclusion() 
bounding box inclusion status} or
      *         mismatched {@linkplain DefaultVerticalExtent#getVerticalCRS() 
vertical datum}).
-     * @throws UnsupportedOperationException if a {@code TemporalFactory} is 
required but no implementation
-     *         has been found on the module path.
      *
      * @see DefaultExtent#intersect(Extent)
      *
diff --git 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
index 7762e52c8c..861ad6a85d 100644
--- 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
@@ -37,7 +37,7 @@ import org.apache.sis.xml.bind.FilterByVersion;
 import org.apache.sis.xml.privy.LegacyNamespaces;
 import org.apache.sis.xml.bind.gml.TM_Primitive;
 import org.apache.sis.xml.bind.metadata.MD_Scope;
-import org.apache.sis.metadata.privy.TemporalUtilities;
+import org.apache.sis.pending.temporal.TemporalUtilities;
 
 // Specific to the geoapi-3.1 and geoapi-4.0 branches:
 import org.opengis.metadata.maintenance.Scope;
diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultPeriod.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/DefaultPeriod.java
similarity index 89%
rename from 
endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultPeriod.java
rename to 
endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/DefaultPeriod.java
index 1973da502c..12a7573630 100644
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultPeriod.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/DefaultPeriod.java
@@ -20,6 +20,8 @@ import java.util.Objects;
 
 // Specific to the geoapi-3.1 and geoapi-4.0 branches:
 import java.time.Instant;
+import java.time.Duration;
+import java.time.temporal.TemporalAmount;
 import org.opengis.temporal.Period;
 
 
@@ -49,6 +51,11 @@ final class DefaultPeriod extends Primitive implements 
Period {
         return ending;
     }
 
+    /** Duration of this temporal geometric primitive. */
+    @Override public TemporalAmount length() {
+        return (beginning != null && ending != null) ? 
Duration.between(beginning, ending) : null;
+    }
+
     /** String representation. */
     @Override public String toString() {
         return "[" + beginning + " … " + ending + ']';
diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/Primitive.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/Primitive.java
similarity index 84%
rename from 
endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/Primitive.java
rename to 
endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/Primitive.java
index 0287791d12..d8c284e1dd 100644
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/Primitive.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/Primitive.java
@@ -31,7 +31,7 @@ import org.opengis.metadata.Identifier;
  *
  * @author  Martin Desruisseaux (Geomatys)
  */
-class Primitive implements TemporalGeometricPrimitive, Identifier {
+abstract class Primitive implements TemporalGeometricPrimitive, Identifier {
     /**
      * For sub-class constructors.
      */
@@ -57,18 +57,13 @@ class Primitive implements TemporalGeometricPrimitive, 
Identifier {
         return toString();
     }
 
-    /** position of this primitive relative to another primitive. */
+    /** Position of this primitive relative to another primitive. */
     @Override public final RelativePosition relativePosition(TemporalPrimitive 
other) {
-        throw DefaultTemporalFactory.unsupported();
+        throw new UnsupportedOperationException();
     }
 
     /** Absolute value of the difference between temporal positions. */
     @Override public final TemporalAmount distance(TemporalGeometricPrimitive 
other) {
-        throw DefaultTemporalFactory.unsupported();
-    }
-
-    /** Duration of this temporal geometric primitive. */
-    @Override public final TemporalAmount length() {
-        return null;    // Do not throw an exception here; this is invoked by 
reflection.
+        throw new UnsupportedOperationException();
     }
 }
diff --git 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/TemporalUtilities.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/TemporalUtilities.java
similarity index 65%
rename from 
endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/TemporalUtilities.java
rename to 
endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/TemporalUtilities.java
index ee30445316..8c7b1dac7c 100644
--- 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/privy/TemporalUtilities.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/TemporalUtilities.java
@@ -14,67 +14,27 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.metadata.privy;
+package org.apache.sis.pending.temporal;
 
 import java.util.Date;
-import java.util.ServiceLoader;
 import org.opengis.temporal.TemporalPrimitive;
-import org.apache.sis.system.Modules;
-import org.apache.sis.system.Reflect;
-import org.apache.sis.system.SystemListener;
-import org.apache.sis.pending.temporal.DefaultTemporalFactory;
 
 // Specific to the geoapi-3.1 and geoapi-4.0 branches:
 import java.time.Instant;
 import org.opengis.temporal.Period;
-import org.opengis.temporal.TemporalFactory;
 
 
 /**
- * Utilities related to ISO 19108 objects. This class may disappear after we 
reviewed
- * the GeoAPI-pending temporal interfaces.
+ * Utilities related to ISO 19108 objects.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Guilhem Legal (Geomatys)
  */
-public final class TemporalUtilities extends SystemListener {
+public final class TemporalUtilities {
     /**
-     * The default factory to use for implementations.
-     */
-    private static volatile TemporalFactory implementation;
-
-    static {
-        SystemListener.add(new TemporalUtilities());
-    }
-
-    /**
-     * For the singleton system listener only.
+     * Do not allow instantiation of this class.
      */
     private TemporalUtilities() {
-        super(Modules.METADATA);
-    }
-
-    /**
-     * Discards the cached factory when the module path has changed.
-     */
-    @Override
-    protected void classpathChanged() {
-        implementation = null;
-    }
-
-    /**
-     * Returns a temporal factory, or a default implementation if none.
-     *
-     * @return the temporal factory.
-     */
-    private static TemporalFactory getTemporalFactory() {
-        TemporalFactory factory = implementation;
-        if (factory == null) {
-            factory = ServiceLoader.load(TemporalFactory.class, 
Reflect.getContextClassLoader())
-                    .findFirst().orElseGet(DefaultTemporalFactory::provider);
-            implementation = factory;
-        }
-        return factory;
     }
 
     /**
@@ -87,21 +47,20 @@ public final class TemporalUtilities extends SystemListener 
{
     public static TemporalPrimitive createInstant(final Date time) throws 
UnsupportedOperationException {
         if (time == null) return null;
         final Instant t = time.toInstant();
-        return getTemporalFactory().createPeriod(t, t);
+        return new DefaultPeriod(t, t);
     }
 
     /**
-     * Creates a period for the given begin and end dates. The given arguments 
can be null if the
-     * {@link TemporalFactory} methods accept null instants, which stand for 
undetermined position.
+     * Creates a period for the given begin and end dates.
      *
-     * @param  begin  the begin date, inclusive.
-     * @param  end    the end date, inclusive.
+     * @param  begin  the begin date (inclusive), or {@code null}.
+     * @param  end    the end date (inclusive), or {@code null}.
      * @return the period, or {@code null} if both arguments are null.
      * @throws UnsupportedOperationException if the temporal factory is not 
available on the module path.
      */
     public static TemporalPrimitive createPeriod(final Date begin, final Date 
end) throws UnsupportedOperationException {
         if (begin == null && end == null) return null;
-        return getTemporalFactory().createPeriod(
+        return new DefaultPeriod(
                 (begin != null) ? begin.toInstant() : null,
                   (end != null) ?   end.toInstant() : null);
     }
diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/package-info.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/package-info.java
similarity index 73%
rename from 
endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/package-info.java
rename to 
endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/package-info.java
index 06ff786284..bc684a2a97 100644
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/package-info.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/package-info.java
@@ -16,8 +16,10 @@
  */
 
 /**
- * Place-holder for a future "sis-temporal" module. This is a temporary 
package;
- * the temporal GeoAPI interfaces are expected to change a lot in a future 
revision.
+ * Place-holder for a future implementation of {@code org.opengis.temporal} 
interfaces.
+ * Those interfaces should be derived from ISO 19108, but they overlap with 
{@code java.time} standard API.
+ * Furthermore, the ISO 19108 standard also overlaps with ISO 19111. How to 
resolve those overlaps has not
+ * yet been decided.
  *
  * @author  Martin Desruisseaux (Geomatys)
  */
diff --git 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
index edea96f9cb..c7a23ec8e8 100644
--- 
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
+++ 
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java
@@ -22,7 +22,7 @@ import org.opengis.temporal.TemporalPrimitive;
 import org.apache.sis.xml.privy.XmlUtilities;
 import org.apache.sis.xml.bind.Context;
 import org.apache.sis.xml.bind.gco.PropertyType;
-import org.apache.sis.metadata.privy.TemporalUtilities;
+import org.apache.sis.pending.temporal.TemporalUtilities;
 import org.apache.sis.util.resources.Errors;
 
 // Specific to the geoapi-3.1 and geoapi-4.0 branches:
diff --git a/endorsed/src/org.apache.sis.util/main/module-info.java 
b/endorsed/src/org.apache.sis.util/main/module-info.java
index 10c920ec57..6391f7b34d 100644
--- a/endorsed/src/org.apache.sis.util/main/module-info.java
+++ b/endorsed/src/org.apache.sis.util/main/module-info.java
@@ -128,9 +128,6 @@ module org.apache.sis.util {
             org.apache.sis.referencing.epsg,            // In the "non-free" 
sub-project.
             org.apache.sis.referencing.database;        // In the "non-free" 
sub-project.
 
-    exports org.apache.sis.pending.temporal to
-            org.apache.sis.metadata;
-
     exports org.apache.sis.converter to
             org.apache.sis.metadata,
             org.apache.sis.referencing,
diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultTemporalFactory.java
 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultTemporalFactory.java
deleted file mode 100644
index b52df00f46..0000000000
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/temporal/DefaultTemporalFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.pending.temporal;
-
-import java.time.Instant;
-
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.temporal.*;
-import org.opengis.referencing.crs.TemporalCRS;
-import org.apache.sis.util.resources.Errors;
-
-
-/**
- * Default implementation of temporal object factory. This is a temporary 
class;
- * GeoAPI temporal interfaces are expected to change a lot in a future 
revision.
- *
- * @author  Martin Desruisseaux (Geomatys)
- */
-public final class DefaultTemporalFactory implements TemporalFactory {
-    /** The unique instance of this factory. */
-    private static final TemporalFactory INSTANCE = new 
DefaultTemporalFactory();
-
-    /** {@return the unique instance of this factory}. */
-    public static TemporalFactory provider() {
-        return INSTANCE;
-    }
-
-    /** Creates the singleton instance. */
-    private DefaultTemporalFactory() {
-    }
-
-    /** Creates a period for the two given instants. */
-    @Override public Period createPeriod(Instant begin, Instant end) {
-        return new DefaultPeriod(begin, end);
-    }
-
-    /** Returns the exception to be thrown by all unsupported methods. */
-    static UnsupportedOperationException unsupported() {
-        return new 
UnsupportedOperationException(Errors.format(Errors.Keys.MissingRequiredModule_1,
 "sis-temporal"));
-    }
-
-    /** Unsupported. */
-    @Override public TemporalPosition createTemporalPosition(TemporalCRS tcrs, 
IndeterminateValue iv) {
-        throw unsupported();
-    }
-}
diff --git a/geoapi/snapshot b/geoapi/snapshot
index 268b27c27d..76470c0640 160000
--- a/geoapi/snapshot
+++ b/geoapi/snapshot
@@ -1 +1 @@
-Subproject commit 268b27c27dcc3b034dd7621a682bc4d432511f11
+Subproject commit 76470c06402aba756ce77dd98a0d36e4e2abcb14

Reply via email to