cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r532594 - in /incubator/cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/ tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/intern...
Date Thu, 26 Apr 2007 03:44:45 GMT
Author: mmao
Date: Wed Apr 25 20:44:44 2007
New Revision: 532594

URL: http://svn.apache.org/viewvc?view=rev&rev=532594
Log:
CXF-545 Set the serviceName through java2wsdl using the JaxwsServiceFactoryBean

Added:
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/my_hello_soap12.wsdl
Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?view=diff&rev=532594&r1=532593&r2=532594
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Wed Apr 25 20:44:44 2007
@@ -406,6 +406,7 @@
             setDataBinding(new SourceDataBinding());
         } else {
             jaxWsConfiguration = new JaxWsServiceConfiguration();
+            jaxWsConfiguration.setServiceFactory(this);
             getServiceConfigurations().add(0, jaxWsConfiguration);
         }
         methodDispatcher = new JAXWSMethodDispatcher(implInfo);

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java?view=diff&rev=532594&r1=532593&r2=532594
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
Wed Apr 25 20:44:44 2007
@@ -21,6 +21,7 @@
 
 import java.io.File;
 import java.util.logging.Logger;
+import javax.xml.namespace.QName;
 import javax.xml.ws.BindingType;
 import javax.xml.ws.soap.SOAPBinding;
 
@@ -32,6 +33,8 @@
 import org.apache.cxf.binding.soap.SoapBindingConfiguration;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.Processor;
 import org.apache.cxf.tools.common.ToolConstants;
@@ -50,6 +53,25 @@
     private ToolContext context;
 
     public void process() throws ToolException {
+        ServiceBuilder builder = getServiceBuilder();
+        ServiceInfo service = builder.build();
+        
+        File output = getOutputFile(builder.getOutputFile(),
+                                    service.getName().getLocalPart() + ".wsdl");
+        generate(service, output);
+    }
+
+    public void generate(ServiceInfo service, File output) throws ToolException {
+        WSDLGeneratorFactory factory = WSDLGeneratorFactory.getInstance();
+        factory.setWSDLVersion(getWSDLVersion());
+
+        AbstractGenerator generator = factory.newGenerator();
+        generator.setAllowImports(context.containsKey(ToolConstants.CFG_CREATE_XSD_IMPORTS));
+        generator.setServiceModel(service);
+        generator.generate(output);
+    }
+
+    public ServiceBuilder getServiceBuilder() throws ToolException {
         init();
         ServiceBuilderFactory builderFactory = ServiceBuilderFactory.getInstance();
         builderFactory.setServiceClass(getServiceClass());
@@ -61,18 +83,16 @@
         builder.setBus(getBus());
         builder.setBindingConfig(getBindingConfig());
 
-        ServiceInfo service = builder.build();
+        ReflectionServiceFactoryBean serviceFactory = builder.getServiceFactory();
 
-        File output = getOutputFile(builder.getOutputFile(),
-                                    service.getName().getLocalPart() + ".wsdl");
-
-        WSDLGeneratorFactory factory = WSDLGeneratorFactory.getInstance();
-        factory.setWSDLVersion(getWSDLVersion());
-
-        AbstractGenerator generator = factory.newGenerator();
-        generator.setAllowImports(context.containsKey(ToolConstants.CFG_CREATE_XSD_IMPORTS));
-        generator.setServiceModel(service);
-        generator.generate(output);
+        if (!StringUtils.isEmpty(getServiceName())) {
+            QName serviceQName = serviceFactory.getServiceQName();
+            if (serviceQName != null) {
+                serviceFactory.setServiceName(new QName(serviceQName.getNamespaceURI(), getServiceName()));
+            }
+        }
+        
+        return builder;
     }
 
     protected String getTransportId() {
@@ -146,6 +166,10 @@
         return wsVersion;
     }
 
+    public String getServiceName() {
+        return (String) this.context.get(ToolConstants.CFG_SERVICENAME);
+    }
+    
     public Bus getBus() {
         return BusFactory.getDefaultBus();
     }

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java?view=diff&rev=532594&r1=532593&r2=532594
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
Wed Apr 25 20:44:44 2007
@@ -51,6 +51,7 @@
             throw new ToolException("Can not find the ServiceBulider for style: " + s, e);
         }
         builder.setServiceClass(serviceClass);
