cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r819113 - in /cxf/branches/2.2.x-fixes: ./ common/common/src/main/java/org/apache/cxf/configuration/spring/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ rt/fronten...
Date Sat, 26 Sep 2009 11:17:51 GMT
Author: dkulp
Date: Sat Sep 26 11:17:50 2009
New Revision: 819113

URL: http://svn.apache.org/viewvc?rev=819113&view=rev
Log:
Merged revisions 819092 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r819092 | dkulp | 2009-09-25 23:06:52 -0400 (Fri, 25 Sep 2009) | 1 line
  
  [CXF-2449] Add ability to @Autowire by type the jaxws:client things
........

Added:
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java
      - copied unchanged from r819092, cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsProxyFactoryBeanDefinitionParser.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/clients.xml
    cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser.java
    cxf/branches/2.2.x-fixes/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/SpringBeansTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Sep 26 11:17:50 2009
@@ -1 +1 @@
-/cxf/trunk:819016
+/cxf/trunk:819016,819092

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java?rev=819113&r1=819112&r2=819113&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
(original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
Sat Sep 26 11:17:50 2009
@@ -24,6 +24,8 @@
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
 
@@ -32,11 +34,19 @@
  * that the factory produces.
  */
 public abstract class AbstractFactoryBeanDefinitionParser extends AbstractBeanDefinitionParser
{
+    private static boolean factoriesAreAbstract = true;
+    public static void setFactoriesAreAbstract(boolean b) {
+        factoriesAreAbstract = b;
+    }
     
     @SuppressWarnings("deprecation")
     @Override
     protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean)
{
-        BeanDefinitionBuilder factoryBean = BeanDefinitionBuilder.rootBeanDefinition(getFactoryClass());
+        Class factoryClass = getFactoryClass();
+        BeanDefinitionBuilder factoryBean = bean;
+        if (!FactoryBean.class.isAssignableFrom(factoryClass)) {
+            factoryBean = BeanDefinitionBuilder.rootBeanDefinition(getFactoryClass());
+        }
 
         NamedNodeMap atts = element.getAttributes();        
         boolean createdFromAPI = false;
@@ -80,15 +90,28 @@
             id = id + getSuffix();
         }
         
-        String factoryId = id + getFactoryIdSuffix();
-        
-        ctx.getRegistry().registerBeanDefinition(factoryId, factoryBean.getBeanDefinition());
-        bean.getBeanDefinition().setAttribute("id", id);
-        bean.setFactoryBean(factoryId, "create");
+        if (FactoryBean.class.isAssignableFrom(getFactoryClass())) {
+            AbstractBeanDefinition def = factoryBean.getRawBeanDefinition().cloneBeanDefinition();
+            def.setBeanClass(getRawFactoryClass());
+            def.setAbstract(factoriesAreAbstract);
+            def.setLazyInit(true);
+            ctx.getRegistry().registerBeanDefinition(id + getFactoryIdSuffix(),
+                                                     def);
+            bean.getBeanDefinition().setAttribute("id", id);
+        } else {
+            String factoryId = id + getFactoryIdSuffix();
+            ctx.getRegistry().registerBeanDefinition(factoryId, factoryBean.getBeanDefinition());
+            bean.getBeanDefinition().setAttribute("id", id);
+            bean.setFactoryBean(factoryId, "create");
+        }
     }
 
     protected abstract Class getFactoryClass();
