Author: veithen
Date: Wed Sep 19 19:34:55 2012
New Revision: 1387718

URL: http://svn.apache.org/viewvc?rev=1387718&view=rev
Log:
AXIS-2877:
 * Ensure that Wsdl2javaAntTask sets up the class loader before attempting to 
set the custom GeneratorFactory.
 * Change the class loader delegation mode to parent-first so that the custom 
GeneratorFactory can be loaded even if the nested <classpath> contains the Axis 
JARs.

Added:
    axis/axis1/java/trunk/axis-ant/src/test/ant/generatorfactory/
    axis/axis1/java/trunk/axis-ant/src/test/ant/generatorfactory/build.xml   
(with props)
    axis/axis1/java/trunk/axis-ant/src/test/java/org/
    axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/
    axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/
    axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/
    axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/
    axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/
    
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/CustomGeneratorFactoryTest.java
   (with props)
    
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyGeneratorFactory.java
   (with props)
    
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceImplWriter.java
   (with props)
    
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceWriter.java
   (with props)
    axis/axis1/java/trunk/axis-ant/src/test/wsdl/generatorfactory/
    axis/axis1/java/trunk/axis-ant/src/test/wsdl/generatorfactory/sample.wsdl
Modified:
    axis/axis1/java/trunk/axis-ant/pom.xml
    
axis/axis1/java/trunk/axis-ant/src/main/java/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java
    axis/axis1/java/trunk/pom.xml
    axis/axis1/java/trunk/samples/integrationguide-sample/pom.xml

Modified: axis/axis1/java/trunk/axis-ant/pom.xml
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-ant/pom.xml?rev=1387718&r1=1387717&r2=1387718&view=diff
==============================================================================
--- axis/axis1/java/trunk/axis-ant/pom.xml (original)
+++ axis/axis1/java/trunk/axis-ant/pom.xml Wed Sep 19 19:34:55 2012
@@ -55,6 +55,11 @@
             <artifactId>xmlunit</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
@@ -75,6 +80,7 @@
                                 <ant antfile="src/test/ant/clash/build.xml" 
target="test" inheritrefs="true" />
                                 <ant antfile="src/test/ant/extra/build.xml" 
target="test" inheritrefs="true" />
                                 <ant antfile="src/test/ant/filegen/build.xml" 
target="test" inheritrefs="true" />
+                                <ant 
antfile="src/test/ant/generatorfactory/build.xml" target="test" 
inheritrefs="true" />
                                 <ant antfile="src/test/ant/header/build.xml" 
target="test" inheritrefs="true" />
                                 <ant antfile="src/test/ant/literal/build.xml" 
target="test" inheritrefs="true" />
                                 <ant 
antfile="src/test/ant/multibinding/build.xml" target="test" inheritrefs="true" 
/>

Modified: 
axis/axis1/java/trunk/axis-ant/src/main/java/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-ant/src/main/java/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java?rev=1387718&r1=1387717&r2=1387718&view=diff
==============================================================================
--- 
axis/axis1/java/trunk/axis-ant/src/main/java/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java
 (original)
+++ 
axis/axis1/java/trunk/axis-ant/src/main/java/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java
 Wed Sep 19 19:34:55 2012
@@ -210,6 +210,17 @@ public class Wsdl2javaAntTask extends Ta
             // Instantiate the emitter
             Emitter emitter = createEmitter();
 
