cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r667313 - in /cxf/trunk/rt: core/src/main/java/org/apache/cxf/bus/spring/ core/src/main/java/org/apache/cxf/configuration/spring/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/ f...
Date Fri, 13 Jun 2008 02:02:04 GMT
Author: dkulp
Date: Thu Jun 12 19:02:03 2008
New Revision: 667313

URL: http://svn.apache.org/viewvc?rev=667313&view=rev
Log:
[CXF-1633] If no bus found in the application context so the default bus needs to be used,
we'll wire the application context into the Configurer in the default bus so configuration
will be picked up.

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsProxyFactoryBeanDefinitionParser.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
Thu Jun 12 19:02:03 2008
@@ -26,8 +26,10 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.apache.cxf.configuration.spring.BusWiringType;
+import org.apache.cxf.configuration.spring.ConfigurerImpl;
 import org.apache.cxf.helpers.CastUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -36,6 +38,8 @@
 import org.springframework.beans.factory.config.ConstructorArgumentValues;
 import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
 import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
 
 /**
  * BeanFactoryPostProcessor that looks for any bean definitions that have the
@@ -51,25 +55,34 @@
 public class BusWiringBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
 
     private static final Logger LOG = LogUtils.getL7dLogger(BusWiringBeanFactoryPostProcessor.class);
+    Bus bus;
+    
+    public BusWiringBeanFactoryPostProcessor() {
+    }
 
+    public BusWiringBeanFactoryPostProcessor(Bus b) {
+        bus = b;
+    }
     public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) throws BeansException
{
+        Object inject = bus;
         if (factory.containsBeanDefinition(Bus.DEFAULT_BUS_ID)) {
-            for (String beanName : factory.getBeanDefinitionNames()) {
-                LOG.fine("Checking bean " + beanName);
-                BeanDefinition beanDefinition = factory.getBeanDefinition(beanName);
-                if (BusWiringType.PROPERTY == beanDefinition
-                    .getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE)) {
-                    LOG.fine("Found " + AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE +
" attribute "
-                             + BusWiringType.PROPERTY + " on bean " + beanName);
-                    beanDefinition.getPropertyValues()
-                        .addPropertyValue("bus", new RuntimeBeanReference(Bus.DEFAULT_BUS_ID));
-                } else if (BusWiringType.CONSTRUCTOR == beanDefinition
-                    .getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE)) {
-                    LOG.fine("Found " + AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE +
" attribute "
-                             + BusWiringType.CONSTRUCTOR + " on bean " + beanName);
-                    ConstructorArgumentValues constructorArgs = beanDefinition.getConstructorArgumentValues();
-                    insertConstructorArg(constructorArgs, new RuntimeBeanReference(Bus.DEFAULT_BUS_ID));
-                }
+            inject = new RuntimeBeanReference(Bus.DEFAULT_BUS_ID);
+        }
+        for (String beanName : factory.getBeanDefinitionNames()) {
+            LOG.fine("Checking bean " + beanName);
+            BeanDefinition beanDefinition = factory.getBeanDefinition(beanName);
+            if (BusWiringType.PROPERTY == beanDefinition
+                .getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE)) {
+                LOG.fine("Found " + AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE + " attribute
"
+                         + BusWiringType.PROPERTY + " on bean " + beanName);
+                beanDefinition.getPropertyValues()
+                    .addPropertyValue("bus", inject);
+            } else if (BusWiringType.CONSTRUCTOR == beanDefinition
+                .getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE)) {
+                LOG.fine("Found " + AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE + " attribute
"
+                         + BusWiringType.CONSTRUCTOR + " on bean " + beanName);
+                ConstructorArgumentValues constructorArgs = beanDefinition.getConstructorArgumentValues();
+                insertConstructorArg(constructorArgs, inject);
             }
         }
     }
@@ -98,4 +111,15 @@
         }
         constructorArgs.addIndexedArgumentValue(0, valueToInsert);
     }
+    
+    public static void updateBusReferencesInContext(Bus bus, ApplicationContext ctx) {
+        Configurer conf = bus.getExtension(Configurer.class);
+        if (conf instanceof ConfigurerImpl) {
+            ((ConfigurerImpl)conf).addApplicationContext(ctx);
+        }
+        if (ctx instanceof ConfigurableApplicationContext) {
+            ConfigurableApplicationContext cctx = (ConfigurableApplicationContext)ctx;
+            new BusWiringBeanFactoryPostProcessor(bus).postProcessBeanFactory(cctx.getBeanFactory());
+        }
+    }
 }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
Thu Jun 12 19:02:03 2008
@@ -22,6 +22,8 @@
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -44,7 +46,7 @@
     
     private static final Logger LOG = LogUtils.getL7dLogger(ConfigurerImpl.class);
 
-    private ApplicationContext appContext;
+    private Set<ApplicationContext> appContexts;
     private final Map<String, String> wildCardBeanDefinitions = new HashMap<String,
String>();
     
     public ConfigurerImpl() {
@@ -56,24 +58,26 @@
     }
         
     private void initWildcardDefinitionMap() {
-        if (null != appContext) {
-            for (String n : appContext.getBeanDefinitionNames()) {
-                if (isWildcardBeanName(n)) {
-                    AutowireCapableBeanFactory bf = appContext.getAutowireCapableBeanFactory();
-                    BeanDefinitionRegistry bdr = (BeanDefinitionRegistry) bf;
-                    BeanDefinition bd = bdr.getBeanDefinition(n);
-                    String className = bd.getBeanClassName();
-                    if (null != className) {
-                        if (!wildCardBeanDefinitions.containsKey(className)) {
-                            wildCardBeanDefinitions.put(className, n);
+        if (null != appContexts) {
+            for (ApplicationContext appContext : appContexts) {
+                for (String n : appContext.getBeanDefinitionNames()) {
+                    if (isWildcardBeanName(n)) {
+                        AutowireCapableBeanFactory bf = appContext.getAutowireCapableBeanFactory();
+                        BeanDefinitionRegistry bdr = (BeanDefinitionRegistry) bf;
+                        BeanDefinition bd = bdr.getBeanDefinition(n);
+                        String className = bd.getBeanClassName();
+                        if (null != className) {
+                            if (!wildCardBeanDefinitions.containsKey(className)) {
+                                wildCardBeanDefinitions.put(className, n);
+                            } else {
+                                LogUtils.log(LOG, Level.WARNING, "ONE_WILDCARD_BEAN_ID_PER_CLASS_MSG",

+                                             new String[]{wildCardBeanDefinitions.get(className),
+                                                          className,
+                                                          n});   
+                            }
                         } else {
-                            LogUtils.log(LOG, Level.WARNING, "ONE_WILDCARD_BEAN_ID_PER_CLASS_MSG",

-                                         new String[]{wildCardBeanDefinitions.get(className),
-                                                      className,
-                                                      n});   
+                            LogUtils.log(LOG, Level.WARNING, "WILDCARD_BEAN_ID_WITH_NO_CLASS_MSG",
n); 
                         }
-                    } else {
-                        LogUtils.log(LOG, Level.WARNING, "WILDCARD_BEAN_ID_WITH_NO_CLASS_MSG",
n); 
                     }
                 }
             }
@@ -84,9 +88,9 @@
         configureBean(null, beanInstance);
     }
     
-    public void configureBean(String bn, Object beanInstance) {
+    public synchronized void configureBean(String bn, Object beanInstance) {
 
-        if (null == appContext) {
+        if (null == appContexts) {
             return;
         }
         
@@ -110,6 +114,12 @@
             }
         });
         
+        for (ApplicationContext appContext : appContexts) {
+            if (appContext.containsBean(bn)) {
+                this.setBeanFactory(appContext.getAutowireCapableBeanFactory());
+            }
+        }
+        
         try {
             super.configureBean(beanInstance);
             if (LOG.isLoggable(Level.FINE)) {
@@ -177,9 +187,15 @@
     }
     
     public final void setApplicationContext(ApplicationContext ac) {
-        appContext = ac;
-        setBeanFactory(appContext.getAutowireCapableBeanFactory());
-        initWildcardDefinitionMap();
+        appContexts = new CopyOnWriteArraySet<ApplicationContext>();
+        addApplicationContext(ac);
+        setBeanFactory(ac.getAutowireCapableBeanFactory());
+    }
+    public final void addApplicationContext(ApplicationContext ac) {
+        if (!appContexts.contains(ac)) {
+            appContexts.add(ac);
+            initWildcardDefinitionMap();
+        }
     }
 
     public Class<?> getRegistrationType() {

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java Thu Jun
12 19:02:03 2008
@@ -135,6 +135,13 @@
         this(bus, implementor, (String) null);
     }
     
+    public void setBus(Bus b) {
+        bus = b;
+    }
+    public Bus getBus() {
+        return bus;
+    }
+    
     public Binding getBinding() {
         return ((JaxWsEndpointImpl) getEndpoint()).getJaxwsBinding();
     }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
Thu Jun 12 19:02:03 2008
@@ -27,6 +27,7 @@
 
 import org.apache.cxf.common.injection.ResourceInjector;
 import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientFactoryBean;
 import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.interceptor.Interceptor;
@@ -53,6 +54,9 @@
     public JaxWsProxyFactoryBean() {
         super(new JaxWsClientFactoryBean());
     }
+    public JaxWsProxyFactoryBean(ClientFactoryBean fact) {
+        super(fact);
+    }
 
     public void setHandlers(List<Handler> h) {
         handlers.clear();

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
Thu Jun 12 19:02:03 2008
@@ -29,16 +29,22 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.apache.cxf.configuration.spring.BusWiringType;
 import org.apache.cxf.jaxws.EndpointImpl;
+import org.springframework.beans.BeansException;
 import org.springframework.beans.FatalBeanException;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 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 EndpointDefinitionParser extends AbstractBeanDefinitionParser {
@@ -47,7 +53,7 @@
 
     public EndpointDefinitionParser() {
         super();
-        setBeanClass(EndpointImpl.class);
+        setBeanClass(SpringEndpointImpl.class);
     }
 
     @Override
@@ -144,10 +150,31 @@
         throws BeanDefinitionStoreException {
         String id = super.resolveId(elem, definition, ctx);
         if (StringUtils.isEmpty(id)) {
-            id = getBeanClass().getName() + "--" + definition.hashCode();
+            id = EndpointImpl.class.getName() + "--" + definition.hashCode();
         }
         
         return id;
     }
+    
+    
+    public static class SpringEndpointImpl extends EndpointImpl
+        implements ApplicationContextAware {
+    
+        public SpringEndpointImpl(Object implementor) {
+            super((Bus)null, implementor);
+        }
+        public SpringEndpointImpl(Bus bus, Object implementor) {
+            super(bus, implementor);
+        }
+        
+        
+        public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (getBus() == null) {
+                Bus bus = BusFactory.getThreadDefaultBus();
+                BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
+                setBus(bus);
+            }
+        }
+    }
 
 }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsProxyFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsProxyFactoryBeanDefinitionParser.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsProxyFactoryBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsProxyFactoryBeanDefinitionParser.java
Thu Jun 12 19:02:03 2008
@@ -18,14 +18,22 @@
  */
 package org.apache.cxf.jaxws.spring;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
