cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r669671 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/configuration/spring/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/core/src/main/java/org/apache/cxf/transport/http/ rt/frontend/jaxws/src/main/java/org/a...
Date Thu, 19 Jun 2008 20:14:28 GMT
Author: dkulp
Date: Thu Jun 19 13:14:28 2008
New Revision: 669671

URL: http://svn.apache.org/viewvc?rev=669671&view=rev
Log:
[CXF-1660, CXF-1661] Don't register nested beans as root beans. 
Fix problems of trying to use <soap:soapBinding style="rpc"/> configuration to configure
frontend for rpc.
Cache a bunch few things in the RSFB to avoid looking up the same thing (isWrapped and isRPC)
a bunch of times for each method.

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConfiguration.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/JaxWsSoapBindingConfiguration.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java?rev=669671&r1=669670&r2=669671&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
Thu Jun 19 13:14:28 2008
@@ -173,13 +173,7 @@
 
     protected void setFirstChildAsProperty(Element element, ParserContext ctx, 
                                          BeanDefinitionBuilder bean, String propertyName)
{
-        String id = getAndRegisterFirstChild(element, ctx, bean, propertyName);
-        bean.addPropertyReference(propertyName, id);
-        
-    }
 
-    protected String getAndRegisterFirstChild(Element element, ParserContext ctx, 
-                                              BeanDefinitionBuilder bean, String propertyName)
{
         Element first = getFirstChild(element);
         
         if (first == null) {
@@ -196,25 +190,22 @@
                 if (id == null) {
                     throw new IllegalStateException("<ref> elements must have a \"bean\"
attribute!");
                 }
-                return id;
+                bean.addPropertyReference(propertyName, id);
+                return;
             } else if ("bean".equals(name)) {
                 BeanDefinitionHolder bdh = ctx.getDelegate().parseBeanDefinitionElement(first);
                 child = bdh.getBeanDefinition();
-                id = bdh.getBeanName();
+                bean.addPropertyValue(propertyName, child);
+                return;
             } else {
                 throw new UnsupportedOperationException("Elements with the name " + name
 
                                                         + " are not currently "
                                                         + "supported as sub elements of "

                                                         + element.getLocalName());
             }
-            
-        } else {
-            child = ctx.getDelegate().parseCustomElement(first, bean.getBeanDefinition());
-            id = child.toString();
         }
-       
-        ctx.getRegistry().registerBeanDefinition(id, child);
-        return id;
+        child = ctx.getDelegate().parseCustomElement(first, bean.getBeanDefinition());
+        bean.addPropertyValue(propertyName, child);
     }
 
     protected Element getFirstChild(Element element) {

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConfiguration.java?rev=669671&r1=669670&r2=669671&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConfiguration.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConfiguration.java
Thu Jun 19 13:14:28 2008
@@ -28,13 +28,18 @@
 
 public class SoapBindingConfiguration extends BindingConfiguration {
     private SoapVersion soapVersion = Soap11.getInstance();
-    private String style = "document";
+    private String style;
     private String use;
     private String transportURI = "http://schemas.xmlsoap.org/soap/http";
     private String defaultSoapAction = "";
     private boolean mtomEnabled;
     private QName bindingName;
     private String bindingNamePostfix = "SoapBinding";
+    
+    public SoapBindingConfiguration() {
+        
+    }
+    
 
     @Override
     public String getBindingId() {
@@ -63,11 +68,15 @@
         this.transportURI = transportURI;
     }
 
-    protected String getStyle() {
-        return style;
+    public boolean isSetStyle() {
+        return style != null;
+    }
+    
+    public String getStyle() {
+        return style == null ? "document" : style;
     }
 
-    protected String getStyle(OperationInfo op) {
+    public String getStyle(OperationInfo op) {
         return getStyle();
     }
 

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java?rev=669671&r1=669670&r2=669671&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java Thu
Jun 19 13:14:28 2008
@@ -69,7 +69,10 @@
     
     public WSDLQueryHandler() {
     }
-
+    public WSDLQueryHandler(Bus b) {
+        bus = b;
+    }
+    
     public String getResponseContentType(String baseUri, String ctx) {
         if (baseUri.toLowerCase().contains("?wsdl")
             || baseUri.toLowerCase().contains("?xsd=")) {

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/JaxWsSoapBindingConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/JaxWsSoapBindingConfiguration.java?rev=669671&r1=669670&r2=669671&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/JaxWsSoapBindingConfiguration.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/JaxWsSoapBindingConfiguration.java
Thu Jun 19 13:14:28 2008
@@ -41,7 +41,7 @@
     }
 
     @Override
-    protected String getStyle() {
+    public String getStyle() {
         SOAPBinding sb = getServiceClass().getAnnotation(SOAPBinding.class);
         if (sb != null) {
             if (sb.style().equals(Style.DOCUMENT)) {
@@ -72,6 +72,6 @@
                 return "encoded";
             }
         }
-        return super.getStyle();
+        return super.getUse();
     }
 }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?rev=669671&r1=669670&r2=669671&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Thu Jun 19 13:14:28 2008
@@ -694,7 +694,7 @@
         if (ann != null) {
             return ann.style().toString().toLowerCase();
         }
-        return "document";
+        return super.getStyle();
     }
     
     private boolean isDocumentBare(Method method) {
@@ -717,7 +717,7 @@
         if (ann != null) {
             return ann.style().equals(SOAPBinding.Style.RPC);
         }
-        return Boolean.FALSE;
+        return super.isRPC(method);
     }
     
     

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=669671&r1=669670&r2=669671&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 19 13:14:28 2008
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.jaxws.spring;
 
+import java.io.ByteArrayOutputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.List;
@@ -27,6 +28,7 @@
 
 import junit.framework.Assert;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.anonymous_complex_type.AnonymousComplexType;
 import org.apache.cxf.anonymous_complex_type.SplitNameResponse.Names;
@@ -46,6 +48,7 @@
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.jaxws.service.Hello;
+import org.apache.cxf.transport.http.WSDLQueryHandler;
 import org.apache.hello_world_soap_http.Greeter;
 import org.junit.After;
 import org.junit.Test;
@@ -217,16 +220,37 @@
         ClassPathXmlApplicationContext ctx = 
             new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/jaxws/spring/servers.xml"});
 
-        JaxWsServerFactoryBean bean = (JaxWsServerFactoryBean) ctx.getBean("simple");
+        JaxWsServerFactoryBean bean;
+        BindingConfiguration bc;
+        SoapBindingConfiguration sbc;
+        
+        bean = (JaxWsServerFactoryBean) ctx.getBean("inlineSoapBindingRPC");
+        assertNotNull(bean);
+        
+        bc = bean.getBindingConfig();
+        assertTrue(bc instanceof SoapBindingConfiguration);
+        sbc = (SoapBindingConfiguration) bc;
+        assertEquals("rpc", sbc.getStyle());
+
+        WSDLQueryHandler handler = new WSDLQueryHandler((Bus)ctx.getBean("cxf"));
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        handler.writeResponse("http://localhost/test?wsdl", "/test",
+                              bean.create().getEndpoint().getEndpointInfo(),
+                              bout);
+        String wsdl = bout.toString();
+        assertTrue(wsdl.contains("name=\"stringArray\""));
+        assertTrue(wsdl.contains("name=\"stringArray\""));
+        
+        bean = (JaxWsServerFactoryBean) ctx.getBean("simple");
         assertNotNull(bean);
 
         bean = (JaxWsServerFactoryBean) ctx.getBean("inlineSoapBinding");
         assertNotNull(bean);
         
-        BindingConfiguration bc = bean.getBindingConfig();
+        bc = bean.getBindingConfig();
         assertTrue(bc instanceof SoapBindingConfiguration);
-        SoapBindingConfiguration sbc = (SoapBindingConfiguration) bc;
-        assertTrue(sbc.getVersion() instanceof Soap12);
+        sbc = (SoapBindingConfiguration) bc;
+        assertTrue("Not soap version 1.2: " + sbc.getVersion(),  sbc.getVersion() instanceof
Soap12);
         
         bean = (JaxWsServerFactoryBean) ctx.getBean("inlineDataBinding");
         
@@ -300,4 +324,5 @@
         assertTrue("the soap configure should set isMtomEnabled to be true",
                    sbc.isMtomEnabled());
     }
+    
 }

Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml?rev=669671&r1=669670&r2=669671&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml Thu
Jun 19 13:14:28 2008
@@ -38,7 +38,7 @@
           </list>
       </property>
   </bean>
-  
+   
   <jaxws:server id="simple" serviceBean="#greeter" xmlns:test="urn:foo" xmlns="urn:foo"/>
 
   <bean id="greeter" class="org.apache.hello_world_soap_http.GreeterImpl"/>
@@ -109,6 +109,14 @@
     </jaxws:binding>
   </jaxws:server>
   
+  <jaxws:server id="inlineSoapBindingRPC" 
+    serviceClass="org.apache.cxf.jaxws.service.Hello"
+    address="http://localhost:8080/testrpc">
+    <jaxws:binding>
+      <soap:soapBinding style="rpc"/>
+    </jaxws:binding>
+  </jaxws:server>
+  
   <jaxws:server id="inlineDataBinding" 
     serviceClass="org.apache.cxf.jaxws.service.Hello"
     address="http://localhost:8080/test">

Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java?rev=669671&r1=669670&r2=669671&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
Thu Jun 19 13:14:28 2008
@@ -86,7 +86,8 @@
         JaxWsServiceConfiguration jwsc = (JaxWsServiceConfiguration) bean.getServiceConfigurations().get(0);
         jwsc.setServiceFactory(bean);
 
-        assertEquals("document", jwsc.getStyle());
+        assertNull(jwsc.getStyle());
+        assertEquals("document", bean.getStyle());
         assertNull(jwsc.isWrapped());
     }
 

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java?rev=669671&r1=669670&r2=669671&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
Thu Jun 19 13:14:28 2008
@@ -34,6 +34,7 @@
 import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.interceptor.AnnotationInterceptors;
 import org.apache.cxf.service.Service;
+import org.apache.cxf.service.factory.AbstractServiceConfiguration;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.factory.ServiceConstructionException;
 import org.apache.cxf.service.model.BindingInfo;
@@ -58,9 +59,29 @@
         serviceClass = sbean.getServiceClass();
         serviceName = sbean.getServiceQName(false);
         endpointName = sbean.getEndpointName(false);
+        sbean.getServiceConfigurations().add(new SoapBindingServiceConfiguration());
     }
     protected AbstractWSDLBasedEndpointFactory() {
     }
