cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: CXF-5576: Initital support for CDI integration. Refactored bus detection inside CXFCdiServlet.
Date Thu, 20 Mar 2014 01:22:36 GMT
Repository: cxf
Updated Branches:
  refs/heads/master c15186dc8 -> fc5026a90


CXF-5576: Initital support for CDI integration. Refactored bus detection inside CXFCdiServlet.


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

Branch: refs/heads/master
Commit: fc5026a904e16a5377a721e4984be8fc14649608
Parents: c15186d
Author: reta <drreta@gmail.com>
Authored: Wed Mar 19 21:22:21 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Wed Mar 19 21:22:21 2014 -0400

----------------------------------------------------------------------
 .../java/org/apache/cxf/cdi/CXFCdiServlet.java   | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/fc5026a9/integration/cdi/src/main/java/org/apache/cxf/cdi/CXFCdiServlet.java
----------------------------------------------------------------------
diff --git a/integration/cdi/src/main/java/org/apache/cxf/cdi/CXFCdiServlet.java b/integration/cdi/src/main/java/org/apache/cxf/cdi/CXFCdiServlet.java
index 869ef88..be93b8a 100644
--- a/integration/cdi/src/main/java/org/apache/cxf/cdi/CXFCdiServlet.java
+++ b/integration/cdi/src/main/java/org/apache/cxf/cdi/CXFCdiServlet.java
@@ -18,10 +18,14 @@
  */
 package org.apache.cxf.cdi;
 
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.CDI;
 import javax.servlet.ServletConfig;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
 
@@ -34,12 +38,21 @@ public class CXFCdiServlet extends CXFNonSpringServlet {
     
     @Override
     protected void loadBus(ServletConfig servletConfig) {
+        Bus bus = null;
         final BeanManager beanManager = CDI.current().getBeanManager();        
         if (beanManager != null) {
-            final JAXRSCdiResourceExtension extension = beanManager.getExtension(JAXRSCdiResourceExtension.class);
-            if (extension != null) {
-                setBus(extension.getBus());
+            final Set< Bean< ? > > candidates = beanManager.getBeans(CdiBusBean.CXF);
+            
+            if (!candidates.isEmpty()) {
+                final Bean< ? > candidate = candidates.iterator().next();
+                
+                bus = (Bus)beanManager.getReference(candidate, Bus.class, 
+                    beanManager.createCreationalContext(candidate));                
             }
+        } 
+        
+        if (bus != null) {
+            setBus(bus);
         } else {
             busCreated = true;
             setBus(BusFactory.newInstance().createBus());


Mime
View raw message