+import org.apache.cxf.frontend.ClientFactoryBean;
 import org.apache.cxf.frontend.spring.ClientProxyFactoryBeanDefinitionParser;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
 public class JaxWsProxyFactoryBeanDefinitionParser extends ClientProxyFactoryBeanDefinitionParser
{
 
     @Override
     protected Class getFactoryClass() {
-        return JaxWsProxyFactoryBean.class;
+        return JAXWSSpringClientProxyFactoryBean.class;
     }
 
     @Override
@@ -33,4 +41,23 @@
         return ".jaxws-client";
     }
 
+    
+    public static class JAXWSSpringClientProxyFactoryBean extends JaxWsProxyFactoryBean
+        implements ApplicationContextAware {
+
+        public JAXWSSpringClientProxyFactoryBean() {
+            super();
+        }
+        public JAXWSSpringClientProxyFactoryBean(ClientFactoryBean fact) {
+            super(fact);
+        }
+        
+        public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (getBus() == null) {
+                Bus bus = BusFactory.getThreadDefaultBus();
+                BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
+                setBus(bus);
+            }
+        }
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
Thu Jun 12 19:02:03 2008
@@ -18,10 +18,17 @@
  */
 package org.apache.cxf.jaxws.spring;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
 import org.apache.cxf.configuration.spring.StringBeanDefinitionParser;
 import org.apache.cxf.frontend.spring.ServerFactoryBeanDefinitionParser;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
 
 public class NamespaceHandler extends NamespaceHandlerSupport {
     public void init() {
@@ -33,4 +40,23 @@
         parser.setBeanClass(JaxWsServerFactoryBean.class);
         registerBeanDefinitionParser("server", parser);        
     }
+    
+    public static class SpringServerFactoryBean extends JaxWsServerFactoryBean
+        implements ApplicationContextAware {
+    
+        public SpringServerFactoryBean() {
+            super();
+        }
+        public SpringServerFactoryBean(JaxWsServiceFactoryBean fact) {
+            super(fact);
+        }
+        
+        public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (getBus() == null) {
+                Bus bus = BusFactory.getThreadDefaultBus();
+                BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
+                setBus(bus);
+            }
+        }
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
Thu Jun 12 19:02:03 2008
@@ -158,7 +158,7 @@
         boolean found = false;
         String[] names = ctx.getBeanNamesForType(EndpointImpl.class);
         for (String n : names) {
-            if (n.startsWith(EndpointImpl.class.getName())) { 
+            if (n.startsWith(EndpointImpl.class.getPackage().getName())) { 
                 found = true;
             }
         }

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser.java
Thu Jun 12 19:02:03 2008
@@ -25,10 +25,17 @@
 
 import org.w3c.dom.Element;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
 import org.apache.cxf.configuration.spring.AbstractFactoryBeanDefinitionParser;
+import org.apache.cxf.frontend.ClientFactoryBean;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.springframework.beans.BeansException;
 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 ClientProxyFactoryBeanDefinitionParser 
     extends AbstractFactoryBeanDefinitionParser {
@@ -40,7 +47,7 @@
 
     @Override
     protected Class getFactoryClass() {
-        return ClientProxyFactoryBean.class;
+        return SpringClientProxyFactoryBean.class;
     }
 
     @Override
@@ -79,4 +86,23 @@
             setFirstChildAsProperty(e, ctx, bean, name);
         }
     }
+    
+    public static class SpringClientProxyFactoryBean extends ClientProxyFactoryBean
+        implements ApplicationContextAware {
+
+        public SpringClientProxyFactoryBean() {
+            super();
+        }
+        public SpringClientProxyFactoryBean(ClientFactoryBean fact) {
+            super(fact);
+        }
+        
+        public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (getBus() == null) {
+                Bus bus = BusFactory.getThreadDefaultBus();
+                BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
+                setBus(bus);
+            }
+        }
+    }
 }

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
Thu Jun 12 19:02:03 2008
@@ -25,14 +25,21 @@
 
 import org.w3c.dom.Element;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 