+            if (classpath != null) {
+                AntClassLoader cl = new AntClassLoader(
+                        getClass().getClassLoader(),
+                        getProject(),
+                        classpath,
+                        true);
+                log("Using CLASSPATH " + cl.getClasspath(),
+                        Project.MSG_VERBOSE);
+                ClassUtils.setDefaultClassLoader(cl);
+            }
+
             //extract the scope
             Scope scope = Scope.getScope(deployScope, null);
             if (scope != null) {
@@ -253,17 +264,6 @@ public class Wsdl2javaAntTask extends Ta
                        
emitter.setImplementationClassName(implementationClassName);
 
             Authenticator.setDefault(new DefaultAuthenticator(username, 
password));
-            if (classpath != null) {
-                AntClassLoader cl = new AntClassLoader(
-                        getClass().getClassLoader(),
-                        getProject(),
-                        classpath,
-                        false);
-                log("Using CLASSPATH " + cl.getClasspath(),
-                        Project.MSG_VERBOSE);
-                ClassUtils.setDefaultClassLoader(cl);
-            }
-
             try {
                 if(url.indexOf(':') == -1)
                     url = getProject().resolveFile(url).getAbsolutePath();

Added: axis/axis1/java/trunk/axis-ant/src/test/ant/generatorfactory/build.xml
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-ant/src/test/ant/generatorfactory/build.xml?rev=1387718&view=auto
==============================================================================
--- axis/axis1/java/trunk/axis-ant/src/test/ant/generatorfactory/build.xml 
(added)
+++ axis/axis1/java/trunk/axis-ant/src/test/ant/generatorfactory/build.xml Wed 
Sep 19 19:34:55 2012
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+  ~ 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.
+  -->
+<project>
+    <target name="test">
+        <!-- Tests custom GeneratorFactory; regression test for AXIS-2877 -->
+        <wsdl2java url="src/test/wsdl/generatorfactory/sample.wsdl"
+                   output="${project.build.directory}/work"
+                   factory="org.apache.axis.tools.ant.wsdl.MyGeneratorFactory">
+            <classpath>
+                <path refid="maven.test.classpath"/>
+            </classpath>
+        </wsdl2java>
+    </target>
+</project>

Propchange: 
axis/axis1/java/trunk/axis-ant/src/test/ant/generatorfactory/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/CustomGeneratorFactoryTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/CustomGeneratorFactoryTest.java?rev=1387718&view=auto
==============================================================================
--- 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/CustomGeneratorFactoryTest.java
 (added)
+++ 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/CustomGeneratorFactoryTest.java
 Wed Sep 19 19:34:55 2012
@@ -0,0 +1,32 @@
+/*
+ * 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.axis.tools.ant.wsdl;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+
+public class CustomGeneratorFactoryTest extends TestCase {
+    public void test() throws Exception {
+        File file = new File(System.getProperty("basedir", "."), 
"target/work/com/example/stockquote_wsdl/StockQuoteServiceLocator.java");
+        assertTrue(FileUtils.readFileToString(file).contains("My header 
comment"));
+    }
+}
\ No newline at end of file

Propchange: 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/CustomGeneratorFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyGeneratorFactory.java
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyGeneratorFactory.java?rev=1387718&view=auto
==============================================================================
--- 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyGeneratorFactory.java
 (added)
+++ 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyGeneratorFactory.java
 Wed Sep 19 19:34:55 2012
@@ -0,0 +1,46 @@
+/*
+ * 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.axis.tools.ant.wsdl;
+
+import javax.wsdl.Service;
+
+import org.apache.axis.wsdl.gen.Generator;
+import org.apache.axis.wsdl.gen.NoopGenerator;
+import org.apache.axis.wsdl.symbolTable.ServiceEntry;
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.toJava.Emitter;
+import org.apache.axis.wsdl.toJava.JavaGeneratorFactory;
+
+public class MyGeneratorFactory extends JavaGeneratorFactory {
+    public MyGeneratorFactory(Emitter emitter) {
+        super(emitter);
+    }
+
+    public Generator getGenerator(Service service, SymbolTable symbolTable) {
+        if (include(service.getQName())) {
+            Generator writer = new MyServiceWriter(emitter, service, 
symbolTable);
+            ServiceEntry sEntry = 
symbolTable.getServiceEntry(service.getQName());
+            serviceWriters.addStuff(writer, sEntry, symbolTable);
+            return serviceWriters;
+        }
+        else {
+            return new NoopGenerator();
+        }
+    }
+}

Propchange: 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyGeneratorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceImplWriter.java
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceImplWriter.java?rev=1387718&view=auto
==============================================================================
--- 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceImplWriter.java
 (added)
+++ 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceImplWriter.java
 Wed Sep 19 19:34:55 2012
@@ -0,0 +1,39 @@
+/*
+ * 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.axis.tools.ant.wsdl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import org.apache.axis.wsdl.symbolTable.ServiceEntry;
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.toJava.Emitter;
+import org.apache.axis.wsdl.toJava.JavaServiceImplWriter;
+
+public class MyServiceImplWriter extends JavaServiceImplWriter {
+    public MyServiceImplWriter(Emitter emitter, ServiceEntry sEntry, 
SymbolTable symbolTable) {
+        super(emitter, sEntry, symbolTable);
+    }
+
+    protected void writeHeaderComments(PrintWriter pw) throws IOException {
+        pw.println("/**");
+        pw.println(" * My header comment");
+        pw.println(" */");
+    }
+}

Propchange: 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceImplWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceWriter.java
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceWriter.java?rev=1387718&view=auto
==============================================================================
--- 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceWriter.java
 (added)
+++ 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceWriter.java
 Wed Sep 19 19:34:55 2012
