cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r812736 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
Date Wed, 09 Sep 2009 00:35:29 GMT
Author: dkulp
Date: Wed Sep  9 00:35:29 2009
New Revision: 812736

URL: http://svn.apache.org/viewvc?rev=812736&view=rev
Log:
if <cxf:bus> is used in a context that doesn't define a bus, go ahead
and create a default bus and wire it into the context

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java?rev=812736&r1=812735&r2=812736&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java Wed
Sep  9 00:35:29 2009
@@ -26,6 +26,7 @@
 import org.w3c.dom.Element;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.CXFBusImpl;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.common.util.StringUtils;
@@ -33,8 +34,12 @@
 import org.apache.cxf.configuration.spring.BusWiringType;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.interceptor.Interceptor;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
 
 public class BusDefinitionParser extends AbstractBeanDefinitionParser {
 
@@ -76,12 +81,27 @@
         return id;
     }
     @NoJSR250Annotations
-    public static class BusConfig  {
+    public static class BusConfig implements ApplicationContextAware {
         CXFBusImpl bus;
+        boolean defaultBus;
+        public BusConfig() {
+            bus = (CXFBusImpl)BusFactory.getDefaultBus();
+            defaultBus = true;
+        }
         
         public BusConfig(Bus b) {
             bus = (CXFBusImpl)b;
         }
+        
+        public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
+            if (defaultBus
+                && applicationContext.getAutowireCapableBeanFactory() instanceof
ConfigurableBeanFactory) {
+                ConfigurableBeanFactory bf = (ConfigurableBeanFactory)applicationContext
+                    .getAutowireCapableBeanFactory();
+                bf.registerSingleton("cxf", bus);
+            }
+        }
+        
         public List<Interceptor> getOutFaultInterceptors() {
             return bus.getOutFaultInterceptors();
         }
@@ -129,5 +149,6 @@
             bus.setProperties(s);
         }
 
+
     }
 }



Mime
View raw message