-    
+
+    protected Class getRawFactoryClass() {
+        return getFactoryClass();
+    }
+
     /**
      * @return The Spring ID of the factory bean.
      */

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsProxyFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsProxyFactoryBeanDefinitionParser.java?rev=819113&r1=819112&r2=819113&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsProxyFactoryBeanDefinitionParser.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/JaxWsProxyFactoryBeanDefinitionParser.java
Sat Sep 26 11:17:50 2009
@@ -26,11 +26,22 @@
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 
 import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 
 public class JaxWsProxyFactoryBeanDefinitionParser extends ClientProxyFactoryBeanDefinitionParser
{
 
+    public JaxWsProxyFactoryBeanDefinitionParser() {
+        super();
+        setBeanClass(JAXWSSpringClientProxyFactoryBean.class);
+    }
+    
+    
+    protected Class getRawFactoryClass() {
+        return JaxWsProxyFactoryBean.class;
+    }
+
     @Override
     protected Class getFactoryClass() {
         return JAXWSSpringClientProxyFactoryBean.class;
@@ -43,7 +54,7 @@
 
     
     public static class JAXWSSpringClientProxyFactoryBean extends JaxWsProxyFactoryBean
-        implements ApplicationContextAware {
+        implements ApplicationContextAware, FactoryBean {
 
         public JAXWSSpringClientProxyFactoryBean() {
             super();
@@ -59,5 +70,14 @@
                 setBus(bus);
             }
         }
+        public Object getObject() throws Exception {
+            return create();
+        }
+        public Class getObjectType() {
+            return this.getServiceClass();
+        }
+        public boolean isSingleton() {
+            return false;
+        }
     }
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java?rev=819113&r1=819112&r2=819113&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
Sat Sep 26 11:17:50 2009
@@ -37,6 +37,7 @@
 import org.apache.cxf.binding.soap.SoapBindingConfiguration;
 import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.configuration.spring.AbstractFactoryBeanDefinitionParser;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.databinding.source.SourceDataBinding;
 import org.apache.cxf.endpoint.Client;
@@ -264,9 +265,13 @@
 
     @Test
     public void testClients() throws Exception {
+        AbstractFactoryBeanDefinitionParser.setFactoriesAreAbstract(false);
         ClassPathXmlApplicationContext ctx =
             new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/jaxws/spring/clients.xml"});
 
+        ClientHolderBean greeters = (ClientHolderBean)ctx.getBean("greeters");
+        assertEquals(3, greeters.greeterCount());
+        
         Object bean = ctx.getBean("client1.proxyFactory");
         assertNotNull(bean);
 

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/clients.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/clients.xml?rev=819113&r1=819112&r2=819113&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/clients.xml
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/clients.xml
Sat Sep 26 11:17:50 2009
@@ -21,13 +21,19 @@
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xmlns:soap="http://cxf.apache.org/bindings/soap"
+      xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
+http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
 http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
-
+	
+	<context:annotation-config />
+	
   <import resource="classpath:META-INF/cxf/cxf.xml"/>
   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
+  
+  <bean class="org.apache.cxf.jaxws.spring.ClientHolderBean" id="greeters" autowire="autodetect"/>
     
   <bean class="org.apache.cxf.transport.local.LocalTransportFactory" lazy-init="false">
       <property name="transportIds">

Modified: cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser.java?rev=819113&r1=819112&r2=819113&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser.java
Sat Sep 26 11:17:50 2009
@@ -32,6 +32,7 @@
 import org.apache.cxf.frontend.ClientFactoryBean;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.springframework.context.ApplicationContext;
@@ -42,13 +43,15 @@
 
     public ClientProxyFactoryBeanDefinitionParser() {
         super();
-        setBeanClass(Object.class);
+        setBeanClass(SpringClientProxyFactoryBean.class);
     }
-
     @Override
     protected Class getFactoryClass() {
         return SpringClientProxyFactoryBean.class;
     }
+    protected Class getRawFactoryClass() {
+        return ClientProxyFactoryBean.class;
+    }
 
     @Override
     protected String getFactoryIdSuffix() {
@@ -88,7 +91,7 @@
     }
     
     public static class SpringClientProxyFactoryBean extends ClientProxyFactoryBean
-        implements ApplicationContextAware {
+        implements ApplicationContextAware, FactoryBean {
 
         public SpringClientProxyFactoryBean() {
             super();
@@ -104,5 +107,14 @@
                 setBus(bus);
             }
         }
+        public Object getObject() throws Exception {
+            return create();
+        }
+        public Class getObjectType() {
+            return this.getServiceClass();
+        }
+        public boolean isSingleton() {
+            return false;
+        }
     }
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/SpringBeansTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/SpringBeansTest.java?rev=819113&r1=819112&r2=819113&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/SpringBeansTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/simple/src/test/java/org/apache/cxf/frontend/spring/SpringBeansTest.java
Sat Sep 26 11:17:50 2009
@@ -27,6 +27,7 @@
 import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
+import org.apache.cxf.configuration.spring.AbstractFactoryBeanDefinitionParser;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.NullConduitSelector;
 import org.apache.cxf.frontend.ClientProxy;
@@ -81,6 +82,7 @@
 
     @Test
     public void testClients() throws Exception {
+        AbstractFactoryBeanDefinitionParser.setFactoriesAreAbstract(false);
         ClassPathXmlApplicationContext ctx =
             new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/frontend/spring/clients.xml"});
 



Mime
View raw message