geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johndam...@apache.org
Subject svn commit: r1805044 - /geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDI.java
Date Mon, 14 Aug 2017 23:50:49 GMT
Author: johndament
Date: Mon Aug 14 23:50:48 2017
New Revision: 1805044

URL: http://svn.apache.org/viewvc?rev=1805044&view=rev
Log:
GERONIMO-6578 Cache the CDIProvider not CDI instance.  Clean up a bunch of TODOs.

Modified:
    geronimo/specs/trunk/geronimo-jcdi_2.0_spec/src/main/java/javax/enterprise/inject/spi/CDI.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=1805044&r1=1805043&r2=1805044&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
Mon Aug 14 23:50:48 2017
@@ -24,8 +24,6 @@ import java.util.ServiceLoader;
 /**
  * <p>Static helper class to access the {@link BeanManager}</p>
  *
- * TODO not yet implemented!
- *
  * <p>Usage:
  * <pre>
  * BeanManager bm = CDI.current().getBeanManager();
@@ -37,34 +35,34 @@ import java.util.ServiceLoader;
  */
 public abstract class CDI<T> implements Instance<T>
 {
-    private static volatile CDI INSTANCE; // temporary implementation
+    private static volatile CDIProvider PROVIDER;
 
     public static CDI<Object> current()
     {
-        if (INSTANCE == null)
+        if (PROVIDER == null)
         {
             synchronized (CDI.class)
             {
-                if (INSTANCE == null)
+                if (PROVIDER == null)
                 {
 
-                    CDI<Object> highestCdi = null;
+                    CDIProvider highestProvider = null;
                     int ordinal = -1;
 
                     ServiceLoader<CDIProvider> cdiProviders = ServiceLoader.load(CDIProvider.class);
                     for (CDIProvider cdiProvider : cdiProviders)
                     {
-                        if (highestCdi == null || cdiProvider.getPriority() > ordinal)
+                        if (highestProvider == null || cdiProvider.getPriority() > ordinal)
                         {
-                            highestCdi = cdiProvider.getCDI();
+                            highestProvider = cdiProvider;
                         }
                     }
 
-                    INSTANCE = highestCdi;
+                    PROVIDER = highestProvider;
                 }
             }
         }
-        return INSTANCE;
+        return PROVIDER.getCDI();
     }
 
     /**
@@ -78,14 +76,13 @@ public abstract class CDI<T> implements
      */
     public static void setCDIProvider(CDIProvider provider)
     {
-        //X TODO implement!
         if (provider == null)
         {
-            INSTANCE = null;
+            PROVIDER = null;
         }
         else
         {
-            INSTANCE = provider.getCDI();
+            PROVIDER = provider;
         }
     }
 



Mime
View raw message