@@ -0,0 +1,40 @@
+/*
+ * 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.axis.tools.ant.wsdl;
+
+import javax.wsdl.Service;
+
+import org.apache.axis.wsdl.symbolTable.ServiceEntry;
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.toJava.Emitter;
+import org.apache.axis.wsdl.toJava.JavaServiceWriter;
+
+public class MyServiceWriter extends JavaServiceWriter {
+    public MyServiceWriter(Emitter emitter, Service service, SymbolTable 
symbolTable) {
+        super(emitter, service, symbolTable);
+    }
+
+    protected void setGenerators() {
+        super.setGenerators();
+        if (serviceImplWriter != null) {
+            ServiceEntry sEntry = 
symbolTable.getServiceEntry(service.getQName());
+            serviceImplWriter = new MyServiceImplWriter(emitter, sEntry, 
symbolTable);
+        }
+    }
+}

Propchange: 
axis/axis1/java/trunk/axis-ant/src/test/java/org/apache/axis/tools/ant/wsdl/MyServiceWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis1/java/trunk/axis-ant/src/test/wsdl/generatorfactory/sample.wsdl
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-ant/src/test/wsdl/generatorfactory/sample.wsdl?rev=1387718&view=auto
==============================================================================
--- axis/axis1/java/trunk/axis-ant/src/test/wsdl/generatorfactory/sample.wsdl 
(added)
+++ axis/axis1/java/trunk/axis-ant/src/test/wsdl/generatorfactory/sample.wsdl 
Wed Sep 19 19:34:55 2012
@@ -0,0 +1,64 @@
+<definitions name="StockQuote"
+
+targetNamespace="http://example.com/stockquote.wsdl";
+          xmlns:tns="http://example.com/stockquote.wsdl";
+          xmlns:xsd1="http://example.com/stockquote.xsd";
+          xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
+          xmlns="http://schemas.xmlsoap.org/wsdl/";>
+
+    <types>
+       <schema targetNamespace="http://example.com/stockquote.xsd";
+              xmlns="http://www.w3.org/2001/XMLSchema";>
+           <element name="TradePriceRequest">
+              <complexType>
+                  <all>
+                      <element name="tickerSymbol" type="string"/>
+                  </all>
+              </complexType>
+           </element>
+           <element name="TradePrice">
+              <complexType>
+                  <all>
+                      <element name="price" type="float"/>
+                  </all>
+              </complexType>
+           </element>
+       </schema>
+    </types>
+
+    <message name="GetLastTradePriceInput">
+        <part name="body" element="xsd1:TradePriceRequest"/>
+    </message>
+
+    <message name="GetLastTradePriceOutput">
+        <part name="body" element="xsd1:TradePrice"/>
+    </message>
+
+    <portType name="StockQuotePortType">
+        <operation name="GetLastTradePrice">
+           <input message="tns:GetLastTradePriceInput"/>
+           <output message="tns:GetLastTradePriceOutput"/>
+        </operation>
+    </portType>
+
+    <binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
+        <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
+        <operation name="GetLastTradePrice">
+           <soap:operation soapAction="http://example.com/GetLastTradePrice"/>
+           <input>
+               <soap:body use="literal"/>
+           </input>
+           <output>
+               <soap:body use="literal"/>
+           </output>
+        </operation>
+    </binding>
+
+    <service name="StockQuoteService">
+        <documentation>My first service</documentation>
+        <port name="StockQuotePort" binding="tns:StockQuoteSoapBinding">
+           <soap:address location="http://example.com/stockquote"/>
+        </port>
+    </service>
+
+</definitions>

Modified: axis/axis1/java/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/pom.xml?rev=1387718&r1=1387717&r2=1387718&view=diff
==============================================================================
--- axis/axis1/java/trunk/pom.xml (original)
+++ axis/axis1/java/trunk/pom.xml Wed Sep 19 19:34:55 2012
@@ -88,6 +88,11 @@
                 <artifactId>log4j</artifactId>
                 <version>1.2.8</version>
             </dependency>
+            <dependency>
+                <groupId>commons-io</groupId>
+                <artifactId>commons-io</artifactId>
+                <version>1.4</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
     <prerequisites>

Modified: axis/axis1/java/trunk/samples/integrationguide-sample/pom.xml
URL: 
http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/integrationguide-sample/pom.xml?rev=1387718&r1=1387717&r2=1387718&view=diff
==============================================================================
--- axis/axis1/java/trunk/samples/integrationguide-sample/pom.xml (original)
+++ axis/axis1/java/trunk/samples/integrationguide-sample/pom.xml Wed Sep 19 
19:34:55 2012
@@ -41,7 +41,6 @@
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>1.4</version>
         </dependency>
     </dependencies>
     <build>


Reply via email to