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 9f079c7e510e46b0dfe3f09d5db4607a93fe520f Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sun Jan 15 19:41:49 2023 +0100 Move the `Configuration` annotation to internal package. Apply the annotation on some static constants worth to know that they can be changed. https://issues.apache.org/jira/browse/SIS-86 --- .../main/java/org/apache/sis/gui/RecentFiles.java | 2 + .../org/apache/sis/gui/dataset/FeatureLoader.java | 2 + .../java/org/apache/sis/gui/map/MapCanvasAWT.java | 3 + .../org/apache/sis/internal/gui/LogHandler.java | 2 + .../org/apache/sis/internal/gui/RecentChoices.java | 2 + .../org/apache/sis/coverage/SampleRangeFormat.java | 2 + .../java/org/apache/sis/image/ResamplingGrid.java | 2 + .../sis/internal/coverage/j2d/ImageLayout.java | 4 + .../sis/internal/coverage/j2d/ImageUtilities.java | 4 + .../sis/internal/metadata/sql/Initializer.java | 4 +- .../org/apache/sis/metadata/MetadataStandard.java | 2 + .../apache/sis/metadata/sql/MetadataSource.java | 3 + .../coverage/MultiResolutionCoverageLoader.java | 2 + .../org/apache/sis/portrayal/CanvasContext.java | 2 + .../sis/internal/referencing/Arithmetic.java | 2 + .../apache/sis/internal/referencing/Formulas.java | 8 +- .../referencing/PositionalAccuracyConstant.java | 4 + .../main/java/org/apache/sis/io/wkt/Formatter.java | 3 + .../sis/referencing/GeodesicsOnEllipsoid.java | 6 +- .../factory/ConcurrentAuthorityFactory.java | 10 ++- .../sis/referencing/factory/ReferenceKeeper.java | 3 + .../DefaultCoordinateOperationFactory.java | 2 + .../operation/builder/LocalizationGridBuilder.java | 2 + .../operation/builder/ProjectedTransformTry.java | 12 +-- .../operation/matrix/GeneralMatrix.java | 4 + .../operation/projection/TransverseMercator.java | 2 + .../operation/transform/InterpolatedTransform.java | 3 + .../apache/sis/internal/system/CommonExecutor.java | 1 + .../apache/sis/internal/system/Configuration.java | 91 ++++++++++++++++++++++ .../org/apache/sis/internal/system/Supervisor.java | 6 +- .../org/apache/sis/internal/util/DoubleDouble.java | 4 + .../org/apache/sis/internal/util/Numerics.java | 3 + .../src/main/java/org/apache/sis/math/Plane.java | 2 + .../java/org/apache/sis/measure/AbstractUnit.java | 2 + .../java/org/apache/sis/measure/UnitFormat.java | 2 + .../java/org/apache/sis/setup/Configuration.java | 11 ++- .../java/org/apache/sis/util/Configuration.java | 44 ----------- .../java/org/apache/sis/util/logging/Logging.java | 2 + .../apache/sis/util/logging/MonolineFormatter.java | 7 +- .../apache/sis/util/logging/PerformanceLevel.java | 7 +- .../sis/util/resources/IndexedResourceBundle.java | 2 + ide-project/NetBeans/nbproject/genfiles.properties | 4 +- ide-project/NetBeans/nbproject/project.xml | 1 + .../org/apache/sis/internal/netcdf/FeatureSet.java | 2 + .../apache/sis/storage/netcdf/MetadataReader.java | 2 + .../sis/internal/storage/StoreUtilities.java | 2 + .../org/apache/sis/storage/StorageConnector.java | 8 +- 47 files changed, 230 insertions(+), 70 deletions(-) diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/RecentFiles.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/RecentFiles.java index 9535ffde4a..0bccac802e 100644 --- a/application/sis-javafx/src/main/java/org/apache/sis/gui/RecentFiles.java +++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/RecentFiles.java @@ -28,6 +28,7 @@ import org.apache.sis.gui.dataset.ResourceEvent; import org.apache.sis.gui.dataset.ResourceExplorer; import org.apache.sis.internal.gui.Resources; import org.apache.sis.internal.gui.RecentChoices; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.util.ArraysExt; @@ -42,6 +43,7 @@ final class RecentFiles implements EventHandler<ActionEvent> { /** * Maximum number of items to show. */ + @Configuration static final int MAX_COUNT = 10; /** diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureLoader.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureLoader.java index 1fa4c895e2..65af557681 100644 --- a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureLoader.java +++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureLoader.java @@ -29,6 +29,7 @@ import org.apache.sis.storage.FeatureSet; import org.apache.sis.storage.DataStoreException; import org.apache.sis.util.collection.BackingStoreException; import org.apache.sis.internal.gui.Resources; +import org.apache.sis.internal.system.Configuration; /** @@ -47,6 +48,7 @@ final class FeatureLoader extends Task<Boolean> implements Consumer<Feature> { * * @see FeatureList#nextPageLoader */ + @Configuration private static final int PAGE_SIZE = 100; /** diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvasAWT.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvasAWT.java index a497028403..ee90198bd7 100644 --- a/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvasAWT.java +++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvasAWT.java @@ -43,6 +43,7 @@ import javafx.beans.property.SimpleObjectProperty; import javafx.concurrent.Task; import javafx.util.Callback; import org.apache.sis.internal.coverage.j2d.ColorModelFactory; +import org.apache.sis.internal.system.Configuration; /** @@ -64,6 +65,7 @@ public abstract class MapCanvasAWT extends MapCanvas { * back to video card memory. I'm not aware of a way to perform direct transfer from AWT to JavaFX. * Consequently before to enable this acceleration, we should benchmark to see if it is worth. */ + @Configuration private static final boolean NATIVE_ACCELERATION = false; /** @@ -79,6 +81,7 @@ public abstract class MapCanvasAWT extends MapCanvas { /** * Default value of {@link #imageMargin}. */ + @Configuration private static final Insets DEFAULT_MARGIN = new Insets(SCROLL_EVENT_SIZE); /** diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/LogHandler.java b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/LogHandler.java index 7a87b9919f..17dd5a95cc 100644 --- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/LogHandler.java +++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/LogHandler.java @@ -33,6 +33,7 @@ import org.apache.sis.storage.DataStore; import org.apache.sis.storage.Resource; import org.apache.sis.storage.event.StoreListener; import org.apache.sis.storage.event.WarningEvent; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.util.resources.Vocabulary; import org.apache.sis.util.CharSequences; @@ -49,6 +50,7 @@ public final class LogHandler extends Handler implements StoreListener<WarningEv /** * Maximal number of log records stored by this class. */ + @Configuration private static final int LIMIT = 1000; /** diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/RecentChoices.java b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/RecentChoices.java index 76441c4972..f539cd4a49 100644 --- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/RecentChoices.java +++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/RecentChoices.java @@ -25,6 +25,7 @@ import javafx.scene.control.ComboBox; import javafx.collections.ObservableList; import org.apache.sis.util.CharSequences; import org.apache.sis.util.collection.FrequencySortedSet; +import org.apache.sis.internal.system.Configuration; /** @@ -42,6 +43,7 @@ public final class RecentChoices { * * @see #useReferenceSystem(String) */ + @Configuration public static final int MAXIMUM_REFERENCE_SYSTEMS = 20; /** diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/SampleRangeFormat.java b/core/sis-feature/src/main/java/org/apache/sis/coverage/SampleRangeFormat.java index 06ef7c6f49..30b54efefa 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/coverage/SampleRangeFormat.java +++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/SampleRangeFormat.java @@ -26,6 +26,7 @@ import org.apache.sis.io.TableAppender; import org.apache.sis.measure.Range; import org.apache.sis.measure.RangeFormat; import org.apache.sis.internal.util.Numerics; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.measure.NumberRange; import org.apache.sis.measure.MeasurementRange; import org.apache.sis.util.resources.Vocabulary; @@ -44,6 +45,7 @@ final class SampleRangeFormat extends RangeFormat { * Maximum value for {@link #numFractionDigits}. This is the number * of significant digits to allow when formatting real values. */ + @Configuration private static final int MAX_DIGITS = 6; /** diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/ResamplingGrid.java b/core/sis-feature/src/main/java/org/apache/sis/image/ResamplingGrid.java index e717583931..5c4c30f962 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/image/ResamplingGrid.java +++ b/core/sis-feature/src/main/java/org/apache/sis/image/ResamplingGrid.java @@ -28,6 +28,7 @@ import org.apache.sis.referencing.operation.matrix.Matrix2; import org.apache.sis.referencing.operation.transform.MathTransforms; import org.apache.sis.referencing.operation.transform.AbstractMathTransform2D; import org.apache.sis.internal.referencing.j2d.AffineTransform2D; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.util.collection.Cache; import org.apache.sis.util.resources.Errors; import org.apache.sis.io.wkt.Formatter; @@ -71,6 +72,7 @@ final class ResamplingGrid extends AbstractMathTransform2D { * This maximum is honored on a best-effort basis; it may happen that for some pixels * the error is slightly higher. */ + @Configuration static final double TOLERANCE = 0.125; /** diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageLayout.java b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageLayout.java index aab3f04ad0..1b3bd172ee 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageLayout.java +++ b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageLayout.java @@ -30,6 +30,7 @@ import org.apache.sis.image.ComputedImage; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.resources.Errors; import org.apache.sis.internal.util.Strings; +import org.apache.sis.internal.system.Configuration; /** @@ -48,7 +49,10 @@ public class ImageLayout { * <p>Tiles of 180×180 pixels consume about 127 kB, assuming 4 bytes per pixel. This is about half * the consumption of tiles of 256×256 pixels. We select a size which is a multiple of 90 because * images are often used with a resolution of e.g. ½° per pixel.</p> + * + * @see ImageUtilities#DEFAULT_TILE_SIZE */ + @Configuration private static final int MIN_TILE_SIZE = 180; /** diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageUtilities.java b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageUtilities.java index 1148179ef6..dc11a2f7e6 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageUtilities.java +++ b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageUtilities.java @@ -31,6 +31,7 @@ import java.awt.image.SampleModel; import java.awt.image.SinglePixelPackedSampleModel; import java.awt.image.MultiPixelPackedSampleModel; import org.apache.sis.internal.feature.Resources; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.system.Modules; import org.apache.sis.internal.util.Numerics; import org.apache.sis.util.Numbers; @@ -60,6 +61,7 @@ public final class ImageUtilities extends Static { /** * Default width and height of tiles, in pixels. */ + @Configuration public static final int DEFAULT_TILE_SIZE = 256; /** @@ -67,6 +69,7 @@ public final class ImageUtilities extends Static { * keeping the most recently used tiles up to 10 Mb of memory. This is not for sophisticated caching mechanism; * instead the "real" caching should be done by {@link org.apache.sis.image.ComputedImage}. */ + @Configuration public static final int SUGGESTED_TILE_CACHE_SIZE = 10 * (1024 * 1024) / (DEFAULT_TILE_SIZE * DEFAULT_TILE_SIZE); /** @@ -76,6 +79,7 @@ public final class ImageUtilities extends Static { * * @see #prepareTransferRegion(Rectangle, int) */ + @Configuration private static final int BUFFER_SIZE = 32 * DEFAULT_TILE_SIZE * Byte.SIZE; /** diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java index e15f8f7e78..eeea549d12 100644 --- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java @@ -37,13 +37,13 @@ import javax.naming.event.NamingEvent; import javax.naming.event.NamingExceptionEvent; import javax.naming.event.ObjectChangeListener; import org.apache.sis.setup.InstallationResources; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.system.DefaultFactories; import org.apache.sis.internal.system.DataDirectory; import org.apache.sis.internal.system.Shutdown; import org.apache.sis.internal.system.Loggers; import org.apache.sis.util.resources.Messages; import org.apache.sis.util.logging.Logging; -import org.apache.sis.util.Configuration; import static java.util.logging.Logger.getLogger; import static org.apache.sis.internal.util.MetadataServices.EMBEDDED; @@ -227,7 +227,7 @@ public abstract class Initializer { * * @since 1.0 */ - @Configuration + @Configuration(writeAccess = Configuration.Access.GLOBAL) public static synchronized boolean setDefault(final Supplier<DataSource> ds) { if (source == null) { supplier = ds; diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java index 24c276ce3f..04febe4872 100644 --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java @@ -34,6 +34,7 @@ import org.apache.sis.util.Classes; import org.apache.sis.util.ComparisonMode; import org.apache.sis.util.collection.TreeTable; import org.apache.sis.util.collection.CheckedContainer; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.system.Modules; import org.apache.sis.internal.system.Semaphores; import org.apache.sis.internal.system.SystemListener; @@ -112,6 +113,7 @@ public class MetadataStandard implements Serializable { * than GeoAPI, but have a slight performance cost at construction time. Performance * after construction should be the same.</p> */ + @Configuration static final boolean IMPLEMENTATION_CAN_ALTER_API = false; /** diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java index 4ff11a50ff..7c9551ddb6 100644 --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java @@ -60,6 +60,7 @@ import org.apache.sis.internal.metadata.sql.Initializer; import org.apache.sis.internal.metadata.sql.Reflection; import org.apache.sis.internal.metadata.sql.SQLBuilder; import org.apache.sis.internal.metadata.ReferencingServices; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.system.Loggers; import org.apache.sis.internal.util.Strings; import org.apache.sis.internal.util.CollectionsExt; @@ -133,12 +134,14 @@ public class MetadataSource implements AutoCloseable { * * @see #closeExpired() */ + @Configuration private static final long TIMEOUT = 2000_000000; /** * An extra delay to add to the {@link #TIMEOUT} in order to increase the chances to * close many statements at once. */ + @Configuration private static final int EXTRA_DELAY = 500_000000; /** diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoader.java b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoader.java index d2df229921..27d096675f 100644 --- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoader.java +++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/MultiResolutionCoverageLoader.java @@ -36,6 +36,7 @@ import org.apache.sis.coverage.grid.GridCoverage; import org.apache.sis.coverage.grid.GridRoundingMode; import org.apache.sis.math.DecimalFunctions; import org.apache.sis.io.TableAppender; +import org.apache.sis.internal.system.Configuration; /** @@ -60,6 +61,7 @@ public class MultiResolutionCoverageLoader { * This is used by {@link #defaultResolutions(GridGeometry, double[])} when no * resolution levels are explicitly given by the {@linkplain #resource}. */ + @Configuration private static final int DEFAULT_SIZE = 512; /** diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/CanvasContext.java b/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/CanvasContext.java index 08be337904..0fe4324b70 100644 --- a/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/CanvasContext.java +++ b/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/CanvasContext.java @@ -34,6 +34,7 @@ import org.apache.sis.measure.Units; import org.apache.sis.geometry.Envelopes; import org.apache.sis.geometry.GeneralEnvelope; import org.apache.sis.internal.referencing.Formulas; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.referencing.operation.transform.LinearTransform; @@ -53,6 +54,7 @@ final class CanvasContext extends CoordinateOperationContext { * * @see Canvas#findTransform(CoordinateReferenceSystem, CoordinateReferenceSystem, boolean) */ + @Configuration private static final double DISPLAY_RESOLUTION = 1; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Arithmetic.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Arithmetic.java index d6ffd7d4ed..901d8f0bdc 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Arithmetic.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Arithmetic.java @@ -18,6 +18,7 @@ package org.apache.sis.internal.referencing; import java.util.function.BiFunction; import java.util.function.BinaryOperator; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.util.DoubleDouble; import org.apache.sis.math.Fraction; @@ -76,6 +77,7 @@ public enum Arithmetic { * Whether to assume that {@code float} and {@code double} values * were intended to be exact in base 10. */ + @Configuration public static final boolean DECIMAL = true; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java index 2face4aff3..538cb09cc6 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Formulas.java @@ -16,10 +16,11 @@ */ package org.apache.sis.internal.referencing; +import org.opengis.referencing.datum.Ellipsoid; import org.apache.sis.util.Static; import org.apache.sis.measure.Latitude; import org.apache.sis.internal.util.Numerics; -import org.opengis.referencing.datum.Ellipsoid; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.referencing.datum.DefaultEllipsoid; import static java.lang.Math.*; @@ -51,6 +52,7 @@ public final class Formulas extends Static { * @see #ANGULAR_TOLERANCE * @see org.apache.sis.internal.util.Numerics#COMPARISON_THRESHOLD */ + @Configuration public static final double LINEAR_TOLERANCE = 0.01; /** @@ -63,6 +65,7 @@ public final class Formulas extends Static { * @see #LINEAR_TOLERANCE * @see org.apache.sis.internal.util.Numerics#COMPARISON_THRESHOLD */ + @Configuration public static final double ANGULAR_TOLERANCE = LINEAR_TOLERANCE / (NAUTICAL_MILE * 60); /** @@ -70,6 +73,7 @@ public final class Formulas extends Static { * assuming that the unit of measurement is second. Current value is arbitrary * and may change in any future Apache SIS version. */ + @Configuration public static final double TEMPORAL_TOLERANCE = 60; // One minute. /** @@ -96,6 +100,7 @@ public final class Formulas extends Static { * * <p>Current value has been determined empirically for allowing {@code GeodesicsOnEllipsoidTest} to pass.</p> */ + @Configuration public static final int MAXIMUM_ITERATIONS = 18; /** @@ -104,6 +109,7 @@ public final class Formulas extends Static { * Use of FMA brings performance benefits on machines having hardware support, * but come at a high cost on older machines without hardware support. */ + @Configuration public static final boolean USE_FMA = true; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/PositionalAccuracyConstant.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/PositionalAccuracyConstant.java index 411d7a0cd0..246bdfb7ab 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/PositionalAccuracyConstant.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/PositionalAccuracyConstant.java @@ -36,6 +36,7 @@ import org.apache.sis.measure.Units; import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.metadata.iso.quality.DefaultConformanceResult; import org.apache.sis.metadata.iso.quality.DefaultAbsoluteExternalPositionalAccuracy; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.util.resources.Vocabulary; @@ -65,6 +66,7 @@ public final class PositionalAccuracyConstant extends DefaultAbsoluteExternalPos * * @see org.apache.sis.referencing.operation.AbstractCoordinateOperation#getLinearAccuracy() */ + @Configuration public static final double UNKNOWN_ACCURACY = 3000; /** @@ -76,6 +78,7 @@ public final class PositionalAccuracyConstant extends DefaultAbsoluteExternalPos * * @see org.apache.sis.referencing.operation.AbstractCoordinateOperation#getLinearAccuracy() */ + @Configuration private static final double DATUM_SHIFT_ACCURACY = 25; /** @@ -84,6 +87,7 @@ public final class PositionalAccuracyConstant extends DefaultAbsoluteExternalPos * The result is multiplied by 2 again as a margin because we have no guarantees that the domain * of validity of the two datum are close enough for making this concatenation valid. */ + @Configuration public static final double INDIRECT_SHIFT_ACCURACY = 100; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java b/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java index f64bef6d26..6d78aff9dd 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Formatter.java @@ -74,6 +74,7 @@ import org.apache.sis.internal.util.X364; import org.apache.sis.internal.util.Numerics; import org.apache.sis.internal.util.Constants; import org.apache.sis.internal.util.StandardDateFormat; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.simple.SimpleExtent; import org.apache.sis.internal.metadata.Resources; import org.apache.sis.internal.referencing.WKTKeywords; @@ -116,12 +117,14 @@ public class Formatter implements Localized { * Accuracy of geographic bounding boxes, in number of fraction digits. * We use the accuracy recommended by ISO 19162. */ + @Configuration static final int BBOX_ACCURACY = 2; /** * Maximal accuracy of vertical extents, in number of fraction digits. * The value used here is arbitrary and may change in any future SIS version. */ + @Configuration private static final int VERTICAL_ACCURACY = 9; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodesicsOnEllipsoid.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodesicsOnEllipsoid.java index 7818cab811..6521f1e00e 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodesicsOnEllipsoid.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodesicsOnEllipsoid.java @@ -22,6 +22,7 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.apache.sis.internal.referencing.Resources; import org.apache.sis.internal.referencing.Formulas; import org.apache.sis.math.MathFunctions; +import org.apache.sis.util.Debug; import static java.lang.Math.*; @@ -78,11 +79,12 @@ import static java.lang.Math.*; */ class GeodesicsOnEllipsoid extends GeodeticCalculator { /** - * Whether to include code used for JUnit tests only. This field should be - * set to {@code true} during development and to {@code false} in releases. + * Whether to include code used for JUnit tests only. This field can be set to + * {@code true} during debugging and should be set to {@code false} in releases. * * @see #snapshot() */ + @Debug static final boolean STORE_LOCAL_VARIABLES = false; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java index 823976a0af..7ab474133a 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java @@ -55,6 +55,7 @@ import org.apache.sis.internal.simple.SimpleCitation; import org.apache.sis.internal.system.ReferenceQueueConsumer; import org.apache.sis.internal.system.DelayedExecutor; import org.apache.sis.internal.system.DelayedRunnable; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.system.Shutdown; import org.apache.sis.internal.system.Loggers; import org.apache.sis.internal.util.CollectionsExt; @@ -111,11 +112,12 @@ public abstract class ConcurrentAuthorityFactory<DAO extends GeodeticAuthorityFa * Any operation that take longer than this amount of time to execute will have a message logged. * The log level depends on the execution duration as specified in {@link PerformanceLevel}. * - * <div class="note"><b>Rational:</b> - * we do not unconditionally log all creation messages because they are redundant with more detailed + * <h4>Rational</h4> + * We do not unconditionally log all creation messages because they are redundant with more detailed * logs produced by {@link GeodeticObjectFactory}. Their only additional information is the creation - * duration, which is not very useful if too close to zero.</div> + * duration, which is not very useful if too close to zero. */ + @Configuration private static final long DURATION_FOR_LOGGING = 10_000_000L; // 10 milliseconds. /** @@ -263,7 +265,9 @@ public abstract class ConcurrentAuthorityFactory<DAO extends GeodeticAuthorityFa * Every access to this field must be performed in a block synchronized on {@link #availableDAOs}. * * @see #getTimeout(TimeUnit) + * @see #setTimeout(long, TimeUnit) */ + @Configuration(writeAccess = Configuration.Access.INSTANCE) private long timeout = 60_000_000_000L; // 1 minute /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ReferenceKeeper.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ReferenceKeeper.java index 40b5ebcd3c..752f4877b1 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ReferenceKeeper.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ReferenceKeeper.java @@ -17,6 +17,7 @@ package org.apache.sis.referencing.factory; import org.opengis.referencing.IdentifiedObject; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.system.DelayedExecutor; import org.apache.sis.internal.system.DelayedRunnable; import org.apache.sis.internal.util.StandardDateFormat; @@ -50,11 +51,13 @@ final class ReferenceKeeper { * is not designed for large collections. Note that the number of unique entries may be lower * because this class does not try to avoid duplicated references. */ + @Configuration private static final int CAPACITY = 40; /** * Time to wait before to remove entries from this map. Current value is 5 minutes. */ + @Configuration private static final long EXPIRATION_TIME = 5L * 60 * StandardDateFormat.NANOS_PER_SECOND; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java index 0fde35056c..1136177578 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java @@ -57,6 +57,7 @@ import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.Classes; import org.apache.sis.util.NullArgumentException; import org.apache.sis.util.Utilities; +import org.apache.sis.util.Debug; /** @@ -90,6 +91,7 @@ public class DefaultCoordinateOperationFactory extends AbstractFactory implement * Whether this class is allowed to use the EPSG authority factory for searching coordinate operation paths. * This flag should always be {@code true}, except temporarily for testing purposes. */ + @Debug static final boolean USE_EPSG_FACTORY = true; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java index 01f456033a..792f319688 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LocalizationGridBuilder.java @@ -38,6 +38,7 @@ import org.apache.sis.referencing.datum.DatumShiftGrid; import org.apache.sis.internal.referencing.Resources; import org.apache.sis.geometry.GeneralEnvelope; import org.apache.sis.geometry.Envelopes; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.util.Numerics; import org.apache.sis.internal.util.Strings; import org.apache.sis.util.resources.Vocabulary; @@ -130,6 +131,7 @@ public class LocalizationGridBuilder extends TransformBuilder { * precision has been specified. The {@code sourceToGrid} transform shall not be applied on this value. * This default precision may change in any future SIS version. */ + @Configuration private static final double DEFAULT_PRECISION = 1E-7; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/ProjectedTransformTry.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/ProjectedTransformTry.java index 8d0a41990d..ffaf3ab3c6 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/ProjectedTransformTry.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/ProjectedTransformTry.java @@ -25,13 +25,13 @@ import java.text.NumberFormat; import org.opengis.geometry.MismatchedDimensionException; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.TransformException; -import org.apache.sis.referencing.operation.matrix.MatrixSIS; import org.apache.sis.io.TableAppender; import org.apache.sis.util.ArraysExt; import org.apache.sis.util.Exceptions; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.resources.Errors; import org.apache.sis.referencing.operation.matrix.Matrices; +import org.apache.sis.referencing.operation.matrix.MatrixSIS; import org.apache.sis.referencing.operation.transform.MathTransforms; @@ -41,8 +41,8 @@ import org.apache.sis.referencing.operation.transform.MathTransforms; * in order to avoid consuming too much memory when many attempts are made; {@link LinearTransformBuilder} needs only * to keep the best attempt. * - * <div class="note"> - * <p><b>Purpose:</b> localization grids in netCDF files contain (<var>longitude</var>, <var>latitude</var>) values for all pixels. + * <h2>Purpose</h2> + * <p>Localization grids in netCDF files contain (<var>longitude</var>, <var>latitude</var>) values for all pixels. * {@link LocalizationGridBuilder} first computes a linear (affine) approximation of a localization grid, then stores the residuals. * This approach works well when the residuals are small. However if the localization grid is non-linear, then the affine transform * is a poor approximation of that grid and the residuals are high. High residuals make inverse transforms hard to compute, which @@ -53,10 +53,10 @@ import org.apache.sis.referencing.operation.transform.MathTransforms; * if one of those projections results in a grid closer to an affine transform. In other words, we use this class for trying to * guess what the projection may be. It is okay if the guess is not a perfect match; if the residuals become smalls enough, * it will resolve the "no convergence" errors.</p> - * </div> * - * <p><b>Note:</b> {@link #compareTo(ProjectedTransformTry)} is inconsistent with {@link #equals(Object)}. - * The fact that {@link ProjectedTransformTry} instances are comparable should not be visible in public API.</p> + * <h2>Note</h2> + * {@link #compareTo(ProjectedTransformTry)} is inconsistent with {@link #equals(Object)}. + * The fact that {@link ProjectedTransformTry} instances are comparable should not be visible in public API. * * @author Martin Desruisseaux (Geomatys) * @version 1.1 diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java index d43410c5b9..bd3a625868 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java @@ -21,6 +21,7 @@ import org.opengis.referencing.operation.Matrix; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.ArraysExt; import org.apache.sis.internal.util.Numerics; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.referencing.Arithmetic; import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix; @@ -61,7 +62,10 @@ class GeneralMatrix extends MatrixSIS implements ExtendedPrecisionMatrix { * <div class="note"><b>Note:</b> * A similar constant exists in {@code org.apache.sis.math.Plane}. * </div> + * + * @see Numerics#COMPARISON_THRESHOLD */ + @Configuration private static final double ZERO_THRESHOLD = 1E-14; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java index 860e57643f..c633d378b7 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java @@ -36,6 +36,7 @@ import org.apache.sis.internal.referencing.Resources; import org.apache.sis.internal.util.DoubleDouble; import org.apache.sis.parameter.Parameters; import org.apache.sis.util.Workaround; +import org.apache.sis.util.Debug; import static java.lang.Math.*; import static org.apache.sis.math.MathFunctions.asinh; @@ -117,6 +118,7 @@ public class TransverseMercator extends NormalizedProjection { * * @see #identityEquals(double, double) */ + @Debug private static final boolean ALLOW_TRIGONOMETRIC_IDENTITIES = true; /** diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java index ebbc83f854..1815536d47 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/InterpolatedTransform.java @@ -31,6 +31,7 @@ import org.apache.sis.referencing.operation.matrix.Matrices; import org.apache.sis.referencing.operation.matrix.MatrixSIS; import org.apache.sis.referencing.operation.matrix.NoninvertibleMatrixException; import org.apache.sis.measure.Units; +import org.apache.sis.util.Debug; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.ComparisonMode; @@ -449,6 +450,7 @@ public class InterpolatedTransform extends DatumShiftTransform { * be enabled, and some information will be printed to the standard output stream. Enabling debugging slows * down considerably the transformations; it should be done only for small set of test data. */ + @Debug private static final boolean DEBUG = false; /** @@ -458,6 +460,7 @@ public class InterpolatedTransform extends DatumShiftTransform { * more curved grids like the ones read from netCDF files. We provide this switch for allowing performance * comparisons. */ + @Debug private static final boolean SIMPLE = false; /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/CommonExecutor.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/CommonExecutor.java index 532bf9a330..17b5e7b6ac 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/CommonExecutor.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/CommonExecutor.java @@ -58,6 +58,7 @@ public final class CommonExecutor extends AtomicInteger implements ThreadFactory * If the number of tasks is greater than this parallelism value, * extraneous tasks will be queued. */ + @Configuration public static final int PARALLELISM = Math.max(Runtime.getRuntime().availableProcessors() - 1, 1); /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Configuration.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Configuration.java new file mode 100644 index 0000000000..5c30cf939c --- /dev/null +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Configuration.java @@ -0,0 +1,91 @@ +/* + * 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.system; + +import java.lang.annotation.Target; +import java.lang.annotation.Retention; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; + + +/** + * Annotates methods having a system-wide impact on the configuration of the Apache SIS library. + * Also used for some static final constants fixed to arbitrary values that could be customized. + * This annotation should not be used on test classes for avoiding to pollute usage searches. + * + * <h2>Application to static final constants</h2> + * We do not annotate all static constants having arbitrary values because there is too many of them. + * We annotate only the most interesting ones, when we can reasonably think that some developers may + * want to change the values. This annotation is used for identifying aspects where we could add API + * in a future version if there is an interest for controlling them. + * + * @author Martin Desruisseaux (IRD, Geomatys) + * @version 1.4 + * @since 0.3 + */ +@Target({ElementType.METHOD, ElementType.FIELD}) +@Retention(RetentionPolicy.SOURCE) +public @interface Configuration { + /** + * Tells by which API the configuration can be modified. + * The value shall be {@code NONE} (the default) for compile-time constants. + * At the opposite extreme, the value should be {@code GLOBAL} If the configuration + * is accessible from the {@link org.apache.sis.setup.Configuration} public class. + * + * @return which API can modify the configuration. + */ + Access writeAccess() default Access.NONE; + + /** + * Indication of which API can modify the configuration. The enumeration is ordered from + * non-modifiable to the preferred place where to provide control on the configuration. + */ + enum Access { + /** + * The configuration is non-modifiable. + * This value applies to all static final constants. + */ + NONE, + + /** + * The configuration is modifiable through an internal API. + * There is no public API for this configuration yet. + */ + INTERNAL, + + /** + * The configuration is modifiable through a public method + * that must be invoked on a particular instance of a class. + * This configuration can not be easily moved to {@link #GLOBAL} + * because it would require to decide on which instance to apply. + */ + INSTANCE, + + /** + * The configuration is modifiable through a public static method. + * This value means that the configuration could be moved to {@link #GLOBAL}, + * but has not been moved yet because it is not clear if there is an interest for that. + */ + STATIC, + + /** + * The configuration is modifiable through {@link org.apache.sis.setup.Configuration}. + * This is the place where we try to centralize all configurations of interest. + */ + GLOBAL + } +} diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java index 7197ec5529..325391b862 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java @@ -37,7 +37,6 @@ import javax.management.InstanceAlreadyExistsException; import java.lang.management.ManagementFactory; import org.apache.sis.setup.About; -import org.apache.sis.util.Configuration; import org.apache.sis.util.logging.Logging; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.resources.Messages; @@ -59,6 +58,7 @@ public final class Supervisor extends StandardMBean implements SupervisorMBean { * Whatever JMX agent is enabled. Setting this variable to {@code false} allows the * Java compiler to omit any dependency to this {@code Supervisor} class. */ + @Configuration static final boolean ENABLED = true; /** @@ -81,7 +81,7 @@ public final class Supervisor extends StandardMBean implements SupervisorMBean { * and the MBean will not be registered. This method does not propagate the exception * because the MBean is not a mandatory part of SIS library.</p> */ - @Configuration + @Configuration(writeAccess = Configuration.Access.INTERNAL) public static synchronized void register() { if (name == null) { name = ObjectName.WILDCARD; // In case of failure. @@ -112,7 +112,7 @@ public final class Supervisor extends StandardMBean implements SupervisorMBean { * * @throws JMException if an error occurred during unregistration. */ - @Configuration + @Configuration(writeAccess = Configuration.Access.INTERNAL) static synchronized void unregister() throws JMException { final ObjectName n = name; if (n != null) { diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java index 465f861f00..f3a0f85679 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/DoubleDouble.java @@ -23,6 +23,8 @@ import java.math.MathContext; import org.apache.sis.math.Fraction; import org.apache.sis.math.MathFunctions; import org.apache.sis.math.DecimalFunctions; +import org.apache.sis.internal.system.Configuration; +import org.apache.sis.util.Debug; /** @@ -76,6 +78,7 @@ public final class DoubleDouble extends Number implements Comparable<DoubleDoubl * implementation. Since JAMA uses {@code double} arithmetic, SIS needs to disable double-double * arithmetic if the results are to be compared for strict equality.</p> */ + @Debug public static final boolean DISABLED = false; /** @@ -84,6 +87,7 @@ public final class DoubleDouble extends Number implements Comparable<DoubleDoubl * if the amount of non-zero significand bits is equal or lower than {@code ZERO_THRESHOLD+1}, * consider the result as zero. */ + @Configuration private static final int ZERO_THRESHOLD = 2; /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java index 25d2a9dc9b..7633317629 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java @@ -35,6 +35,7 @@ import static java.lang.Math.min; import static java.lang.Math.max; import static java.lang.Math.abs; import static java.lang.Math.ulp; +import org.apache.sis.internal.system.Configuration; /** @@ -114,7 +115,9 @@ public final class Numerics extends Static { * * @see org.apache.sis.internal.referencing.Formulas#LINEAR_TOLERANCE * @see org.apache.sis.internal.referencing.Formulas#ANGULAR_TOLERANCE + * @see org.apache.sis.referencing.operation.matrix.GeneralMatrix#ZERO_THRESHOLD */ + @Configuration public static final double COMPARISON_THRESHOLD = 1E-13; /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java b/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java index eb1831bf7c..ceaa5294bf 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java +++ b/core/sis-utility/src/main/java/org/apache/sis/math/Plane.java @@ -82,6 +82,8 @@ public class Plane implements DoubleBinaryOperator, Cloneable, Serializable { * <div class="note"><b>Note:</b> * A similar constant exists in {@code org.apache.sis.referencing.operation.matrix.GeneralMatrix}. * </div> + * + * @see Numerics#COMPARISON_THRESHOLD */ private static final double ZERO_THRESHOLD = 1E-14; diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java b/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java index 09688330c2..ac85136eff 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java +++ b/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java @@ -33,6 +33,7 @@ import org.apache.sis.util.LenientComparable; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.logging.Logging; import org.apache.sis.internal.system.Loggers; +import org.apache.sis.internal.system.Configuration; import static java.util.logging.Logger.getLogger; @@ -82,6 +83,7 @@ abstract class AbstractUnit<Q extends Quantity<Q>> implements Unit<Q>, LenientCo * * @see #isValidSymbol(String, boolean, boolean) */ + @Configuration private static final int MAX_OPERATIONS_IN_SYMBOL = 1; /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java b/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java index 99d603ea93..12d2cd0dfc 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java +++ b/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java @@ -33,6 +33,7 @@ import java.io.UncheckedIOException; import javax.measure.Dimension; import javax.measure.Unit; import javax.measure.format.MeasurementParseException; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.system.Loggers; import org.apache.sis.internal.util.Constants; import org.apache.sis.internal.util.DefinitionURI; @@ -88,6 +89,7 @@ public class UnitFormat extends Format implements javax.measure.format.UnitForma /** * Whether the parsing of authority codes such as {@code "EPSG:9001"} is allowed. */ + @Configuration private static final boolean PARSE_AUTHORITY_CODES = true; /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/setup/Configuration.java b/core/sis-utility/src/main/java/org/apache/sis/setup/Configuration.java index 1e68580692..39575dc8c7 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/setup/Configuration.java +++ b/core/sis-utility/src/main/java/org/apache/sis/setup/Configuration.java @@ -21,6 +21,7 @@ import java.util.Optional; import javax.sql.DataSource; import java.sql.SQLException; import java.util.function.Supplier; +import java.util.concurrent.TimeUnit; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.internal.util.MetadataServices; @@ -32,8 +33,16 @@ import org.apache.sis.internal.util.MetadataServices; * in order to avoid interfering with user's settings. * * <h2>Other system-wide configuration</h2> + * The following methods have system-wide effects on Apache SIS configuration, + * but are not yet controlled through this {@code Configuration} class: + * + * <ul> + * <li>{@link org.apache.sis.util.logging.MonolineFormatter#install()}</li> + * <li>{@link org.apache.sis.util.logging.PerformanceLevel#setMinDuration(long, TimeUnit)}</li> + * </ul> + * * The following properties are defined by the standard Java environment. - * Apache SIS does not modify those properties but read them: + * Apache SIS read those properties but does not modify them: * * <ul> * <li>{@link Locale#getDefault()} (sometimes using {@link Locale.Category})</li> diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/Configuration.java b/core/sis-utility/src/main/java/org/apache/sis/util/Configuration.java deleted file mode 100644 index 51b97e4d9e..0000000000 --- a/core/sis-utility/src/main/java/org/apache/sis/util/Configuration.java +++ /dev/null @@ -1,44 +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.util; - -import java.lang.annotation.Target; -import java.lang.annotation.Retention; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.RetentionPolicy; - - -/** - * Annotates methods having a system-wide impact on the configuration of the Apache SIS library. - * See <cite>"Use"</cite> javadoc link for a list of annotated methods. - * - * <p><b>Do not use.</b> This annotation is for documentation purpose only - * and will be replaced by the {@link org.apache.sis.setup.Configuration} class. - * - * @author Martin Desruisseaux (IRD, Geomatys) - * @version 0.3 - * - * @see <a href="https://issues.apache.org/jira/browse/SIS-86">SIS-86</a> - * - * @since 0.3 - */ -@Documented -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.SOURCE) -public @interface Configuration { -} diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java b/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java index 0b4219f852..c7b3196d22 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java @@ -28,6 +28,7 @@ import org.apache.sis.util.Static; import org.apache.sis.util.Exceptions; import org.apache.sis.util.Classes; import org.apache.sis.internal.system.Modules; +import org.apache.sis.internal.system.Configuration; /** @@ -57,6 +58,7 @@ public final class Logging extends Static { * Consequently, we will ignore the stack traces of recoverable failures, but will report * stack traces that may impact performance, configuration, or correctness.</p> */ + @Configuration private static final int LEVEL_THRESHOLD_FOR_STACKTRACE = 600; /** diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java b/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java index 7e0cc6056d..f61f0ed51d 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java @@ -36,11 +36,11 @@ import org.apache.sis.internal.system.Modules; import org.apache.sis.internal.util.X364; import org.apache.sis.internal.util.Strings; import org.apache.sis.internal.util.AutoMessageFormat; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.io.IO; import org.apache.sis.io.LineAppender; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.CharSequences; -import org.apache.sis.util.Configuration; import org.apache.sis.util.Debug; import static org.apache.sis.internal.util.StandardDateFormat.UTC; @@ -184,6 +184,7 @@ public class MonolineFormatter extends Formatter { /** * Maximal amount of causes to print in stack traces. This is an arbitrary limit. */ + @Configuration private static final int MAX_CAUSES = 10; /** @@ -978,7 +979,7 @@ loop: for (int i=0; ; i++) { * using the {@link #setTimeFormat(String)} and {@link #setSourceFormat(String)} methods. * @throws SecurityException if this method does not have the permission to install the formatter. */ - @Configuration + @Configuration(writeAccess = Configuration.Access.STATIC) public static MonolineFormatter install() throws SecurityException { return install(Logger.getLogger(""), null); } @@ -1023,7 +1024,7 @@ loop: for (int i=0; ; i++) { * @throws SecurityException if this method does not have the permission to install the formatter. */ @Debug - @Configuration + @Configuration(writeAccess = Configuration.Access.STATIC) public static MonolineFormatter install(final Logger logger, final Level level) throws SecurityException { ArgumentChecks.ensureNonNull("logger", logger); MonolineFormatter monoline = null; diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/logging/PerformanceLevel.java b/core/sis-utility/src/main/java/org/apache/sis/util/logging/PerformanceLevel.java index e1c76fad30..110a291393 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/logging/PerformanceLevel.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/logging/PerformanceLevel.java @@ -19,9 +19,9 @@ package org.apache.sis.util.logging; import java.util.logging.Level; import java.util.logging.Logger; import java.util.concurrent.TimeUnit; -import org.apache.sis.util.Configuration; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.resources.Vocabulary; +import org.apache.sis.internal.system.Configuration; /** @@ -79,7 +79,11 @@ public final class PerformanceLevel extends Level { /** * The minimal duration (in nanoseconds) for logging the record. + * + * @see #getMinDuration(TimeUnit) + * @see #setMinDuration(long, TimeUnit) */ + @Configuration(writeAccess = Configuration.Access.INSTANCE) private volatile long minDuration; /** @@ -142,7 +146,6 @@ public final class PerformanceLevel extends Level { * @param unit the unit of the given duration value. * @throws IllegalArgumentException if the given duration is zero or negative. */ - @Configuration @SuppressWarnings("fallthrough") public void setMinDuration(long duration, final TimeUnit unit) throws IllegalArgumentException { ArgumentChecks.ensureStrictlyPositive("duration", duration); diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java b/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java index cc387e7ddd..11580346f1 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java @@ -43,6 +43,7 @@ import org.apache.sis.util.Exceptions; import org.apache.sis.util.CharSequences; import org.apache.sis.util.logging.Logging; import org.apache.sis.internal.system.Loggers; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.util.AutoMessageFormat; import org.apache.sis.internal.util.MetadataServices; import org.apache.sis.internal.util.Strings; @@ -95,6 +96,7 @@ public class IndexedResourceBundle extends ResourceBundle implements Localized { * Resource strings are never cut to this length. However, text replacing {@code "{0}"} in a string like * {@code "Parameter name is {0}"} will be cut to this length. */ + @Configuration private static final int MAX_STRING_LENGTH = 200; /** diff --git a/ide-project/NetBeans/nbproject/genfiles.properties b/ide-project/NetBeans/nbproject/genfiles.properties index 2427112a0b..dbf91a7a89 100644 --- a/ide-project/NetBeans/nbproject/genfiles.properties +++ b/ide-project/NetBeans/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.data.CRC32=58e6b21c build.xml.script.CRC32=462eaba0 build.xml.stylesheet.CRC32=28e38971@1.53.1.46 -nbproject/build-impl.xml.data.CRC32=fd717426 +nbproject/build-impl.xml.data.CRC32=b95fb13b nbproject/build-impl.xml.script.CRC32=69d63511 -nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.104.0.48 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.105.0.48 diff --git a/ide-project/NetBeans/nbproject/project.xml b/ide-project/NetBeans/nbproject/project.xml index 73c362359f..d23f13fea9 100644 --- a/ide-project/NetBeans/nbproject/project.xml +++ b/ide-project/NetBeans/nbproject/project.xml @@ -89,6 +89,7 @@ <word>collinearity</word> <word>complexify</word> <word>covariant</word> + <word>customizable</word> <word>deserialization</word> <word>deserialized</word> <word>endianness</word> 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 f7dc1807a6..0e07cd1c65 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 @@ -37,6 +37,7 @@ import org.opengis.referencing.crs.TemporalCRS; import org.opengis.metadata.acquisition.GeometryType; import org.apache.sis.referencing.crs.DefaultTemporalCRS; import org.apache.sis.coverage.grid.GridExtent; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.feature.MovingFeatures; import org.apache.sis.internal.util.Strings; import org.apache.sis.storage.DataStore; @@ -82,6 +83,7 @@ final class FeatureSet extends DiscreteSampling { * We do not read all features at once neither because it consumes a lot of memory if the netCDF file is large. * This value is a compromise between reducing I/O operations and reducing memory consumption. */ + @Configuration private static final int PAGE_SIZE = 512; /** diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java index 4962e1122e..690a381421 100644 --- a/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java +++ b/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java @@ -65,6 +65,7 @@ import org.apache.sis.internal.storage.io.IOUtilities; import org.apache.sis.internal.storage.MetadataBuilder; import org.apache.sis.internal.storage.wkt.StoreFormat; import org.apache.sis.internal.referencing.AxisDirections; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.util.CollectionsExt; import org.apache.sis.internal.util.Strings; import org.apache.sis.util.resources.Errors; @@ -119,6 +120,7 @@ final class MetadataReader extends MetadataBuilder { * Whether the reader should include experimental fields. * They are fields for which we are unsure of the proper ISO 19115 location. */ + @Configuration private static final boolean EXPERIMENTAL = true; /** diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreUtilities.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreUtilities.java index 24503c0824..3e2baca237 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreUtilities.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreUtilities.java @@ -46,6 +46,7 @@ import org.apache.sis.storage.UnsupportedStorageException; import org.apache.sis.storage.event.StoreListeners; import org.apache.sis.geometry.GeneralEnvelope; import org.apache.sis.internal.metadata.Identifiers; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.system.Modules; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.CharSequences; @@ -80,6 +81,7 @@ public final class StoreUtilities extends Static { * have different sample value ranges for each coverage, which cause {@code CoverageAggregator} to consider * that that cannot be aggregated together.</p> */ + @Configuration public static final boolean ALLOW_LAST_RESORT_STATISTICS = false; /** 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 88a47baa62..808db94167 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 @@ -64,6 +64,7 @@ import org.apache.sis.internal.storage.io.ChannelImageOutputStream; import org.apache.sis.internal.storage.io.InputStreamAdapter; import org.apache.sis.internal.storage.io.RewindableLineReader; import org.apache.sis.internal.storage.io.InternalOptionKey; +import org.apache.sis.internal.system.Configuration; import org.apache.sis.internal.util.Strings; import org.apache.sis.io.InvalidSeekException; import org.apache.sis.setup.OptionKey; @@ -113,10 +114,15 @@ public class StorageConnector implements Serializable { * The default size (in bytes) of {@link ByteBuffer}s created by storage connectors. * Those buffers are typically created when the specified storage object is a * {@link File}, {@link Path}, {@link URL} or {@link URI}. - * Users can override this value by providing a value for {@link OptionKey#BYTE_BUFFER}. + * The default buffer size is arbitrary and may change in any future Apache SIS version. + * + * <p>Users can override this value by providing a value for {@link OptionKey#BYTE_BUFFER}.</p> + * + * @see OptionKey#BYTE_BUFFER * * @since 1.4 */ + @Configuration public static final int DEFAULT_BUFFER_SIZE = 16 * 1024; /**