geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1796298 - in /geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi: CDI.java CDIProvider.java
Date Fri, 26 May 2017 16:25:08 GMT
Author: struberg
Date: Fri May 26 16:25:08 2017
New Revision: 1796298

URL: http://svn.apache.org/viewvc?rev=1796298&view=rev
Log:
GERONIMO-6553 take CDIProvider with highest priority.

Modified:
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDI.java
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDIProvider.java

Modified: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDI.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDI.java?rev=1796298&r1=1796297&r2=1796298&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDI.java
(original)
+++ geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDI.java
Fri May 26 16:25:08 2017
@@ -43,7 +43,26 @@ public abstract class CDI<T> implements
     {
         if (INSTANCE == null)
         {
-            INSTANCE = ServiceLoader.load(CDIProvider.class).iterator().next().getCDI();
+            synchronized (CDI.class)
+            {
+                if (INSTANCE == null)
+                {
+
+                    CDI<Object> highestCdi = null;
+                    int ordinal = -1;
+
+                    ServiceLoader<CDIProvider> cdiProviders = ServiceLoader.load(CDIProvider.class);
+                    for (CDIProvider cdiProvider : cdiProviders)
+                    {
+                        if (highestCdi == null || cdiProvider.getPriority() > ordinal)
+                        {
+                            highestCdi = cdiProvider.getCDI();
+                        }
+                    }
+
+                    INSTANCE = highestCdi;
+                }
+            }
         }
         return INSTANCE; //X TODO implement!
     }

Modified: geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDIProvider.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDIProvider.java?rev=1796298&r1=1796297&r2=1796298&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDIProvider.java
(original)
+++ geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDIProvider.java
Fri May 26 16:25:08 2017
@@ -25,7 +25,15 @@ package javax.enterprise.inject.spi;
  *
  * @since 1.1
  */
-public interface CDIProvider
+public interface CDIProvider extends Prioritized
 {
+    int DEFAULT_CDI_PROVIDER_PRIORITY = 0;
+
     CDI<Object> getCDI();
+
+    @Override
+    default int getPriority()
+    {
+        return DEFAULT_CDI_PROVIDER_PRIORITY;
+    }
 }



Mime
View raw message