You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by st...@apache.org on 2018/03/01 07:00:47 UTC

deltaspike git commit: DELTASPIKE-1320 detect conflicts in globalAlternatives

Repository: deltaspike
Updated Branches:
  refs/heads/master f06a78939 -> bb1f188c1


DELTASPIKE-1320 detect conflicts in globalAlternatives

labeled Alternatives take precendence over globalAlternatives


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/bb1f188c
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/bb1f188c
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/bb1f188c

Branch: refs/heads/master
Commit: bb1f188c19712d76c1b5a70b413a0a9ee2eb0657
Parents: f06a789
Author: Mark Struberg <st...@apache.org>
Authored: Thu Mar 1 07:28:04 2018 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Thu Mar 1 07:44:25 2018 +0100

----------------------------------------------------------------------
 ...lAwareGlobalAlternativeBeanClassProvider.java | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/bb1f188c/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/extension/LabelAwareGlobalAlternativeBeanClassProvider.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/extension/LabelAwareGlobalAlternativeBeanClassProvider.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/extension/LabelAwareGlobalAlternativeBeanClassProvider.java
index adad429..8a2ddf7 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/extension/LabelAwareGlobalAlternativeBeanClassProvider.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/extension/LabelAwareGlobalAlternativeBeanClassProvider.java
@@ -48,26 +48,32 @@ public class LabelAwareGlobalAlternativeBeanClassProvider implements Alternative
         }
 
         Map<String, String> allProperties = ConfigResolver.getAllProperties();
+        // first read all globalAlternatives
         for (Map.Entry<String, String> property : allProperties.entrySet())
         {
-            if (activeQualifierLabel != null && property.getKey().startsWith(activeQualifierLabel))
+            if (property.getKey().startsWith(GLOBAL_ALTERNATIVES))
             {
-                String interfaceName = property.getKey().substring(activeQualifierLabel.length());
+                String interfaceName = property.getKey().substring(GLOBAL_ALTERNATIVES.length());
                 String implementation = property.getValue();
                 if (LOG.isLoggable(Level.FINE))
                 {
-                    LOG.fine("Enabling labeled alternative for interface " + interfaceName + ": " + implementation);
+                    LOG.fine("Enabling global alternative for interface " + interfaceName + ": " + implementation);
                 }
 
                 result.put(interfaceName, implementation);
             }
-            else if (property.getKey().startsWith(GLOBAL_ALTERNATIVES))
+        }
+
+        // and overwrite with any possible labled alternative, if exists
+        for (Map.Entry<String, String> property : allProperties.entrySet())
+        {
+            if (activeQualifierLabel != null && property.getKey().startsWith(activeQualifierLabel))
             {
-                String interfaceName = property.getKey().substring(GLOBAL_ALTERNATIVES.length());
+                String interfaceName = property.getKey().substring(activeQualifierLabel.length());
                 String implementation = property.getValue();
                 if (LOG.isLoggable(Level.FINE))
                 {
-                    LOG.fine("Enabling global alternative for interface " + interfaceName + ": " + implementation);
+                    LOG.fine("Enabling labeled alternative for interface " + interfaceName + ": " + implementation);
                 }
 
                 result.put(interfaceName, implementation);
@@ -76,4 +82,5 @@ public class LabelAwareGlobalAlternativeBeanClassProvider implements Alternative
 
         return result;
     }
+
 }