+import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 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 ServerFactoryBeanDefinitionParser extends AbstractBeanDefinitionParser {
@@ -40,7 +47,7 @@
 
     public ServerFactoryBeanDefinitionParser() {
         super();
-        setBeanClass(ServerFactoryBean.class);
+        setBeanClass(SpringServerFactoryBean.class);
     }
     
     @Override
@@ -103,4 +110,22 @@
         return true;
     }
 
+    public static class SpringServerFactoryBean extends ServerFactoryBean
+        implements ApplicationContextAware {
+
+        public SpringServerFactoryBean() {
+            super();
+        }
+        public SpringServerFactoryBean(ReflectionServiceFactoryBean fact) {
+            super(fact);
+        }
+        
+        public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (getBus() == null) {
+                Bus bus = BusFactory.getThreadDefaultBus();
+                BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
+                setBus(bus);
+            }
+        }
+    }
 }

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
Thu Jun 12 19:02:03 2008
@@ -120,7 +120,7 @@
     /**
      * This constructor is called by the JettyHTTPServerEngineFactory.
      */
-    JettyHTTPServerEngine(
+    public JettyHTTPServerEngine(
         JettyHTTPServerEngineFactory fac, 
         Bus bus,
         int port) {
@@ -148,6 +148,10 @@
         bus = b;
     }
     
+    public Bus getBus() {
+        return bus;
+    }
+    
     
     /**
      * Returns the protocol "http" or "https" for which this engine

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
Thu Jun 12 19:02:03 2008
@@ -92,6 +92,10 @@
         this.bus = bus;
     }
     
+    public Bus getBus() {
+        return bus;
+    }
+    
     
     @PostConstruct
     public void registerWithBus() {

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
Thu Jun 12 19:02:03 2008
@@ -26,20 +26,27 @@
 import org.w3c.dom.NodeList;
 
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.configuration.jsse.spring.TLSServerParametersConfig;
 import org.apache.cxf.configuration.security.TLSServerParametersType;
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.apache.cxf.configuration.spring.BusWiringType;
 import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine;
+import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory;
 import org.apache.cxf.transport.http_jetty.ThreadingParameters;
 import org.apache.cxf.transports.http_jetty.configuration.TLSServerParametersIdentifiedType;
 import org.apache.cxf.transports.http_jetty.configuration.ThreadingParametersIdentifiedType;
 import org.apache.cxf.transports.http_jetty.configuration.ThreadingParametersType;
+import org.springframework.beans.BeansException;
 import org.springframework.beans.MutablePropertyValues;
 import org.springframework.beans.PropertyValue;
 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 JettyHTTPServerEngineBeanDefinitionParser extends AbstractBeanDefinitionParser
{
 
@@ -193,5 +200,30 @@
     protected Class getBeanClass(Element arg0) {
         return JettyHTTPServerEngine.class;
     }
+    
+    public static class SpringJettyHTTPServerEngine extends JettyHTTPServerEngine
+        implements ApplicationContextAware {
+        
+        public SpringJettyHTTPServerEngine(
+            JettyHTTPServerEngineFactory fac, 
+            Bus bus,
+            int port) {
+            super(fac, bus, port);
+        }
+        
+        public SpringJettyHTTPServerEngine() {
+            super();
+        }
+        
+        
+        public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (getBus() == null) {
+                Bus bus = BusFactory.getThreadDefaultBus();
+                BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
+                setBus(bus);
+            }
+        }
+    }
+        
 
 }

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java?rev=667313&r1=667312&r2=667313&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineFactoryBeanDefinitionParser.java
Thu Jun 12 19:02:03 2008
@@ -29,6 +29,9 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.configuration.jsse.spring.TLSServerParametersConfig;
@@ -42,9 +45,12 @@
 import org.apache.cxf.transports.http_jetty.configuration.ThreadingParametersType;
 
 
+import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.support.ManagedList;
 import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
 
 public class JettyHTTPServerEngineFactoryBeanDefinitionParser
         extends AbstractBeanDefinitionParser {
@@ -159,7 +165,24 @@
 
     @Override
     protected Class getBeanClass(Element arg0) {
-        return JettyHTTPServerEngineFactory.class;
+        return SpringJettyHTTPServerEngineFactory.class;
+    }
+    
+    public static class SpringJettyHTTPServerEngineFactory extends JettyHTTPServerEngineFactory

+        implements ApplicationContextAware {
+
+        public SpringJettyHTTPServerEngineFactory() {
+            super();
+        }
+        
+        public void setApplicationContext(ApplicationContext ctx) throws BeansException {
+            if (getBus() == null) {
+                Bus bus = BusFactory.getThreadDefaultBus();
+                BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
+                setBus(bus);
+                registerWithBus();
+            }
+        }
     }
 
 }



Mime
View raw message