+        builder.getServiceFactory().setServiceClass(serviceClass);
         return builder;
     }
 

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?view=diff&rev=532594&r1=532593&r2=532594
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Wed Apr 25 20:44:44 2007
@@ -154,15 +154,37 @@
 
     @Test
     public void testDataBase() throws Exception {
-        ToolContext context = new ToolContext();
-        context.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.cxf523.Database");
-        context.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/db.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.cxf523.Database");
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/db.wsdl");
         
-        processor.setEnvironment(context);
+        processor.setEnvironment(env);
         processor.process();
 
         String expectedFile = getClass().getResource("expected/db.wsdl").getFile();
         assertFileEquals(new File(expectedFile), new File(output, "db.wsdl"));
     }
 
+    @Test
+    public void testGetServiceName() throws Exception {
+        processor.setEnvironment(env);
+        assertNull(processor.getServiceName());
+
+        env.put(ToolConstants.CFG_SERVICENAME, "myservice");
+        processor.setEnvironment(env);
+        assertEquals("myservice", processor.getServiceName());
+    }
+
+    @Test
+    public void testSetServiceName() throws Exception {
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.hello_world_soap12_http.Greeter");
+        env.put(ToolConstants.CFG_SOAP12, "soap12");
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/my_hello_soap12.wsdl");
+        env.put(ToolConstants.CFG_SERVICENAME, "MyService");
+        
+        processor.setEnvironment(env);
+        processor.process();
+
+        String expectedFile = getClass().getResource("expected/my_hello_soap12.wsdl").getFile();
+        assertFileEquals(new File(expectedFile), new File(output, "my_hello_soap12.wsdl"));
+    }
 }

Added: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/my_hello_soap12.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/my_hello_soap12.wsdl?view=auto&rev=532594
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/my_hello_soap12.wsdl
(added)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/my_hello_soap12.wsdl
Wed Apr 25 20:44:44 2007
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="MyService" targetNamespace="http://apache.org/hello_world_soap12_http"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://apache.org/hello_world_soap12_http"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://apache.org/hello_world_soap12_http/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+  <wsdl:types>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://apache.org/hello_world_soap12_http/types"
version="1.0">
+<xs:element name="faultDetail">
+<xs:complexType>
+<xs:sequence>
+<xs:element form="qualified" name="minor" type="xs:short"/>
+<xs:element form="qualified" name="major" type="xs:short"/>
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+<xs:element name="pingMe">
+<xs:complexType/>
+</xs:element>
+<xs:element name="pingMeResponse">
+<xs:complexType/>
+</xs:element>
+<xs:element name="sayHi">
+<xs:complexType/>
+</xs:element>
+<xs:element name="sayHiResponse">
+<xs:complexType>
+<xs:sequence>
+<xs:element form="qualified" name="responseType" type="xs:string"/>
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+</xs:schema>
+  </wsdl:types>
+  <wsdl:message name="sayHi">
+    <wsdl:part name="sayHi" element="ns2:sayHi">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="sayHiResponse">
+    <wsdl:part name="sayHiResponse" element="ns2:sayHiResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="faultDetail">
+    <wsdl:part name="faultDetail" element="ns2:faultDetail">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="pingMeResponse">
+    <wsdl:part name="pingMeResponse" element="ns2:pingMeResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="pingMe">
+    <wsdl:part name="pingMe" element="ns2:pingMe">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="Greeter">
+    <wsdl:operation name="sayHi">
+      <wsdl:input name="sayHi" message="ns1:sayHi">
+    </wsdl:input>
+      <wsdl:output name="sayHiResponse" message="ns1:sayHiResponse">
+    </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="pingMe">
+      <wsdl:input name="pingMe" message="ns1:pingMe">
+    </wsdl:input>
+      <wsdl:output name="pingMeResponse" message="ns1:pingMeResponse">
+    </wsdl:output>
+      <wsdl:fault name="faultDetail" message="ns2:faultDetail">
+    </wsdl:fault>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="MyServiceSoapBinding" type="ns1:Greeter">
+    <soap12:binding style="document" transport="http://www.w3.org/2003/05/soap/bindings/HTTP/"/>
+    <wsdl:operation name="sayHi">
+      <soap12:operation soapAction="" style="document"/>
+      <wsdl:input name="sayHi">
+        <soap12:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="sayHiResponse">
+        <soap12:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="pingMe">
+      <soap12:operation soapAction="" style="document"/>
+      <wsdl:input name="pingMe">
+        <soap12:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="pingMeResponse">
+        <soap12:body use="literal"/>
+      </wsdl:output>
+      <wsdl:fault name="faultDetail">
+        <soap12:fault name="faultDetail" use="literal"/>
+      </wsdl:fault>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="MyService">
+    <wsdl:port name="GreeterPort" binding="ns1:MyServiceSoapBinding">
+      <soap12:address location="http://localhost:9090/hello"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>



Mime
View raw message