+
+    
+    private class SoapBindingServiceConfiguration extends AbstractServiceConfiguration {
+        public String getStyle() {
+            if (getBindingConfig() instanceof SoapBindingConfiguration
+                && ((SoapBindingConfiguration)getBindingConfig()).isSetStyle()) {
+                return ((SoapBindingConfiguration)getBindingConfig()).getStyle();
+            }
+            return null;
+        }
+        public Boolean isWrapped() {
+            if (getBindingConfig() instanceof SoapBindingConfiguration
+                && ((SoapBindingConfiguration)getBindingConfig()).isSetStyle()
+                && "rpc".equals(((SoapBindingConfiguration)getBindingConfig()).getStyle()))
{
+                return Boolean.FALSE;
+            }
+            return null;
+        }
+    }
     
     protected Endpoint createEndpoint() throws BusException, EndpointException {        
         serviceFactory.setFeatures(getFeatures());
@@ -292,7 +313,8 @@
                 if (bindingConfig == null) {
                     bindingConfig = new SoapBindingConfiguration();
                 }
-                if (bindingConfig instanceof SoapBindingConfiguration) {
+                if (bindingConfig instanceof SoapBindingConfiguration
+                    && !((SoapBindingConfiguration)bindingConfig).isSetStyle()) {
                     ((SoapBindingConfiguration)bindingConfig).setStyle(serviceFactory.getStyle());
                 }
             }

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=669671&r1=669670&r2=669671&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Thu Jun 19 13:14:28 2008
@@ -157,6 +157,13 @@
 
     private List<AbstractFeature> features;
     
+    private Map<Method, Boolean> wrappedCache = new HashMap<Method, Boolean>();
+    private Map<Method, Boolean> isRpcCache = new HashMap<Method, Boolean>();
+    private String styleCache;
+    private Boolean defWrappedCache;
+    
+    
+    
     public ReflectionServiceFactoryBean() {
         getServiceConfigurations().add(0, new DefaultServiceConfiguration());
 
@@ -587,7 +594,11 @@
 
             setFaultClassInfo(o, method);
         }
-        o.setProperty(METHOD_PARAM_ANNOTATIONS, method.getParameterAnnotations());
+        try {
+            o.setProperty(METHOD_PARAM_ANNOTATIONS, method.getParameterAnnotations());
+        } catch (Throwable t) {
+            t.printStackTrace();
+        }
         o.setProperty(METHOD_ANNOTATIONS, method.getAnnotations());
         Class<?>[] paramTypes = method.getParameterTypes();
         Type[] genericTypes = method.getGenericParameterTypes();
@@ -750,7 +761,7 @@
         op.setProperty(METHOD_ANNOTATIONS, m.getAnnotations());
         op.setProperty(METHOD_PARAM_ANNOTATIONS, m.getParameterAnnotations());
 
-        if (isWrapped(m)) {
+        if (!isRPC(m) && isWrapped(m)) {
             UnwrappedOperationInfo uOp = new UnwrappedOperationInfo(op);
             uOp.setProperty(METHOD_ANNOTATIONS, m.getAnnotations());
             uOp.setProperty(METHOD_PARAM_ANNOTATIONS, m.getParameterAnnotations());
@@ -1637,13 +1648,25 @@
     }
     
     protected boolean isWrapped(final Method method) {
-        for (AbstractServiceConfiguration c : serviceConfigurations) {
-            Boolean b = c.isWrapped(method);
-            if (b != null) {
-                return b.booleanValue();
+        Boolean b = wrappedCache.get(method);
+        if (b == null) {
+            if (isRPC(method)) {
+                wrappedCache.put(method, Boolean.FALSE);
+                return false;
             }
+            
+            for (AbstractServiceConfiguration c : serviceConfigurations) {
+                b = c.isWrapped(method);
+                if (b != null) {
+                    wrappedCache.put(method, b);
+                    return b.booleanValue();
+                }
+            }
+            
+            wrappedCache.put(method, Boolean.TRUE);
+            return true;            
         }
-        return true;
+        return b; 
     }
 
     protected boolean isMatchOperation(String methodNameInClass, String methodNameInWsdl)
{
@@ -2063,35 +2086,47 @@
 
     public boolean isWrapped() {
         if (this.wrappedStyle != null) {
-            return this.wrappedStyle;
+            defWrappedCache = wrappedStyle;
         }
-        for (AbstractServiceConfiguration c : serviceConfigurations) {
-            Boolean b = c.isWrapped();
-            if (b != null) {
-                return b.booleanValue();
+        if (this.defWrappedCache == null) {
+            for (AbstractServiceConfiguration c : serviceConfigurations) {
+                defWrappedCache = c.isWrapped();
+                if (defWrappedCache != null) {
+                    return defWrappedCache;
+                }
             }
+            defWrappedCache = Boolean.TRUE;
         }
-        return true;
+        return defWrappedCache;
     }
 
     public String getStyle() {
-        for (AbstractServiceConfiguration c : serviceConfigurations) {
-            String style = c.getStyle();
-            if (style != null) {
-                return style;
+        if (styleCache == null) {
+            for (AbstractServiceConfiguration c : serviceConfigurations) {
+                styleCache = c.getStyle();
+                if (styleCache != null) {
+                    return styleCache;
+                }
             }
+            styleCache = "document";
         }
-        return "document";
+        return styleCache;
     }
 
     public boolean isRPC(Method method) {
-        for (AbstractServiceConfiguration c : serviceConfigurations) {
-            Boolean b = c.isRPC(method);
-            if (b != null) {
-                return b.booleanValue();
+        Boolean b = isRpcCache.get(method);
+        if (b == null) {
+            for (AbstractServiceConfiguration c : serviceConfigurations) {
+                b = c.isRPC(method);
+                if (b != null) {
+                    isRpcCache.put(method, b);
+                    return b.booleanValue();
+                }
             }
+            b = "rpc".equals(getStyle());
+            isRpcCache.put(method, b);            
         }
-        return "rpc".equals(getStyle());
+        return b;
     }
 
     public void setWrapped(boolean style) {



Mime
View raw message