You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2021/06/18 14:34:40 UTC

[isis] 03/06: ISIS-2750: updates OrderPrecedence constants so that none are negative

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-2750
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 4f7c17f827bc56efe69754c7e311dad766df7735
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Fri Jun 18 15:09:52 2021 +0100

    ISIS-2750: updates OrderPrecedence constants so that none are negative
---
 .../isis/applib/annotation/OrderPrecedence.java    | 46 +++++++++++++++-------
 1 file changed, 31 insertions(+), 15 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/annotation/OrderPrecedence.java b/api/applib/src/main/java/org/apache/isis/applib/annotation/OrderPrecedence.java
index 79d7a5c..135cdc0 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/annotation/OrderPrecedence.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/annotation/OrderPrecedence.java
@@ -24,44 +24,60 @@ import org.springframework.core.Ordered;
 import lombok.experimental.UtilityClass;
 
 /**
- * 
+ * Constants for use with {@link javax.annotation.Priority}, used both to determine which service to inject into a
+ * scalar field when there are multiple candidates, and also to order services if injecting into a vector field (in
+ * other words, into a {@link java.util.List}).
+ *
+ * @see javax.annotation.Priority
+ * @see org.springframework.core.annotation.Order
+ *
  * @since 2.0 {@index}
  */
 @UtilityClass
 public class OrderPrecedence {
 
     /**
-     * For domain services with the highest precedence value.
+     * For domain services with the highest precedence (priority) value.
+     *
+     * <p>
      * No framework services use this constant, but some very fundamental services (eg for security)
      * that are not expected to be overridden use a value that is only a little after this first value.
+     * </p>
      *
-     * @see java.lang.Integer#MIN_VALUE
-     * @see Ordered#HIGHEST_PRECEDENCE
+     * <p>
+     *     Note that this is a non-negative value, because {@link javax.annotation.Priority}'s javadoc states:
+     *     &quot;priority values should generally be non-negative, with negative values * reserved for special meanings
+     *     such as <i>undefined</i> or <i>not specified</i>.&quot;.  In particular, it is <i>not</i> the same as
+     *     {@link Ordered#HIGHEST_PRECEDENCE}.
+     * </p>
+     *
+     * @see javax.annotation.Priority
      */
-    public static final int FIRST = Ordered.HIGHEST_PRECEDENCE;
+    public static final int FIRST = 0;
 
     /**
-     * For framework for services that are unlikely to be overridden by application code.
+     * For domain services that act as a fallback, and which will typically be overridden.
+     *
+     * @see java.lang.Integer#MAX_VALUE
+     * @see Ordered#LOWEST_PRECEDENCE
      */
-    public static final int EARLY = FIRST / 2;
+    public static final int LAST = Ordered.LOWEST_PRECEDENCE;
 
     /**
      * For framework for services that could be overridden by application code (though not commonly).
      */
-    public static final int MIDPOINT = 0;
+    public static final int MIDPOINT = (LAST - FIRST) / 2;
 
     /**
-     * For framework services that are expected to be overridden by application code, or that act as a fallback.
+     * For framework for services that are unlikely to be overridden by application code.
      */
-    public static final int LATE = OrderPrecedence.LAST / 2;
+    public static final int EARLY = (MIDPOINT - FIRST) / 2;
 
     /**
-     * For domain services that act as a fallback, and which will typically be overridden.
-     *
-     * @see java.lang.Integer#MAX_VALUE
-     * @see Ordered#LOWEST_PRECEDENCE
+     * For framework services that are expected to be overridden by application code, or that act as a fallback.
      */
-    public static final int LAST = Ordered.LOWEST_PRECEDENCE;
+    public static final int LATE = (LAST - MIDPOINT) / 2;
+
 
 }