cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r558529 - in /incubator/cxf/trunk/rt/frontend: jaxws/src/main/java/org/apache/cxf/jaxws/ jaxws/src/main/java/org/apache/cxf/jaxws/spring/ jaxws/src/main/resources/schemas/ jaxws/src/test/java/org/apache/cxf/jaxws/spring/ simple/src/main/jav...
Date Sun, 22 Jul 2007 19:08:49 GMT
Author: dandiep
Date: Sun Jul 22 12:08:46 2007
New Revision: 558529

URL: http://svn.apache.org/viewvc?view=rev&rev=558529
Log:
CXF-767: Autogenerate spring ids for endpoint/server 

CXF-817: add support for <invoker> inside <jaxws:endpoint>. Also, I added
support for setting the Invoker on ServerFactoryBean - which is where it
should've been all along. A bit too late to remove the ServiceFactoryBean.invoker
though :-)



Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/NullInvoker.java
  (with props)
Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?view=diff&rev=558529&r1=558528&r2=558529
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Sun Jul 22 12:08:46 2007
@@ -44,6 +44,7 @@
 import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.service.Service;
+import org.apache.cxf.service.invoker.Invoker;
 
 public class EndpointImpl extends javax.xml.ws.Endpoint 
     implements InterceptorProvider, Configurable {
@@ -66,7 +67,7 @@
     private Service service;
     private Map<String, Object> properties;
     private List<Source> metadata;
-    
+    private Invoker invoker;
     private Executor executor;
     private String bindingUri;
     private String wsdlLocation;
@@ -257,6 +258,7 @@
             serverFactory.setServiceBean(implementor);
             serverFactory.setBus(bus);
             serverFactory.setFeatures(features);
+            serverFactory.setInvoker(invoker);
             
             // Be careful not to override any serverfactory settings as a user might
             // have supplied their own.
@@ -296,6 +298,7 @@
             
             configureObject(endpoint.getService());
             configureObject(endpoint);
+            this.service = endpoint.getService();
             
             if (getWsdlLocation() == null) {
                 //hold onto the wsdl location so cache won't clear till we go away
@@ -409,6 +412,14 @@
 
     public void setFeatures(List<AbstractFeature> features) {
         this.features = features;
+    }
+
+    public Invoker getInvoker() {
+        return invoker;
+    }
+
+    public void setInvoker(Invoker invoker) {
+        this.invoker = invoker;
     }
     
     /*

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java?view=diff&rev=558529&r1=558528&r2=558529
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java
Sun Jul 22 12:08:46 2007
@@ -34,6 +34,8 @@
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.apache.cxf.jaxws.EndpointImpl;
 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;
 
@@ -42,6 +44,11 @@
 
     private static final String IMPLEMENTOR = "implementor";
 
+    public EndpointDefinitionParser() {
+        super();
+        setBeanClass(EndpointImpl.class);
+    }
+
     @Override
     protected String getSuffix() {
         return ".jaxws-endpoint";
@@ -125,10 +132,17 @@
             }
         }
     }
-
     @Override
-    protected Class getBeanClass(Element arg0) {
-        return EndpointImpl.class;
+    protected String resolveId(Element elem, 
+                               AbstractBeanDefinition definition, 
+                               ParserContext ctx) 
+        throws BeanDefinitionStoreException {
+        String id = super.resolveId(elem, definition, ctx);
+        if (StringUtils.isEmpty(id)) {
+            id = getBeanClass().getName() + "--" + hashCode();
+        }
+        
+        return id;
     }
 
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd?view=diff&rev=558529&r1=558528&r2=558529
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd Sun Jul 22
12:08:46 2007
@@ -41,6 +41,7 @@
             <xsd:element name="implementor" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="inInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="inFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
+            <xsd:element name="invoker" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="outInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="outFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="properties" type="beans:mapType" minOccurs="0"/>

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/NullInvoker.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/NullInvoker.java?view=auto&rev=558529
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/NullInvoker.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/NullInvoker.java
Sun Jul 22 12:08:46 2007
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxws.spring;
+
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.service.invoker.Invoker;
+
+public class NullInvoker implements Invoker {
+
+    public Object invoke(Exchange exchange, Object o) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/NullInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/NullInvoker.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/NullInvoker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java?view=diff&rev=558529&r1=558528&r2=558529
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
Sun Jul 22 12:08:46 2007
@@ -73,6 +73,13 @@
         assertNotNull(ep.getImplementor());
         assertNotNull(ep.getServer());
         
+
+        bean = ctx.getBean("inlineInvoker");
+        assertNotNull(bean);
+        ep = (EndpointImpl) bean;
+        assertTrue(ep.getInvoker() instanceof NullInvoker);
+        assertTrue(ep.getService().getInvoker() instanceof NullInvoker);
+        
         bean = ctx.getBean("epWithProps");
         assertNotNull(bean);
         
@@ -122,6 +129,16 @@
         }
         assertTrue(saaj);
         assertTrue(logging);
+        
+        // test for existence of Endpoint without an id element
+        boolean found = false;
+        String[] names = ctx.getBeanNamesForType(EndpointImpl.class);
+        for (String n : names) {
+            if (n.startsWith(EndpointImpl.class.getName())) { 
+                found = true;
+            }
+        }
+        assertTrue("Could not find server factory with autogenerated id", found);
     }
     
     @Test
@@ -141,6 +158,15 @@
         assertTrue(sbc.getVersion() instanceof Soap12);
         
         bean = (JaxWsServerFactoryBean) ctx.getBean("inlineDataBinding");
+        
+        boolean found = false;
+        String[] names = ctx.getBeanNamesForType(JaxWsServerFactoryBean.class);
+        for (String n : names) {
+            if (n.startsWith(JaxWsServerFactoryBean.class.getName())) { 
+                found = true;
+            }
+        }
+        assertTrue("Could not find server factory with autogenerated id", found);
     }
     
 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml?view=diff&rev=558529&r1=558528&r2=558529
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
Sun Jul 22 12:08:46 2007
@@ -50,6 +50,16 @@
     </jaxws:implementor>
   </jaxws:endpoint>
   
+  
+  <jaxws:endpoint id="inlineInvoker" address="http://localhost:8080/simpleWithAddress">
+    <jaxws:implementor>
+      <bean class="org.apache.hello_world_soap_http.GreeterImpl"/>
+    </jaxws:implementor>
+    <jaxws:invoker>
+      <bean class="org.apache.cxf.jaxws.spring.NullInvoker"/>
+    </jaxws:invoker>
+  </jaxws:endpoint>
+  
   <jaxws:endpoint id="epWithProps" 
     implementor="#greeter"
     address="http://localhost:8080/test">
@@ -86,4 +96,6 @@
 	</jaxws:outInterceptors>
   </jaxws:endpoint>
 
+  <jaxws:endpoint implementor="org.apache.cxf.jaxws.service.Hello"
+    address="http://localhost:8080/test"/>
 </beans>

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml?view=diff&rev=558529&r1=558528&r2=558529
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/servers.xml
Sun Jul 22 12:08:46 2007
@@ -80,4 +80,8 @@
       <bean class="org.apache.cxf.jaxb.JAXBDataBinding"/>
     </jaxws:dataBinding>
   </jaxws:server>
+  
+  <!-- We should auto generate this id -->
+  <jaxws:server serviceBean="#greeter"/>
+  
 </beans>

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java?view=diff&rev=558529&r1=558528&r2=558529
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
Sun Jul 22 12:08:46 2007
@@ -85,6 +85,7 @@
     private boolean start = true;
     private Object serviceBean;
     private List<String> schemaLocations;
+    private Invoker invoker;
     
     public ServerFactoryBean() {
         super();
@@ -109,8 +110,12 @@
                                     getDestinationFactory(), 
                                     getBindingFactory());
             
-            if (serviceBean != null) {
-                ep.getService().setInvoker(createInvoker());
+            if (invoker == null) {
+                if (serviceBean != null) {
+                    ep.getService().setInvoker(createInvoker());
+                }
+            } else {
+                ep.getService().setInvoker(invoker);
             }
             
             if (start) {
@@ -234,6 +239,14 @@
 
     public void setSchemaLocations(List<String> schemaLocations) {
         this.schemaLocations = schemaLocations;
+    }
+
+    public Invoker getInvoker() {
+        return invoker;
+    }
+
+    public void setInvoker(Invoker invoker) {
+        this.invoker = invoker;
     }
 
 }

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java?view=diff&rev=558529&r1=558528&r2=558529
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
Sun Jul 22 12:08:46 2007
@@ -23,9 +23,12 @@
 
 import org.w3c.dom.Element;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.apache.cxf.frontend.ServerFactoryBean;
 
+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;
 
@@ -63,13 +66,25 @@
     @Override
     protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean)
{
         super.doParse(element, ctx, bean);
-        
+
         bean.setInitMethodName("create");
         
         // We don't really want to delay the registration of our Server
         bean.setLazyInit(false);
     }
-   
+
+    @Override
+    protected String resolveId(Element elem, 
+                               AbstractBeanDefinition definition, 
+                               ParserContext ctx) 
+        throws BeanDefinitionStoreException {
+        String id = super.resolveId(elem, definition, ctx);
+        if (StringUtils.isEmpty(id)) {
+            id = getBeanClass().getName() + "--" + hashCode();
+        }
+        
+        return id;
+    }
 
     @Override
     protected boolean hasBusProperty() {



Mime
View raw message