You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2018/03/29 21:46:38 UTC

[2/7] deltaspike git commit: DELTASPIKE-1320 labeled alternatives take priority over global alternatives

DELTASPIKE-1320 labeled alternatives take priority over global alternatives


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

Branch: refs/heads/deltaspike-1.8.x
Commit: e0a2505580dea6d2d95d9677a0f1ec686ce398f4
Parents: 06fd261
Author: gpetracek <gp...@apache.org>
Authored: Thu Mar 1 09:09:15 2018 +0100
Committer: gpetracek <gp...@apache.org>
Committed: Thu Mar 29 23:35:52 2018 +0200

----------------------------------------------------------------------
 ...AwareGlobalAlternativeBeanClassProvider.java | 24 ++++++++------------
 1 file changed, 10 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e0a25055/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 8a2ddf7..9d7d296 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,39 +48,35 @@ public class LabelAwareGlobalAlternativeBeanClassProvider implements Alternative
         }
 
         Map<String, String> allProperties = ConfigResolver.getAllProperties();
-        // first read all globalAlternatives
         for (Map.Entry<String, String> property : allProperties.entrySet())
         {
-            if (property.getKey().startsWith(GLOBAL_ALTERNATIVES))
+            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);
             }
-        }
-
-        // and overwrite with any possible labled alternative, if exists
-        for (Map.Entry<String, String> property : allProperties.entrySet())
-        {
-            if (activeQualifierLabel != null && property.getKey().startsWith(activeQualifierLabel))
+            else 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);
+                if (!result.containsKey(interfaceName)) //don't override labeled alternatives
+                {
+                    result.put(interfaceName, implementation);
+                }
             }
         }
 
         return result;
     }
-
 }