cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r533072 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/helpers/ rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/common/src/main/java/org/a...
Date Fri, 27 Apr 2007 12:08:26 GMT
Author: mmao
Date: Fri Apr 27 05:08:24 2007
New Revision: 533072

URL: http://svn.apache.org/viewvc?view=rev&rev=533072
Log:
CXF-509
Wrapper bean class source generation

Added:
    incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/model/JavaInterfaceTest.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/JCodeModelFilter.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/Greeter.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperTest.java
Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaInterface.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
    incubator/cxf/trunk/tools/javato/pom.xml
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml
    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/jaxws/Messages.properties
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtilTest.java
    incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBBindErrorListener.java
    incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java (original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java Fri Apr 27 05:08:24 2007
@@ -20,11 +20,15 @@
 package org.apache.cxf.helpers;
 
 import java.io.File;
+import java.text.DecimalFormat;
 import java.util.Locale;
+import java.util.Random;
 
 public final class FileUtils {
     private static final int RETRY_SLEEP_MILLIS = 10;
-    
+    private static Random rand = new Random(System.currentTimeMillis()
+                                            + Runtime.getRuntime().freeMemory());
+
     private FileUtils() {
         
     }
@@ -102,5 +106,30 @@
     private static boolean isWindows() {
         String osName = System.getProperty("os.name").toLowerCase(Locale.US);
         return osName.indexOf("windows") > -1;
+    }
+
+    public static File createTempFile(String prefix, String suffix) {
+        return createTempFile(prefix, suffix, null, true);
+    }
+
+    public static File createTempFile(String prefix, String suffix, File parentDir,
+                               boolean deleteOnExit) {
+        File result = null;
+        String parent = (parentDir == null)
+            ? System.getProperty("java.io.tmpdir")
+            : parentDir.getPath();
+
+        DecimalFormat fmt = new DecimalFormat("#####");
+        synchronized (rand) {
+            do {
+                result = new File(parent,
+                                  prefix + fmt.format(Math.abs(rand.nextInt()))
+                                  + suffix);
+            } while (result.exists());
+        }
+        if (deleteOnExit) {
+            result.deleteOnExit();
+        }
+        return result;
     }
 }

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Fri Apr 27 05:08:24 2007
@@ -344,6 +344,7 @@
 
     protected OperationInfo createOperation(ServiceInfo serviceInfo, InterfaceInfo intf, Method m) {
         OperationInfo op = intf.addOperation(getOperationName(intf, m));
+        op.setProperty(m.getClass().getName(), m);
         op.setProperty("action", getAction(op, m));
         
         if (isWrapped(m)) {

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Fri Apr 27 05:08:24 2007
@@ -94,6 +94,7 @@
     public static final String CFG_USETYPES = "usetypes";
     public static final String CFG_CLASSNAME = "classname";
     public static final String CFG_PORTTYPE = "porttype";
+    public static final String CFG_SOURCEDIR = "sourcedir";
 
 
     // WSDL2Service Constants

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaInterface.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaInterface.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaInterface.java (original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaInterface.java Fri Apr 27 05:08:24 2007
@@ -199,5 +199,18 @@
     public void setHandlerChains(Element elem) {
         this.handlerChains = elem;
     }
-    
+
+    public void setFullClassName(String fullName) {
+        int index = fullName.lastIndexOf(".");
+        setPackageName(fullName.substring(0, index));
+        setName(fullName.substring(index + 1, fullName.length()));
+    }
+
+    public String getFullClassName() {
+        StringBuffer sb = new StringBuffer();
+        sb.append(getPackageName());
+        sb.append(".");
+        sb.append(getName());
+        return sb.toString();
+    }
 }

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java (original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java Fri Apr 27 05:08:24 2007
@@ -19,7 +19,16 @@
 
 package org.apache.cxf.tools.util;
 
-import org.w3c.dom.*;
+import java.io.File;
+import java.io.FileOutputStream;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.tools.common.ToolConstants;
 
@@ -81,5 +90,40 @@
         schemaBindings.appendChild(packagename);
 
         return schemaBindings.getParentNode().getParentNode();
+    }
+
+    /**
+     * Create the jaxb binding file to customize namespace to package mapping
+     * 
+     * @param namespace
+     * @param pkgName
+     * @return file
+     */
+    public static File getPackageMappingSchemaBindingFile(String namespace, String pkgName) {
+        Document doc = DOMUtils.createDocument();
+        Element rootElement = doc.createElement("schema");
+        rootElement.setAttribute("xmlns", ToolConstants.SCHEMA_URI);
+        rootElement.setAttribute("xmlns:jaxb", ToolConstants.NS_JAXB_BINDINGS);
+        rootElement.setAttribute("jaxb:version", "1.0");
+        rootElement.setAttribute("targetNamespace", namespace);
+        Element annoElement = doc.createElement("annotation");
+        Element appInfo = doc.createElement("appinfo");
+        Element schemaBindings = doc.createElement("jaxb:schemaBindings");
+        Element pkgElement = doc.createElement("jaxb:package");
+        pkgElement.setAttribute("name", pkgName);
+        annoElement.appendChild(appInfo);
+        appInfo.appendChild(schemaBindings);
+        schemaBindings.appendChild(pkgElement);
+        rootElement.appendChild(annoElement);
+        File tmpFile = null;
+        try {
+            tmpFile = FileUtils.createTempFile("customzied", ".xsd");
+            FileOutputStream fout = new FileOutputStream(tmpFile);
+            DOMUtils.writeXml(rootElement, fout);
+            fout.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return tmpFile;
     }
 }

Added: incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/model/JavaInterfaceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/model/JavaInterfaceTest.java?view=auto&rev=533072
==============================================================================
--- incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/model/JavaInterfaceTest.java (added)
+++ incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/model/JavaInterfaceTest.java Fri Apr 27 05:08:24 2007
@@ -0,0 +1,34 @@
+/**
+ * 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.tools.common.model;
+
+import junit.framework.TestCase;
+import org.junit.Test;
+
+public class JavaInterfaceTest extends TestCase {
+    @Test
+    public void testSetFullClassName() throws Exception {
+        String fullName = "org.apache.cxf.tools.common.model.JavaInterface";
+        JavaInterface intf = new JavaInterface();
+        intf.setFullClassName(fullName);
+        assertEquals("org.apache.cxf.tools.common.model", intf.getPackageName());
+        assertEquals("JavaInterface", intf.getName());
+    }
+}

Modified: incubator/cxf/trunk/tools/javato/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/pom.xml?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/pom.xml (original)
+++ incubator/cxf/trunk/tools/javato/pom.xml Fri Apr 27 05:08:24 2007
@@ -118,6 +118,22 @@
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-xjc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-impl</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-tools-wsdlto-databinding-jaxb</artifactId>
+	    <version>${project.version}</version>
+        </dependency>
+
+
     </dependencies>
 
     <scm>

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java (original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java Fri Apr 27 05:08:24 2007
@@ -25,6 +25,15 @@
 public abstract class AbstractGenerator<T> {
     private ServiceInfo service;
     private boolean allowImports;
+    private File outputdir;
+
+    public void setOutputBase(File out) {
+        this.outputdir = out;
+    }
+
+    public File getOutputBase() {
+        return this.outputdir;
+    }
 
     public void setServiceModel(ServiceInfo s) {
         this.service = s;

Added: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/JCodeModelFilter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/JCodeModelFilter.java?view=auto&rev=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/JCodeModelFilter.java (added)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/JCodeModelFilter.java Fri Apr 27 05:08:24 2007
@@ -0,0 +1,75 @@
+/**
+ * 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.tools.java2wsdl.generator.wsdl11;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JPackage;
+import org.apache.cxf.tools.common.model.JavaClass;
+
+public final class JCodeModelFilter {
+    final JCodeModel model;
+
+    public JCodeModelFilter(JCodeModel m) {
+        this.model = m;
+    }
+
+    public void include(List<JavaClass> included) {
+        Set<String> includedPackages = new HashSet<String>();
+        List<String> includedClasses = new ArrayList<String>();
+        
+        for (JavaClass clz : included) {
+            includedPackages.add(clz.getPackageName());
+            includedClasses.add(clz.getFullClassName());
+        }
+
+        for (Iterator<JPackage> iter = this.model.packages(); iter.hasNext();) {
+            JPackage pkg = iter.next();
+            if (!includedPackages.contains(pkg.name())) {
+                remove(pkg);
+            } else {
+                remove(pkg, includedClasses);
+            }
+        }
+    }
+
+    private void remove(JPackage pkg, List<String> includedClasses) {
+        List<JDefinedClass> toRemove = new ArrayList<JDefinedClass>();
+        for (Iterator<JDefinedClass> iter = pkg.classes(); iter.hasNext();) {
+            JDefinedClass clz = iter.next();
+            if (!includedClasses.contains(pkg.name() + "." + clz.name())) {
+                toRemove.add(clz);
+            }
+        }
+        for (JDefinedClass clz : toRemove) {
+            pkg.remove(clz);
+        }
+    }
+    
+    private void remove(JPackage pkg) {
+        remove(pkg, new ArrayList<String>());
+    }
+}

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java (original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java Fri Apr 27 05:08:24 2007
@@ -35,7 +35,18 @@
 
 public class WSDL11Generator extends AbstractGenerator<Definition> {
 
-    public Definition generate(File file) {
+    public Definition generate(final File dir) {
+        File file = getOutputBase();
+        if (file == null && dir != null) {
+            if (dir.isDirectory()) {
+                file = new File(dir, getServiceModel().getName().getLocalPart() + ".wsdl");
+            } else {
+                file = dir;
+            }
+        } else if (dir == null) {
+            file = new File(getServiceModel().getName().getLocalPart() + ".wsdl");
+        }
+
         createOutputDir(file);
         Definition def = null;
         try {

Added: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java?view=auto&rev=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java (added)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGenerator.java Fri Apr 27 05:08:24 2007
@@ -0,0 +1,162 @@
+/**
+ * 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.tools.java2wsdl.generator.wsdl11;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+import com.sun.codemodel.JCodeModel;
+import com.sun.tools.xjc.api.S2JJAXBModel;
+import com.sun.tools.xjc.api.XJC;
+import com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl;
+
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.tools.common.model.JavaClass;
+import org.apache.cxf.tools.java2wsdl.generator.AbstractGenerator;
+import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.RequestWrapper;
+import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.ResponseWrapper;
+import org.apache.cxf.tools.util.JAXBUtils;
+import org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBBindErrorListener;
+import org.apache.cxf.tools.wsdlto.databinding.jaxb.TypesCodeWriter;
+
+
+public final class WrapperBeanGenerator extends AbstractGenerator<File> {
+
+    private Class<?> serviceClass;
+    
+    public File generate(final File sourcedir) {
+        File dir = getOutputBase();
+        if (dir == null) {
+            dir = sourcedir;
+        }
+        if (dir == null) {
+            dir = new File("./");
+        }
+        generateWrapperBeanClasses(getServiceModel(), dir);
+        return sourcedir;
+    }
+
+
+    public Class<?> getServiceClass() {
+        return this.serviceClass;
+    }
+    
+    public void setServiceClass(Class<?> clz) {
+        this.serviceClass = clz;
+    }
+    
+    private List<InputSource> getExternalSchemaBindings(final Map<String, String> mapping) {
+        List<InputSource> externalSchemaBinding = new ArrayList<InputSource>();
+
+        for (String ns : mapping.keySet()) {
+            File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, mapping.get(ns));
+            externalSchemaBinding.add(new InputSource(file.toURI().toString()));
+        }
+        return externalSchemaBinding;
+    }
+    
+    private void generateWrapperBeanClasses(final ServiceInfo serviceInfo, final File dir) {
+        List<JavaClass> wrapperClasses = new ArrayList<JavaClass>();
+        Map<String, String> nsPkgMapping = new HashMap<String, String>();
+        
+        for (OperationInfo op : serviceInfo.getInterface().getOperations()) {
+            if (op.getUnwrappedOperation() != null) {
+                if (op.hasInput()) {
+                    QName wrapperBeanName = op.getInput().getMessageParts().get(0).getElementQName();
+                    
+                    RequestWrapper requestWrapper = new RequestWrapper();
+                    requestWrapper.setName(wrapperBeanName);
+                    requestWrapper.setMethod((Method) op.getProperty(Method.class.getName()));
+                    JavaClass jClass = requestWrapper.getJavaClass();
+
+                    if (requestWrapper.isWrapperAbsent()) {
+                        nsPkgMapping.put(wrapperBeanName.getNamespaceURI(), jClass.getPackageName());
+                    }
+
+                    if (requestWrapper.isWrapperBeanClassNotExist()) {
+                        wrapperClasses.add(jClass);
+                    }
+                }
+                if (op.hasOutput()) {
+                    QName wrapperBeanName = op.getOutput().getMessageParts().get(0).getElementQName();
+                    ResponseWrapper responseWrapper = new ResponseWrapper();
+                    responseWrapper.setName(wrapperBeanName);
+                    responseWrapper.setMethod((Method) op.getProperty(Method.class.getName()));
+                    JavaClass jClass = responseWrapper.getJavaClass();
+
+                    if (responseWrapper.isWrapperAbsent()) {
+                        nsPkgMapping.put(wrapperBeanName.getNamespaceURI(), jClass.getPackageName());
+                    }
+
+                    if (responseWrapper.isWrapperBeanClassNotExist()) {
+                        wrapperClasses.add(jClass);
+                    }
+                }
+            }
+        }
+
+        if (wrapperClasses.isEmpty()) {
+            return;
+        }
+
+        
+        Map<String, Element> schemas = new HashMap<String, Element>();
+        for (SchemaInfo s : serviceInfo.getSchemas()) {
+            schemas.put(s.getSchema().getTargetNamespace(), s.getElement());
+        }
+
+        SchemaCompilerImpl schemaCompiler = (SchemaCompilerImpl)XJC.createSchemaCompiler();
+        JAXBBindErrorListener listener = new JAXBBindErrorListener(false);
+        schemaCompiler.setErrorListener(listener);
+
+        Set<String> keys = schemas.keySet();
+        for (String key : keys) {
+            schemaCompiler.parseSchema(key, schemas.get(key));
+        }
+        for (InputSource is : getExternalSchemaBindings(nsPkgMapping)) {
+            schemaCompiler.parseSchema(is);
+        }
+
+        S2JJAXBModel rawJaxbModelGenCode = schemaCompiler.bind();
+        JCodeModel jcodeModel = rawJaxbModelGenCode.generateCode(null, null);
+
+        JCodeModelFilter filter = new JCodeModelFilter(jcodeModel);
+        filter.include(wrapperClasses);
+        
+        try {
+            createOutputDir(dir);
+            jcodeModel.build(new TypesCodeWriter(dir, new ArrayList<String>()));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
+}

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml (original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml Fri Apr 27 05:08:24 2007
@@ -57,6 +57,14 @@
 				</associatedArgument>
 			</option>
 
+			<option id="sourcedir" maxOccurs="1">
+			    <annotation>The directory in which the generated source files are placed</annotation>
+			    <switch>s</switch>
+			    <associatedArgument placement="afterSpace">
+				<annotation>source-directory</annotation>
+			    </associatedArgument>
+			</option>
+			
 			<option id="classpath" maxOccurs="1">
 				<annotation>
 					Specify the SEI and types class search path of

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=533072&r1=533071&r2=533072
==============================================================================
--- 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 Fri Apr 27 05:08:24 2007
@@ -20,6 +20,8 @@
 package org.apache.cxf.tools.java2wsdl.processor;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.logging.Logger;
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingType;
@@ -44,6 +46,7 @@
 import org.apache.cxf.tools.common.WSDLConstants;
 import org.apache.cxf.tools.java2wsdl.generator.AbstractGenerator;
 import org.apache.cxf.tools.java2wsdl.generator.WSDLGeneratorFactory;
+import org.apache.cxf.tools.java2wsdl.generator.wsdl11.WrapperBeanGenerator;
 import org.apache.cxf.tools.java2wsdl.processor.internal.ServiceBuilder;
 import org.apache.cxf.tools.java2wsdl.processor.internal.ServiceBuilderFactory;
 import org.apache.cxf.tools.util.AnnotationUtil;
@@ -52,35 +55,61 @@
     private static final Logger LOG = LogUtils.getL7dLogger(JavaToProcessor.class);
     private static final String DEFAULT_ADDRESS = "http://localhost:9090/hello";
     private ToolContext context;
+    private final List<AbstractGenerator> generators = new ArrayList<AbstractGenerator>();
 
+    private void customize(ServiceInfo service) {
+        if (context.containsKey(ToolConstants.CFG_TNS)) {
+            String ns = (String)context.get(ToolConstants.CFG_TNS);
+            service.setTargetNamespace(ns);
+        }
+        
+        if (context.containsKey(ToolConstants.CFG_PORT)) {
+            String portName = (String)context.get(ToolConstants.CFG_PORT);
+            EndpointInfo einfo = service.getEndpoints().iterator().next();
+            QName qn = new QName(einfo.getName().getNamespaceURI(), portName); 
+            einfo.setName(qn);
+        }
+    }
+    
     public void process() throws ToolException {
         ServiceBuilder builder = getServiceBuilder();
         ServiceInfo service = builder.build();
+
+        customize(service);
+
+        File wsdlFile = getOutputFile(builder.getOutputFile(),
+                                      service.getName().getLocalPart() + ".wsdl");
+
+        File outputDir = getOutputDir(wsdlFile);
+        
+        generators.add(getWSDLGenerator(wsdlFile));
+        generators.add(getWrapperBeanGenerator());
         
-        File output = getOutputFile(builder.getOutputFile(),
-                                    service.getName().getLocalPart() + ".wsdl");
-        generate(service, output);
+        generate(service, outputDir);
     }
 
-    public void generate(ServiceInfo service, File output) throws ToolException {
+    private AbstractGenerator getWrapperBeanGenerator() {
+        WrapperBeanGenerator generator = new WrapperBeanGenerator();
+        generator.setOutputBase(getSourceDir());
+        generator.setServiceClass(getServiceClass());
+        return generator;
+    }
+
+    private AbstractGenerator getWSDLGenerator(final File wsdlFile) {
         WSDLGeneratorFactory factory = WSDLGeneratorFactory.getInstance();
         factory.setWSDLVersion(getWSDLVersion());
 
         AbstractGenerator generator = factory.newGenerator();
         generator.setAllowImports(context.containsKey(ToolConstants.CFG_CREATE_XSD_IMPORTS));
-        if (context.containsKey(ToolConstants.CFG_TNS)) {
-            String ns = (String)context.get(ToolConstants.CFG_TNS);
-            service.setTargetNamespace(ns);
-        }
-        
-        if (context.containsKey(ToolConstants.CFG_PORT)) {
-            String portName = (String)context.get(ToolConstants.CFG_PORT);
-            EndpointInfo einfo = service.getEndpoints().iterator().next();
-            QName qn = new QName(einfo.getName().getNamespaceURI(), portName); 
-            einfo.setName(qn);
+        generator.setOutputBase(wsdlFile);
+        return generator;
+    }
+
+    public void generate(ServiceInfo service, File output) throws ToolException {
+        for (AbstractGenerator generator : generators) {
+            generator.setServiceModel(service);
+            generator.generate(output);
         }
-        generator.setServiceModel(service);
-        generator.generate(output);
     }
 
     public ServiceBuilder getServiceBuilder() throws ToolException {
@@ -136,7 +165,19 @@
         return true;
     }
 
-    protected File getOutputFile(File nameFromClz, String defaultOutputFile) {
+    private File getOutputDir(File wsdlLocation) {
+        String dir = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
+        if (dir == null) {
+            if (wsdlLocation == null) {
+                dir = "./";
+            } else {
+                dir = wsdlLocation.getParent();
+            }
+        }
+        return new File(dir);
+    }
+    
+    private File getOutputFile(File nameFromClz, String defaultOutputFile) {
         String output = (String) context.get(ToolConstants.CFG_OUTPUTFILE);
         String dir = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
         if (dir == null) {
@@ -181,6 +222,14 @@
     public String getServiceName() {
         return (String) this.context.get(ToolConstants.CFG_SERVICENAME);
     }
+
+    public File getSourceDir() {
+        String dir = (String) this.context.get(ToolConstants.CFG_SOURCEDIR);
+        if (StringUtils.isEmpty(dir)) {
+            return null;
+        }
+        return new File(dir);
+    }
     
     public Bus getBus() {
         return BusFactory.getDefaultBus();
@@ -201,4 +250,5 @@
             System.setProperty("java.class.path", newCp + File.pathSeparator + classpath);
         }
     }
+
 }

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Messages.properties?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Messages.properties (original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Messages.properties Fri Apr 27 05:08:24 2007
@@ -1,3 +1,4 @@
 LOAD_WRAPPER_CLASS_FAILED = Can not load wrapper class {0}, please check the @RequestWrapper or @ResponseWrapper and also check the class is in your classpath
 WRAPPER_CLASS_NOT_EXIST = Wrapper class not exist
-SOAPBinding_RPC_ON_METHOD = Method [{0}] processing error : SOAPBinding annotation can not be placed on method with RPC style 
\ No newline at end of file
+SOAPBinding_RPC_ON_METHOD = Method [{0}] processing error : SOAPBinding annotation can not be placed on method with RPC style 
+LOADING_WRAPPER_CLASS = Tring to load wrapper class {0}
\ No newline at end of file

Added: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java?view=auto&rev=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java (added)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java Fri Apr 27 05:08:24 2007
@@ -0,0 +1,51 @@
+/**
+ * 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.tools.java2wsdl.processor.internal.jaxws;
+
+import java.lang.reflect.Method;
+
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.tools.common.model.JavaClass;
+import org.apache.cxf.tools.util.AnnotationUtil;
+
+public class RequestWrapper extends Wrapper {
+    public boolean isWrapperAbsent(final Method method) {
+        javax.xml.ws.RequestWrapper reqWrapper = method.getAnnotation(javax.xml.ws.RequestWrapper.class);
+        return reqWrapper == null || StringUtils.isEmpty(reqWrapper.className());
+    }
+
+    public JavaClass getWrapperBeanClass(final Method method) {
+        javax.xml.ws.RequestWrapper reqWrapper = method.getAnnotation(javax.xml.ws.RequestWrapper.class);
+        String reqClassName = "";
+        String reqNs = null;
+        
+        if (!isWrapperAbsent(method)) {
+            reqClassName = reqWrapper.className().length() > 0 ? reqWrapper.className() : reqClassName;
+            reqNs = reqWrapper.targetNamespace();
+        } else {
+            reqClassName = getPackageName(method) + ".jaxws." + AnnotationUtil.capitalize(method.getName());
+        }
+
+        JavaClass jClass = new JavaClass();
+        jClass.setFullClassName(reqClassName);
+        jClass.setNamespace(reqNs);
+        return jClass;
+    }
+}

Added: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java?view=auto&rev=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java (added)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java Fri Apr 27 05:08:24 2007
@@ -0,0 +1,54 @@
+/**
+ * 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.tools.java2wsdl.processor.internal.jaxws;
+
+import java.lang.reflect.Method;
+
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.tools.common.model.JavaClass;
+import org.apache.cxf.tools.util.AnnotationUtil;
+
+public final class ResponseWrapper extends Wrapper {
+    public boolean isWrapperAbsent(final Method method) {
+        javax.xml.ws.ResponseWrapper resWrapper = method.getAnnotation(javax.xml.ws.ResponseWrapper.class);
+        return resWrapper == null || StringUtils.isEmpty(resWrapper.className());
+    }
+
+
+    public JavaClass getWrapperBeanClass(final Method method) {
+        javax.xml.ws.ResponseWrapper resWrapper = method.getAnnotation(javax.xml.ws.ResponseWrapper.class);
+        String resClassName = "";
+        String resNs = null;
+        
+        if (!isWrapperAbsent(method)) {
+            resClassName = resWrapper.className();
+            resNs = resWrapper.targetNamespace();
+        } else {
+            resClassName = getPackageName(method) + ".jaxws." 
+                + AnnotationUtil.capitalize(method.getName())
+                + "Response";
+        }
+        
+        JavaClass jClass = new JavaClass();
+        jClass.setFullClassName(resClassName);
+        jClass.setNamespace(resNs);
+        return jClass;
+    }
+}

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java (original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java Fri Apr 27 05:08:24 2007
@@ -19,35 +19,103 @@
 
 package org.apache.cxf.tools.java2wsdl.processor.internal.jaxws;
 
+import java.lang.reflect.Method;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import javax.xml.namespace.QName;
 
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.common.model.JavaClass;
 import org.apache.cxf.tools.util.AnnotationUtil;
+import org.apache.cxf.tools.util.NameUtil;
+import org.apache.cxf.tools.util.URIParserUtil;
 
 public class Wrapper {
     private static final Logger LOG = LogUtils.getL7dLogger(Wrapper.class);
-    protected String className;
-    protected String localName;
-    protected String targetNamespace;
-    protected String wrapperClass;
-
-    public Wrapper() {
+    private QName name;
+    private JavaClass javaClass;
+    private Method mehtod;
+
+    public void setMethod(Method m) {
+        this.mehtod = m;
+    }
+
+    public void setName(QName n) {
+        this.name = n;
+    }
+
+    public JavaClass getWrapperBeanClass(Method m) {
+        return new JavaClass();
     }
+    
+    protected JavaClass getWrapperBeanClass(QName wrapperBeanName) {
+        JavaClass jClass = new JavaClass();
+        if (wrapperBeanName == null) {
+            return jClass;
+        }
 
-    public Wrapper(String clz, String name, String ns) {
-        this.className = clz;
-        this.localName = name;
-        this.targetNamespace = ns;
+        String ns = wrapperBeanName.getNamespaceURI();
+        jClass.setNamespace(ns);
+        jClass.setPackageName(URIParserUtil.getPackageName(ns));
+        jClass.setName(NameUtil.mangleNameToClassName(wrapperBeanName.getLocalPart()));
+        return jClass;
+    }
+
+    private JavaClass merge(final JavaClass c1, final JavaClass c2) {
+        if (c1.getNamespace() == null) {
+            c1.setNamespace(c2.getNamespace());
+        }
+
+        if (c1.getPackageName() == null) {
+            c1.setPackageName(c2.getPackageName());
+        }
+
+        if (c1.getName() == null) {
+            c1.setName(c2.getName());
+        }
+        return c1;
+    }
+    
+    public JavaClass getJavaClass() {
+        if (javaClass == null) {
+            JavaClass jClass1 = getWrapperBeanClass(this.name);
+            JavaClass jClass2 = getWrapperBeanClass(this.mehtod);
+            javaClass = merge(jClass2, jClass1);
+        }
+        return javaClass;
+    }
+
+    protected String getPackageName(final Method m) {
+        return m.getDeclaringClass().getPackage().getName();
+    }
+
+    public boolean isWrapperAbsent() {
+        return isWrapperAbsent(this.mehtod);
+    }
+
+    public boolean isWrapperAbsent(final Method m) {
+        return false;
+    }
+
+    public boolean isWrapperBeanClassNotExist() {
+        try {
+            Message msg = new Message("LOADING_WRAPPER_CLASS", LOG, getJavaClass().getFullClassName());
+            LOG.log(Level.INFO, msg.toString());
+            getWrapperClass();
+            return false;
+        } catch (ToolException e) {
+            return true;
+        }
     }
 
     public Class getWrapperClass() {
         try {
-            return AnnotationUtil.loadClass(className, getClass().getClassLoader());
+            return AnnotationUtil.loadClass(getJavaClass().getFullClassName(),
+                                            getClass().getClassLoader());
         } catch (Exception e) {
-            Message msg = new Message("LOAD_WRAPPER_CLASS_FAILED", LOG, className);
+            Message msg = new Message("LOAD_WRAPPER_CLASS_FAILED", LOG, getJavaClass().getFullClassName());
             LOG.log(Level.WARNING, msg.toString());
             throw new ToolException(msg);
         }

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java (original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtil.java Fri Apr 27 05:08:24 2007
@@ -22,63 +22,26 @@
 import java.lang.reflect.Method;
 
 import javax.jws.Oneway;
-import javax.xml.ws.RequestWrapper;
-import javax.xml.ws.ResponseWrapper;
-
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.tools.util.AnnotationUtil;
 
 public final class WrapperUtil {
     
     private WrapperUtil() {
     }
 
-    public static Wrapper getRequestWrapper(Method method) {
-        RequestWrapper reqWrapper = method.getAnnotation(RequestWrapper.class);
-        String reqClassName = "";
-        String reqName = method.getName();
-        String reqNS = null;
-        if (reqWrapper != null && !StringUtils.isEmpty(reqWrapper.className())) {
-            reqClassName = reqWrapper.className().length() > 0 ? reqWrapper.className() : reqClassName;
-        } else {
-            reqClassName = getPackageName(method) + ".jaxws." + AnnotationUtil.capitalize(method.getName());
-        }
-
-        return new Wrapper(reqClassName, reqName, reqNS);
-    }
-
-    public static Wrapper getResponseWrapper(Method method) {
-        ResponseWrapper resWrapper = method.getAnnotation(ResponseWrapper.class);
-        String resClassName = "";
-        // rule 3.5 suffix -"Response"
-        String resName = method.getName() + "Response";
-        String resNS = null;
-        if (resWrapper != null && !StringUtils.isEmpty(resWrapper.className())) {
-            resClassName = resWrapper.className();
-        } else {
-            resClassName = getPackageName(method) + ".jaxws." 
-                + AnnotationUtil.capitalize(method.getName())
-                + "Response";
-        }
-        return new Wrapper(resClassName, resName, resNS);
-    }
-
     public static boolean isWrapperClassExists(Method method) {
-        Wrapper requestWrapper = getRequestWrapper(method);
-        Wrapper responseWrapper = getResponseWrapper(method);
-        boolean isOneWay = method.isAnnotationPresent(Oneway.class);
+        Wrapper requestWrapper = new RequestWrapper();
+        requestWrapper.setMethod(method);
         try {
             requestWrapper.getWrapperClass();
+            boolean isOneWay = method.isAnnotationPresent(Oneway.class);
             if (!isOneWay) {
+                Wrapper responseWrapper = new ResponseWrapper();
+                responseWrapper.setMethod(method);
                 responseWrapper.getWrapperClass();
             }
         } catch (Exception e) {
             return false;
         }
         return true;
-    }
-
-    private static String getPackageName(Method method) {
-        return method.getDeclaringClass().getPackage().getName();
     }
 }

Added: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/Greeter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/Greeter.java?view=auto&rev=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/Greeter.java (added)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/Greeter.java Fri Apr 27 05:08:24 2007
@@ -0,0 +1,33 @@
+/**
+ * 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.tools.fortest.withannotation.doc;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+@WebService(name = "Hello")
+public interface Greeter {
+    @WebMethod
+    @RequestWrapper(className = "org.apache.cxf.tools.fortest.withannotation.doc.SayHi")
+    @ResponseWrapper(className = "org.apache.cxf.tools.fortest.withannotation.doc.SayHiResponse")
+    String sayHi();
+}

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=533072&r1=533071&r2=533072
==============================================================================
--- 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 Fri Apr 27 05:08:24 2007
@@ -224,5 +224,53 @@
         String expectedFile = getClass().getResource("expected/my_hello_soap12.wsdl").getFile();
         assertFileEquals(new File(expectedFile), new File(output, "my_hello_soap12.wsdl"));
     }
+    @Test
+    public void testGenWrapperBeanClasses() throws Exception {
+        env.put(ToolConstants.CFG_CLASSNAME,
+                "org.apache.cxf.tools.fortest.classnoanno.docwrapped.Calculator");
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/my_calculator.wsdl");
+        
+        processor.setEnvironment(env);
+        processor.process();
+
+        String pkgBase = "org/apache/cxf/tools/fortest/classnoanno/docwrapped/jaxws";
+        File requestWrapperClass = new File(output, pkgBase + "/Add.java");
+        File responseWrapperClass = new File(output, pkgBase + "/AddResponse.java");
+        assertTrue(requestWrapperClass.exists());
+        assertTrue(responseWrapperClass.exists());
+    }
+
+    @Test
+    public void testNoNeedGenWrapperBeanClasses() throws Exception {
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.withannotation.doc.Stock");
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/my_stock.wsdl");
+        
+        processor.setEnvironment(env);
+        processor.process();
+
+        String pkgBase = "org/apache/cxf/tools/fortest/classnoanno/docwrapped/jaxws";
+        File requestWrapperClass = new File(output, pkgBase + "/Add.java");
+        File responseWrapperClass = new File(output, pkgBase + "/AddResponse.java");
+        assertFalse(requestWrapperClass.exists());
+        assertFalse(responseWrapperClass.exists());
+    }
+
+    @Test
+    public void testSetSourceDir() throws Exception {
+        env.put(ToolConstants.CFG_CLASSNAME,
+                "org.apache.cxf.tools.fortest.classnoanno.docwrapped.Calculator");
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/my_stock.wsdl");
+        env.put(ToolConstants.CFG_SOURCEDIR, output.getPath() + "/beans");
+        
+        processor.setEnvironment(env);
+        processor.process();
+
+        String pkgBase = "beans/org/apache/cxf/tools/fortest/classnoanno/docwrapped/jaxws";
+        File requestWrapperClass = new File(output, pkgBase + "/Add.java");
+        File responseWrapperClass = new File(output, pkgBase + "/AddResponse.java");
+        assertTrue(requestWrapperClass.exists());
+        assertTrue(responseWrapperClass.exists());
+    }
+
         
 }

Added: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperTest.java?view=auto&rev=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperTest.java (added)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperTest.java Fri Apr 27 05:08:24 2007
@@ -0,0 +1,109 @@
+/**
+ * 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.tools.java2wsdl.processor.internal.jaxws;
+
+import java.lang.reflect.Method;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+import org.apache.cxf.tools.common.model.JavaClass;
+import org.junit.Test;
+
+public class WrapperTest extends TestCase {
+    @Test
+    public void testGetWrapperBeanClassFromQName() {
+        QName qname = new QName("http://cxf.apache.org", "sayHi");
+
+        Wrapper wrapper = new Wrapper();
+        wrapper.setName(qname);
+
+        JavaClass jClass = wrapper.getWrapperBeanClass(qname);
+
+        assertEquals("org.apache.cxf", jClass.getPackageName());
+        assertEquals("SayHi", jClass.getName());
+        assertEquals("http://cxf.apache.org", jClass.getNamespace());
+    }
+
+    @Test
+    public void testGetWrapperBeanClassFromMethod() throws Exception {
+        String pkgName = "org.apache.cxf.tools.fortest.classnoanno.docwrapped";
+        Class stockClass = Class.forName(pkgName + ".Stock");
+        Method method = stockClass.getMethod("getPrice", String.class);
+
+        Wrapper wrapper = new Wrapper();
+        wrapper.setMethod(method);
+
+        JavaClass jClass = wrapper.getWrapperBeanClass(method);
+        assertNotNull(jClass);
+        assertNull(jClass.getPackageName());
+        assertNull(jClass.getName());
+
+        wrapper = new RequestWrapper();
+        jClass = wrapper.getWrapperBeanClass(method);
+        assertEquals("GetPrice", jClass.getName());
+        assertEquals(pkgName + ".jaxws", jClass.getPackageName());
+
+        wrapper = new ResponseWrapper();
+        jClass = wrapper.getWrapperBeanClass(method);
+        assertEquals("GetPriceResponse", jClass.getName());
+        assertEquals(pkgName + ".jaxws", jClass.getPackageName());
+    }
+    
+    @Test
+    public void testIsWrapperBeanClassNotExist() throws Exception {
+        String pkgName = "org.apache.cxf.tools.fortest.classnoanno.docwrapped";
+        Class stockClass = Class.forName(pkgName + ".Stock");
+        Method method = stockClass.getMethod("getPrice", String.class);
+        
+        Wrapper wrapper = new RequestWrapper();
+        wrapper.setMethod(method);
+        assertTrue(wrapper.isWrapperAbsent());
+        assertFalse(wrapper.isWrapperBeanClassNotExist());
+        assertEquals(pkgName + ".jaxws", wrapper.getJavaClass().getPackageName());
+        assertEquals("GetPrice", wrapper.getJavaClass().getName());
+        
+        pkgName = "org.apache.cxf.tools.fortest.withannotation.doc";
+        stockClass = Class.forName(pkgName + ".Stock");
+        method = stockClass.getMethod("getPrice", String.class);
+
+        wrapper = new RequestWrapper();
+        wrapper.setMethod(method);
+        assertFalse(wrapper.isWrapperAbsent());
+        assertFalse(wrapper.isWrapperBeanClassNotExist());
+        assertEquals(pkgName + ".jaxws", wrapper.getJavaClass().getPackageName());
+        assertEquals("GetPrice", wrapper.getJavaClass().getName());
+
+        pkgName = "org.apache.cxf.tools.fortest.withannotation.doc";
+        Class clz = Class.forName(pkgName + ".Greeter");
+        method = clz.getMethod("sayHi");
+
+        wrapper = new RequestWrapper();
+        wrapper.setMethod(method);
+        assertFalse(wrapper.isWrapperAbsent());
+        assertFalse(wrapper.isWrapperBeanClassNotExist());
+        assertEquals(pkgName, wrapper.getJavaClass().getPackageName());
+        assertEquals("SayHi", wrapper.getJavaClass().getName());
+
+        wrapper = new ResponseWrapper();
+        wrapper.setMethod(method);
+        assertEquals(pkgName, wrapper.getJavaClass().getPackageName());
+        assertEquals("SayHiResponse", wrapper.getJavaClass().getName());
+    }
+}

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtilTest.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtilTest.java (original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/WrapperUtilTest.java Fri Apr 27 05:08:24 2007
@@ -21,6 +21,7 @@
 
 import java.lang.reflect.Method;
 import junit.framework.TestCase;
+import org.junit.Test;
 
 public class WrapperUtilTest extends TestCase {
     String pkgName = "org.apache.cxf.tools.fortest.classnoanno.docwrapped";
@@ -34,26 +35,12 @@
         assertNotNull(method);
     }
 
-    public void testGetRequestWrapper() {
-        Wrapper wrapper = WrapperUtil.getRequestWrapper(method);
-        assertNotNull(wrapper);
-        assertEquals(pkgName + ".jaxws.GetPrice", wrapper.className);
-        assertEquals("getPrice", wrapper.localName);
-        assertNull(wrapper.targetNamespace);
-    }
-
-    public void testGetResponseWrapper() {
-        Wrapper wrapper = WrapperUtil.getResponseWrapper(method);
-        assertNotNull(wrapper);
-        assertEquals(pkgName + ".jaxws.GetPriceResponse", wrapper.className);
-        assertEquals("getPriceResponse", wrapper.localName);
-        assertNull(wrapper.targetNamespace);
-    }
-
+    @Test
     public void testIsWrapperClassExists() {
         assertTrue(WrapperUtil.isWrapperClassExists(method));
     }
 
+    @Test
     public void testWrapperClassNotExists() throws Exception {
         Class helloClass = Class.forName("org.apache.cxf.tools.fortest.withannotation.doc.HelloWrapped");
         assertNotNull(helloClass);

Modified: incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBBindErrorListener.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBBindErrorListener.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBBindErrorListener.java (original)
+++ incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBBindErrorListener.java Fri Apr 27 05:08:24 2007
@@ -20,17 +20,14 @@
 package org.apache.cxf.tools.wsdlto.databinding.jaxb;
 import com.sun.tools.xjc.api.ErrorListener;
 
-import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
 
-
-
 public class JAXBBindErrorListener implements ErrorListener {
-    private ToolContext env;
+    private boolean isVerbose;
     private String prefix = "Thrown by JAXB : ";
 
-    public JAXBBindErrorListener(ToolContext penv) {
-        env = penv;
+    public JAXBBindErrorListener(boolean verbose) {
+        isVerbose = verbose;
     }
 
     public void error(org.xml.sax.SAXParseException exception) {
@@ -43,13 +40,13 @@
     }
 
     public void info(org.xml.sax.SAXParseException exception) {
-        if (this.env.isVerbose()) {
+        if (this.isVerbose) {
             System.out.println("JAXB Info: " + exception.toString());
         }
     }
 
     public void warning(org.xml.sax.SAXParseException exception) {
-        if (this.env.isVerbose()) {
+        if (this.isVerbose) {
             System.err.println("JAXB parsing schema warning " + exception.toString());
         }
     }

Modified: incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?view=diff&rev=533072&r1=533071&r2=533072
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java (original)
+++ incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java Fri Apr 27 05:08:24 2007
@@ -19,7 +19,6 @@
 package org.apache.cxf.tools.wsdlto.databinding.jaxb;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -49,12 +48,12 @@
 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.helpers.DOMUtils;
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.util.ClassCollector;
+import org.apache.cxf.tools.util.JAXBUtils;
 import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
 
 public class JAXBDataBinding implements DataBindingProfile {
@@ -73,7 +72,7 @@
 
         schemaCompiler.setClassNameAllocator(allocator);
 
-        JAXBBindErrorListener listener = new JAXBBindErrorListener(context);
+        JAXBBindErrorListener listener = new JAXBBindErrorListener(context.isVerbose());
         schemaCompiler.setErrorListener(listener);
         // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
         List<InputSource> jaxbBindings = context.getJaxbBindingFile();
@@ -101,7 +100,7 @@
         } else {
             Map<String, String> nsPkgMap = context.getNamespacePackageMap();
             for (String ns : nsPkgMap.keySet()) {
-                File file = getCustomizedSchemaElement(ns, nsPkgMap.get(ns));
+                File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, nsPkgMap.get(ns));
                 InputSource ins = new InputSource(file.toURI().toString());
                 schemaCompiler.parseSchema(ins);
                 FileUtils.delete(file);
@@ -269,40 +268,5 @@
         return clone;
     }
 
-    /**
-     * Create the jaxb binding file to customize namespace to package mapping
-     * 
-     * @param namespace
-     * @param pkgName
-     * @return file
-     */
-    public File getCustomizedSchemaElement(String namespace, String pkgName) {
-        Document doc = DOMUtils.createDocument();
-        Element rootElement = doc.createElement("schema");
-        rootElement.setAttribute("xmlns", ToolConstants.SCHEMA_URI);
-        rootElement.setAttribute("xmlns:jaxb", ToolConstants.NS_JAXB_BINDINGS);
-        rootElement.setAttribute("jaxb:version", "1.0");
-        rootElement.setAttribute("targetNamespace", namespace);
-        Element annoElement = doc.createElement("annotation");
-        Element appInfo = doc.createElement("appinfo");
-        Element schemaBindings = doc.createElement("jaxb:schemaBindings");
-        Element pkgElement = doc.createElement("jaxb:package");
-        pkgElement.setAttribute("name", pkgName);
-        annoElement.appendChild(appInfo);
-        appInfo.appendChild(schemaBindings);
-        schemaBindings.appendChild(pkgElement);
-        rootElement.appendChild(annoElement);
-        File tmpFile = null;
-        try {
-            tmpFile = File.createTempFile("customzied", ".xsd");
-            FileOutputStream fout = new FileOutputStream(tmpFile);
-            DOMUtils.writeXml(rootElement, fout);
-            fout.close();
-        } catch (Exception e) {
-            Message msg = new Message("FAIL_TO_CREATE_JAXBBINIDNG_FILE", LOG);
-            throw new ToolException(msg, e);
-        }
-        return tmpFile;
-    }
 
 }



Mime
View raw message