You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by James Mao <ja...@iona.com> on 2007/07/14 09:58:44 UTC

Re: svn commit: r555978 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/tools/common/ buildtools/src/main/resources/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/common/src/main/java/org/apache/cxf/tools/common/model/ tools/com...

Hi Dan,

Why remove the DataTypeAdapter?,
The adapter class is used in the jaxb binding file which will be 
generated automatically if the sei has a java.util.Date or 
java.util.Calendar type

Or maybe you have added another class for this purpose, but i can not 
see in this commit

James

> Author: dkulp
> Date: Fri Jul 13 06:08:28 2007
> New Revision: 555978
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=555978
> Log:
> Cleanup formatting of client and impl code
> Add option to generate some default data (may not be schema compliant at this point) into client/impl to make testing easier
>
>
> Added:
>     incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/DefaultValueWriter.java   (with props)
>     incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DefaultValueProvider.java   (with props)
>     incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/RandomValueProvider.java   (with props)
> Removed:
>     incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/DataTypeAdapter.java
> Modified:
>     incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
>     incubator/cxf/trunk/buildtools/src/main/resources/cxf-checkstyle-suppressions.xml
>     incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/Messages.properties
>     incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java
>     incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java
>     incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaParameter.java
>     incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaType.java
>     incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/model/JavaParameterTest.java
>     incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJava.java
>     incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DataBindingProfile.java
>     incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
>     incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
>     incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
>     incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
>     incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
>     incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/ParameterMapper.java
>     incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/client.vm
>     incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm
>     incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/DummyDataBinding.java
>
> Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
> +++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Fri Jul 13 06:08:28 2007
> @@ -56,6 +56,7 @@
>      public static final String CFG_DEFAULT_EX = "defaultex";
>      public static final String CFG_XJC_ARGS = "xjc";
>      public static final String CFG_CATALOG = "catalog";
> +    public static final String CFG_DEFAULT_VALUES = "defaultValues";
>  
>  
>      public static final String CFG_VALIDATE_WSDL = "validate";
>
> Modified: incubator/cxf/trunk/buildtools/src/main/resources/cxf-checkstyle-suppressions.xml
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/buildtools/src/main/resources/cxf-checkstyle-suppressions.xml?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/buildtools/src/main/resources/cxf-checkstyle-suppressions.xml (original)
> +++ incubator/cxf/trunk/buildtools/src/main/resources/cxf-checkstyle-suppressions.xml Fri Jul 13 06:08:28 2007
> @@ -24,5 +24,4 @@
>      <suppress checks=".*"
>                files=".+[\\\/]generated[\\\/].+\.java"
>                />
> -    <suppress checks=".*" files="HelloNoPackage.java"/>
>  </suppressions>
>
> Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/Messages.properties
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/Messages.properties?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/Messages.properties (original)
> +++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/Messages.properties Fri Jul 13 06:08:28 2007
> @@ -18,7 +18,7 @@
>  #    under the License.
>  #
>  #
> -DIRECTORY_NOT_EXIST = Directory : {0} does not exist
> +DIRECTORY_NOT_EXIST = Directory: {0} does not exist
>  NOT_A_DIRECTORY = {0} is not a directory
>  FILE_NOT_EXIST = File does not exist
>  NOT_A_FILE = {0} is not a file
> @@ -26,6 +26,6 @@
>  
>  
>  FAIL_TO_INITIALIZE_VELOCITY_ENGINE = Fail to initialize velocity engine
> -TEMPLATE_MISSING = Can not find velocity tempalte file: {0}
> -VELOCITY_ENGINE_WRITE_ERRORS = velocity engin write errors
> -FAIL_TO_WRITE_FILE = Failed to write file : {0}
> \ No newline at end of file
> +TEMPLATE_MISSING = Can not find velocity template file: {0}
> +VELOCITY_ENGINE_WRITE_ERRORS = velocity engine write errors
> +FAIL_TO_WRITE_FILE = Failed to write file: {0}
> \ No newline at end of file
>
> Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java (original)
> +++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java Fri Jul 13 06:08:28 2007
> @@ -95,6 +95,7 @@
>          }
>  
>          VelocityWriter writer = new VelocityWriter(outputs);
> +        ctx.put("out", writer);
>          try {
>              tmpl.merge(ctx, writer);
>              writer.close();
>
> Added: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/DefaultValueWriter.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/DefaultValueWriter.java?view=auto&rev=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/DefaultValueWriter.java (added)
> +++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/DefaultValueWriter.java Fri Jul 13 06:08:28 2007
> @@ -0,0 +1,28 @@
> +/**
> + * 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 java.io.IOException;
> +import java.io.Writer;
> +
> +public interface DefaultValueWriter {
> +    void writeDefaultValue(Writer writer, String indent,
> +                           String opName, String varName) throws IOException;
> +}
>
> Propchange: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/DefaultValueWriter.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/DefaultValueWriter.java
> ------------------------------------------------------------------------------
>     svn:keywords = Rev Date
>
> Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java (original)
> +++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java Fri Jul 13 06:08:28 2007
> @@ -263,7 +263,7 @@
>              if (parameter.isHolder()) {
>                  sb.append(parameter.getHolderName());
>                  sb.append("<");
> -                sb.append(parameter.getHolderClass());
> +                sb.append(parameter.getClassName());
>                  sb.append(">");
>              } else {
>                  sb.append(parameter.getClassName());
>
> Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaParameter.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaParameter.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaParameter.java (original)
> +++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaParameter.java Fri Jul 13 06:08:28 2007
> @@ -24,7 +24,6 @@
>  
>      private boolean holder;
>      private String holderName;
> -    private String holderClass;
>      private JavaAnnotation annotation;
>      private String partName;
>  
> @@ -53,14 +52,6 @@
>          this.holderName = hn;
>      }
>  
> -    public void setHolderClass(String clz) {
> -        this.holderClass = clz;
> -    }
> -
> -    public String getHolderClass() {
> -        return this.holderClass;
> -    }
> -
>      public void setAnnotation(JavaAnnotation anno) {
>          this.annotation = anno;
>      }
> @@ -95,19 +86,6 @@
>          return sb.toString();
>      }
>      
> -    public String getDefaultTypeValue() {
> -        if (isHolder()) {
> -            StringBuffer sb = new StringBuffer();
> -            sb.append("new ");
> -            sb.append(getHolderName());
> -            sb.append("<");
> -            sb.append(getHolderClass());
> -            sb.append(">()");
> -            return sb.toString(); 
> -        }
> -        return super.getDefaultTypeValue();
> -    }
> -
>      public void setMethod(JavaMethod jm) {
>          this.javaMethod = jm;
>      }
>
> Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaType.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaType.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaType.java (original)
> +++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaType.java Fri Jul 13 06:08:28 2007
> @@ -19,13 +19,13 @@
>  
>  package org.apache.cxf.tools.common.model;
>  
> +import java.io.IOException;
> +import java.io.Writer;
>  import java.lang.reflect.Constructor;
>  import java.util.HashMap;
>  import java.util.Map;
>  import javax.xml.namespace.QName;
>  
> -import com.sun.xml.bind.api.TypeReference;
> -
>  public class JavaType {
>      
>      public static enum Style { IN, OUT, INOUT }
> @@ -40,6 +40,7 @@
>          typeMapping.put("float", "0.0f");
>          typeMapping.put("double", "0.0");
>          typeMapping.put("char", "0");
> +        typeMapping.put("java.lang.String", "\"\"");
>          
>          typeMapping.put("javax.xml.namespace.QName", "new javax.xml.namespace.QName(\"\", \"\")");
>          typeMapping.put("java.net.URI", "new java.net.URI(\"\")");
> @@ -57,10 +58,10 @@
>      protected String className;
>      protected String targetNamespace;
>      protected Style style;
> -    protected TypeReference typeRef;
>      protected boolean isHeader;
>      private QName qname;
>      private JavaInterface owner;
> +    private DefaultValueWriter dvw;
>  
>      public JavaType() {
>      }
> @@ -72,6 +73,13 @@
>          this.className = t;
>      }
>  
> +    public void setDefaultValueWriter(DefaultValueWriter w) {
> +        dvw = w;
> +    }
> +    public DefaultValueWriter getDefaultValueWriter() {
> +        return dvw;
> +    }
> +    
>      public void setQName(QName qn) {
>          this.qname = qn;
>      }
> @@ -88,7 +96,22 @@
>          return this.className;
>      }
>  
> -    public String getDefaultTypeValue() {
> +    public void writeDefaultValue(Writer writer, String indent,
> +                                  String opName, String varName) throws IOException {
> +        if (dvw != null) {
> +            dvw.writeDefaultValue(writer, indent, opName, varName);
> +        } else {
> +            writer.write(className);
> +            writer.write(' ');
> +            writer.write(varName);
> +            writer.write(" = ");
> +            writer.write(getDefaultTypeValue());
> +            writer.write(";");
> +        }
> +    }
> +    
> +    
> +    protected String getDefaultTypeValue() {
>          if (this.className.trim().endsWith("[]")) {
>              return "new " + this.className.substring(0, this.className.length() - 2) + "[0]";
>          }
> @@ -169,13 +192,6 @@
>  
>      public boolean isINOUT() {
>          return this.style == Style.INOUT;
> -    }
> -    public void setTypeReference(TypeReference ref) {
> -        this.typeRef = ref;
> -    }
> -
> -    public TypeReference getTypeReference() {
> -        return this.typeRef;
>      }
>  
>      public void setHeader(boolean header) {
>
> Modified: incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/model/JavaParameterTest.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/model/JavaParameterTest.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/model/JavaParameterTest.java (original)
> +++ incubator/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/common/model/JavaParameterTest.java Fri Jul 13 06:08:28 2007
> @@ -29,12 +29,14 @@
>          JavaParameter holderParameter = new JavaParameter("i", "java.lang.String", null);
>          holderParameter.setHolder(true);
>          holderParameter.setHolderName("javax.xml.ws.Holder");
> -        holderParameter.setHolderClass("java.lang.String");
> -        assertEquals("new javax.xml.ws.Holder<java.lang.String>()", 
> +        assertEquals("\"\"", 
>                       holderParameter.getDefaultTypeValue());
>          
> -        holderParameter.setHolderClass("org.apache.cxf.tools.common.model.JavaParamter");
> -        assertEquals("new javax.xml.ws.Holder<org.apache.cxf.tools.common.model.JavaParamter>()", 
> +        holderParameter = new JavaParameter("org.apache.cxf.tools.common.model.JavaParamter",
> +                                            "org.apache.cxf.tools.common.model.JavaParamter", null);
> +        holderParameter.setHolder(true);
> +        holderParameter.setHolderName("javax.xml.ws.Holder");
> +        assertEquals("null", 
>                       holderParameter.getDefaultTypeValue());
>      }
>  }
>
> Modified: incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJava.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJava.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJava.java (original)
> +++ incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJava.java Fri Jul 13 06:08:28 2007
> @@ -92,7 +92,6 @@
>                 
>          DataBindingProfile databinding = loadDataBinding(getDataBindingName(args));
>          
> -      
>          
>          context.put(DataBindingProfile.class, databinding);
>          
>
> Modified: incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DataBindingProfile.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DataBindingProfile.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DataBindingProfile.java (original)
> +++ incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DataBindingProfile.java Fri Jul 13 06:08:28 2007
> @@ -24,6 +24,7 @@
>  
>  import org.apache.cxf.tools.common.ToolContext;
>  import org.apache.cxf.tools.common.ToolException;
> +import org.apache.cxf.tools.common.model.DefaultValueWriter;
>  
>  public interface DataBindingProfile {
>      
> @@ -31,4 +32,8 @@
>      void initialize(ToolContext c) throws ToolException;
>      String getType(QName qn, boolean element);
>      String getWrappedElementType(QName wrapperElement, QName item);
> +    
> +    DefaultValueWriter createDefaultValueWriter(QName qn, boolean element);
> +    DefaultValueWriter createDefaultValueWriterForWrappedElement(QName wrapperElement, QName qn);
> +    
>  }
>
> Added: incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DefaultValueProvider.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DefaultValueProvider.java?view=auto&rev=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DefaultValueProvider.java (added)
> +++ incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DefaultValueProvider.java Fri Jul 13 06:08:28 2007
> @@ -0,0 +1,56 @@
> +/**
> + * 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.wsdlto.core;
> +
> +import java.math.BigDecimal;
> +import java.math.BigInteger;
> +import java.net.URI;
> +import java.util.Set;
> +
> +import javax.xml.namespace.QName;
> +
> +public interface DefaultValueProvider {
> +    
> +    byte getByteValue(String path);
> +    short getShortValue(String path);
> +    int getIntValue(String path);
> +    long getLongValue(String path);
> +    
> +    float getFloatValue(String path);
> +    double getDoubleValue(String path);
> +    
> +    char getCharValue(String path);
> +    
> +    String getStringValue(String path);
> +    boolean getBooleanValue(String path);
> +    
> +    QName getQNameValue(String path);
> +    URI getURIValue(String path);
> +    
> +    BigInteger getBigIntegerValue(String path);
> +    BigDecimal getBigDecimalValue(String path);
> +    
> +    String getXMLGregorianCalendarValueString(String path);
> +    String getDurationValueString(String path);
> +    
> +    String chooseEnumValue(String path, Set<String> values);
> +    
> +    int getListLength(String path);
> +}
>
> Propchange: incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DefaultValueProvider.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange: incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/DefaultValueProvider.java
> ------------------------------------------------------------------------------
>     svn:keywords = Rev Date
>
> Added: incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/RandomValueProvider.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/RandomValueProvider.java?view=auto&rev=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/RandomValueProvider.java (added)
> +++ incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/RandomValueProvider.java Fri Jul 13 06:08:28 2007
> @@ -0,0 +1,135 @@
> +/**
> + * 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.wsdlto.core;
> +
> +import java.math.BigDecimal;
> +import java.math.BigInteger;
> +import java.net.URI;
> +import java.net.URISyntaxException;
> +import java.util.GregorianCalendar;
> +import java.util.Random;
> +import java.util.Set;
> +
> +import javax.xml.datatype.DatatypeConfigurationException;
> +import javax.xml.namespace.QName;
> +
> +public class RandomValueProvider implements DefaultValueProvider {
> +    Random random = new Random();
> +
> +    public boolean getBooleanValue(String path) {
> +        return random.nextBoolean();
> +    }
> +
> +    public byte getByteValue(String path) {
> +        return (byte)random.nextInt();
> +    }
> +
> +    public char getCharValue(String path) {
> +        return (char)random.nextInt();
> +    }
> +
> +    public double getDoubleValue(String path) {
> +        return random.nextDouble();
> +    }
> +
> +    public float getFloatValue(String path) {
> +        return random.nextFloat();
> +    }
> +
> +    public int getIntValue(String path) {
> +        return random.nextInt();
> +    }
> +
> +    public long getLongValue(String path) {
> +        return random.nextLong();
> +    }
> +
> +    public short getShortValue(String path) {
> +        return (short)random.nextInt();
> +    }
> +
> +    public String getStringValue(String path) {
> +        return path.substring(path.lastIndexOf('/') + 1) + getIntValue(path);
> +    }
> +    
> +    public QName getQNameValue(String path) {
> +        return new QName("http://" + getStringValue(path) + ".com",
> +                         getStringValue(path));
> +    }
> +
> +    public URI getURIValue(String path) {
> +        try {
> +            return new URI("http://" + getStringValue(path) + ".com/" + path);
> +        } catch (URISyntaxException e) {
> +            //ignore
> +        }
> +        return null;
> +    }
> +
> +    public BigDecimal getBigDecimalValue(String path) {
> +        String s = Long.toString(random.nextLong());
> +        s += ".";
> +        s += Long.toString(Math.abs(random.nextLong()));
> +        return new BigDecimal(s);
> +    }
> +    
> +    public BigInteger getBigIntegerValue(String path) {
> +        String s = Long.toString(random.nextLong());
> +        s += Long.toString(Math.abs(random.nextLong()));
> +        return new BigInteger(s);
> +    }
> +
> +    
> +    public String getXMLGregorianCalendarValueString(String path) {
> +        try {
> +            return javax.xml.datatype.DatatypeFactory.newInstance()
> +                .newXMLGregorianCalendar(new GregorianCalendar()).toXMLFormat();
> +        } catch (DatatypeConfigurationException e) {
> +            //ignore
> +        }
> +        return null;
> +    }
> +    
> +    public String getDurationValueString(String path) {
> +        try {
> +            return javax.xml.datatype.DatatypeFactory.newInstance().newDuration(random.nextLong()).toString();
> +        } catch (DatatypeConfigurationException e) {
> +            //ignore
> +        }
> +        return "P1Y35DT60M60.500S";
> +    }
> +
> +    public String chooseEnumValue(String path, Set<String> values) {
> +        int i = random.nextInt(values.size());
> +        for (String s : values) {
> +            if (i == 0) {
> +                return s;
> +            }
> +            --i;
> +        }
> +        return values.iterator().next();
> +    }
> +
> +    public int getListLength(String path) {
> +        int cnt = path.split("/").length;
> +        return cnt > 5 ? 0 : 1;
> +    }
> +
> +}
>
> Propchange: incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/RandomValueProvider.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange: incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/RandomValueProvider.java
> ------------------------------------------------------------------------------
>     svn:keywords = Rev Date
>
> 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=555978&r1=555977&r2=555978
> ==============================================================================
> --- 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 Jul 13 06:08:28 2007
> @@ -20,8 +20,12 @@
>  
>  import java.io.File;
>  import java.io.IOException;
> +import java.io.Writer;
>  import java.lang.reflect.Field;
>  import java.util.ArrayList;
> +import java.util.Collection;
> +import java.util.HashMap;
> +import java.util.HashSet;
>  import java.util.List;
>  import java.util.Map;
>  import java.util.Set;
> @@ -45,7 +49,12 @@
>  import org.xml.sax.InputSource;
>  import org.xml.sax.SAXException;
>  
> +import com.sun.codemodel.ClassType;
> +import com.sun.codemodel.JClass;
>  import com.sun.codemodel.JCodeModel;
> +import com.sun.codemodel.JDefinedClass;
> +import com.sun.codemodel.JMethod;
> +import com.sun.codemodel.JType;
>  import com.sun.tools.xjc.BadCommandLineException;
>  import com.sun.tools.xjc.Options;
>  import com.sun.tools.xjc.api.Mapping;
> @@ -58,19 +67,56 @@
>  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.CastUtils;
>  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.common.model.DefaultValueWriter;
>  import org.apache.cxf.tools.util.ClassCollector;
>  import org.apache.cxf.tools.util.JAXBUtils;
>  import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
> +import org.apache.cxf.tools.wsdlto.core.DefaultValueProvider;
> +import org.apache.cxf.tools.wsdlto.core.RandomValueProvider;
>  
>  public class JAXBDataBinding implements DataBindingProfile {
>      private static final Logger LOG = LogUtils.getL7dLogger(JAXBDataBinding.class);
> -
> +    
> +    private static final Set<String> DEFAULT_TYPE_MAP = new HashSet<String>();
> +    private static final Map<String, String> JLDEFAULT_TYPE_MAP = new HashMap<String, String>();
> +    
>      private S2JJAXBModel rawJaxbModelGenCode;
>      private ToolContext context;
> +    private DefaultValueProvider defaultValues;
> +    
> +    static {
> +        DEFAULT_TYPE_MAP.add("boolean");
> +        DEFAULT_TYPE_MAP.add("int");
> +        DEFAULT_TYPE_MAP.add("long");
> +        DEFAULT_TYPE_MAP.add("short");
> +        DEFAULT_TYPE_MAP.add("byte");
> +        DEFAULT_TYPE_MAP.add("float");
> +        DEFAULT_TYPE_MAP.add("double");
> +        DEFAULT_TYPE_MAP.add("char");
> +        DEFAULT_TYPE_MAP.add("java.lang.String");
> +        DEFAULT_TYPE_MAP.add("javax.xml.namespace.QName");
> +        DEFAULT_TYPE_MAP.add("java.net.URI");
> +        DEFAULT_TYPE_MAP.add("java.math.BigInteger");
> +        DEFAULT_TYPE_MAP.add("java.math.BigDecimal");
> +        DEFAULT_TYPE_MAP.add("javax.xml.datatype.XMLGregorianCalendar");
> +        DEFAULT_TYPE_MAP.add("javax.xml.datatype.Duration");
> +        
> +        JLDEFAULT_TYPE_MAP.put("java.lang.Character", "char");
> +        JLDEFAULT_TYPE_MAP.put("java.lang.Boolean", "boolean");
> +        JLDEFAULT_TYPE_MAP.put("java.lang.Integer", "int");
> +        JLDEFAULT_TYPE_MAP.put("java.lang.Long", "long");
> +        JLDEFAULT_TYPE_MAP.put("java.lang.Short", "short");
> +        JLDEFAULT_TYPE_MAP.put("java.lang.Byte", "byte");
> +        JLDEFAULT_TYPE_MAP.put("java.lang.Float", "float");
> +        JLDEFAULT_TYPE_MAP.put("java.lang.Double", "double");
> +        DEFAULT_TYPE_MAP.addAll(JLDEFAULT_TYPE_MAP.keySet());
> +    }    
> +
>  
>      @SuppressWarnings("unchecked")
>      public void initialize(ToolContext c) throws ToolException {
> @@ -150,6 +196,23 @@
>          rawJaxbModelGenCode = schemaCompiler.bind();
>  
>          addedEnumClassToCollector(schemaLists, allocator);
> +
> +        if (context.get(ToolConstants.CFG_DEFAULT_VALUES) != null) {
> +            String cname = (String)context.get(ToolConstants.CFG_DEFAULT_VALUES);
> +            if (StringUtils.isEmpty(cname)) {
> +                defaultValues = new RandomValueProvider();
> +            } else {
> +                if (cname.charAt(0) == '=') {
> +                    cname = cname.substring(1);
> +                }
> +                try {
> +                    defaultValues = (DefaultValueProvider)Class.forName(cname).newInstance();
> +                } catch (Exception e) {
> +                    LOG.log(Level.SEVERE, e.getMessage());
> +                    throw new ToolException(e);
> +                }
> +            }
> +        }
>      }
>  
>      // TODO  this can be repaced with schemaCompiler.getOptions() once we
> @@ -335,5 +398,250 @@
>              }
>          }
>      }
> +    
> +    public DefaultValueWriter createDefaultValueWriter(QName qname, boolean element) {
> +        if (defaultValues == null) {
> +            return null;
> +        }
> +        TypeAndAnnotation typeAnno = rawJaxbModelGenCode.getJavaType(qname);
> +        if (element) {
> +            Mapping mapping = rawJaxbModelGenCode.get(qname);
> +            if (mapping != null) {
> +                typeAnno = mapping.getType();
> +            }
> +        }
> +        if (typeAnno != null) { 
> +            final JType type = typeAnno.getTypeClass();
> +            return new JAXBDefaultValueWriter(type);
> +        } 
> +        return null;
> +    }
> +    
> +    public DefaultValueWriter createDefaultValueWriterForWrappedElement(QName wrapperElement, QName item) {
> +        if (defaultValues != null) {
> +            Mapping mapping = rawJaxbModelGenCode.get(wrapperElement);
> +            if (mapping != null) {
> +                List<? extends Property> propList = mapping.getWrapperStyleDrilldown();
> +                for (Property pro : propList) {
> +                    if (pro.elementName().getNamespaceURI().equals(item.getNamespaceURI())
> +                        && pro.elementName().getLocalPart().equals(item.getLocalPart())) {
> +                        return new JAXBDefaultValueWriter(pro.type());
> +                    }
> +                }
> +            }
> +        }
> +        return null;
> +    }
> +
> +
> +    private class JAXBDefaultValueWriter implements DefaultValueWriter {
> +        final JType type;
> +        JAXBDefaultValueWriter(JType tp) {
> +            type = tp;
> +        }
> +        public void writeDefaultValue(Writer writer, String indent,
> +                                      String path, String varName) throws IOException {
> +            path = path + "/" + varName;
> +            writeDefaultValue(writer, indent, path, varName, type);
> +        }
> +        
> +        public void writeDefaultValue(Writer writer, String indent,
> +                                      String path, String varName,
> +                                      JType tp) throws IOException {
> +            writer.write(tp.fullName());
> +            writer.write(" ");
> +            writer.write(varName);
> +            writer.write(" = ");
> +            if (tp.isArray()) {
> +                writer.write("new ");
> +                writer.write(tp.fullName());
> +                writer.write(" {};");
> +            } else if (DEFAULT_TYPE_MAP.contains(tp.fullName())) {
> +                writeDefaultType(writer, tp, path);
> +                writer.write(";");
> +            } else if (tp instanceof JDefinedClass) {
> +                JDefinedClass jdc = (JDefinedClass)tp;
> +                if (jdc.getClassType() == ClassType.ENUM) {
> +                    //no way to get the field list as it's private with 
> +                    //no accessors :-(
> +                    try {
> +                        Field f = jdc.getClass().getDeclaredField("enumConstantsByName");
> +                        f.setAccessible(true);
> +                        Map map = (Map)f.get(jdc);
> +                        Set<String> values = CastUtils.cast(map.keySet()); 
> +                        String first = defaultValues.chooseEnumValue(path, values);
> +                        writer.write(tp.fullName());
> +                        writer.write(".");                        
> +                        writer.write(first);                        
> +                        writer.write(";");
> +                    } catch (Exception e) {
> +                        IOException ex = new IOException(e.getMessage());
> +                        ex.initCause(e);
> +                        throw ex;
> +                    }
> +                } else {
> +                    writer.write("new ");
> +                    writer.write(tp.fullName());
> +                    writer.write("();");
> +                    fillInFields(writer, indent, path, varName, jdc);
> +                }
> +            } else {
> +                boolean found = false;
> +                JType tp2 = tp.erasure();
> +                try {
> +                    Field f = tp2.getClass().getDeclaredField("_class");
> +                    f.setAccessible(true);
> +                    Class<?> cls = (Class)f.get(tp2);
> +                    if (List.class.isAssignableFrom(cls)) {
> +                        found = true;
> +
> +                        writer.write("new ");
> +                        writer.write(tp.fullName().replace("java.util.List", "java.util.ArrayList"));
> +                        writer.write("();");
> +                        
> +                        f = tp.getClass().getDeclaredField("args");
> +                        f.setAccessible(true);
> +                        List<JClass> lcl = CastUtils.cast((List)f.get(tp));
> +                        JClass cl = lcl.get(0);
> +                        
> +                        int cnt = defaultValues.getListLength(path + "/" + varName);
> +                        for (int x = 0; x < cnt; x++) {
> +
> +                            writer.write("\n");
> +                            writer.write(indent);
> +                            writeDefaultValue(writer, indent, path + "/" + varName + "Val",
> +                                              varName + "Val" + cnt , cl);
> +                            writer.write("\n");
> +                            writer.write(indent);
> +                            writer.write(varName);
> +                            writer.write(".add(");
> +                            writer.write(varName + "Val" + cnt);
> +                            writer.write(");");
> +                        }
> +                    }
> +                } catch (Exception e) {
> +                    //ignore
> +                }
> +                
> +                if (!found) {
> +                    //System.err.println("No idea what to do with " + tp.fullName());
> +                    //System.err.println("        class " + tp.getClass().getName());
> +                    writer.write("null;");
> +                }
> +            }
> +        }
> +        public void fillInFields(Writer writer, String indent,
> +                                      String path, String varName,
> +                                      JDefinedClass tp) throws IOException {
> +            JClass sp = tp._extends();
> +            if (sp instanceof JDefinedClass) {
> +                fillInFields(writer, indent, path, varName, (JDefinedClass)sp);
> +            }
> +            
> +            Collection<JMethod> methods = tp.methods();
> +            for (JMethod m : methods) {
> +                if (m.name().startsWith("set")) {
> +                    writer.write("\n");
> +                    writer.write(indent);
> +                    if (DEFAULT_TYPE_MAP.contains(m.listParamTypes()[0].fullName())) {
> +                        writer.write(varName);
> +                        writer.write(".");
> +                        writer.write(m.name());
> +                        writer.write("(");
> +                        writeDefaultType(writer, m.listParamTypes()[0], path + "/" + m.name().substring(3));
> +                        writer.write(");");
> +                    } else {
> +                        writeDefaultValue(writer, indent,
> +                                          path + "/" + m.name().substring(3),
> +                                          varName + m.name().substring(3),
> +                                          m.listParamTypes()[0]);
> +                        writer.write("\n");
> +                        writer.write(indent);
> +                        writer.write(varName);
> +                        writer.write(".");
> +                        writer.write(m.name());
> +                        writer.write("(");
> +                        writer.write(varName + m.name().substring(3));
> +                        writer.write(");");
> +                    }
> +                } else if (m.type().fullName().startsWith("java.util.List")) {
> +                    writer.write("\n");
> +                    writer.write(indent);
> +                    writeDefaultValue(writer, indent,
> +                                      path + "/" + m.name().substring(3),
> +                                      varName + m.name().substring(3),
> +                                      m.type());
> +                    writer.write("\n");
> +                    writer.write(indent);
> +                    writer.write(varName);
> +                    writer.write(".");
> +                    writer.write(m.name());
> +                    writer.write("().addAll(");
> +                    writer.write(varName + m.name().substring(3));
> +                    writer.write(");");                    
> +                }
> +            }
> +        }
> +        private void writeDefaultType(Writer writer, JType t, String path) throws IOException {
> +            String name = t.fullName();
> +            writeDefaultType(writer, name, path);
> +            
> +        }    
> +        private void writeDefaultType(Writer writer, String name, String path) throws IOException {
> +            if (JLDEFAULT_TYPE_MAP.containsKey(name)) {
> +                writer.append(name.substring("java.lang.".length())).append(".valueOf(");
> +                writeDefaultType(writer, JLDEFAULT_TYPE_MAP.get(name), path);
> +                writer.append(")");
> +            } else if ("boolean".equals(name)) {
> +                writer.append(defaultValues.getBooleanValue(path) ? "true" : "false");
> +            } else if ("int".equals(name)) {
> +                writer.append(Integer.toString(defaultValues.getIntValue(path)));
> +            } else if ("long".equals(name)) {
> +                writer.append(Long.toString(defaultValues.getLongValue(path))).append("l");
> +            } else if ("short".equals(name)) {
> +                writer.append("(short)").append(Short.toString(defaultValues.getShortValue(path)));
> +            } else if ("byte".equals(name)) {
> +                writer.append("(byte)").append(Byte.toString(defaultValues.getByteValue(path)));
> +            } else if ("float".equals(name)) {
> +                writer.append(Float.toString(defaultValues.getFloatValue(path))).append("f");
> +            } else if ("double".equals(name)) {
> +                writer.append(Double.toString(defaultValues.getDoubleValue(path)));
> +            } else if ("char".equals(name)) {
> +                writer.append("(char)").append(Character.toString(defaultValues.getCharValue(path)));
> +            } else if ("java.lang.String".equals(name)) {
> +                writer.append("\"")
> +                    .append(defaultValues.getStringValue(path))
> +                    .append("\"");
> +            } else if ("javax.xml.namespace.QName".equals(name)) {
> +                QName qn = defaultValues.getQNameValue(path);
> +                writer.append("new javax.xml.namespace.QName(\"")
> +                      .append(qn.getNamespaceURI())
> +                      .append("\", \"")
> +                      .append(qn.getLocalPart())
> +                      .append("\")");
> +            } else if ("java.net.URI".equals(name)) {
> +                writer.append("new java.net.URI(\"")
> +                      .append(defaultValues.getURIValue(path).toASCIIString())
> +                      .append("\")");
> +            } else if ("java.math.BigInteger".equals(name)) {
> +                writer.append("new java.math.BigInteger(\"")
> +                      .append(defaultValues.getBigIntegerValue(path).toString())
> +                      .append("\")");
> +            } else if ("java.math.BigDecimal".equals(name)) {
> +                writer.append("new java.math.BigDecimal(\"")
> +                      .append(defaultValues.getBigDecimalValue(path).toString())
> +                      .append("\")");
> +            } else if ("javax.xml.datatype.XMLGregorianCalendar".equals(name)) {
> +                writer.append("javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(\"")
> +                      .append(defaultValues.getXMLGregorianCalendarValueString(path))
> +                      .append("\")");
> +            } else if ("javax.xml.datatype.Duration".equals(name)) {
> +                writer.append("javax.xml.datatype.DatatypeFactory.newInstance().newDuration(\"")
> +                      .append(defaultValues.getDurationValueString(path))
> +                      .append("\")");
> +            }
> +        }
> +    }
> +
>  
>  }
>
> Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml (original)
> +++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml Fri Jul 13 06:08:28 2007
> @@ -161,6 +161,20 @@
>                  <switch>all</switch>
>              </option>
>  
> +	        <option id="defaultValues" maxOccurs="1">
> +                <annotation>
> +                    Generate default values in the impl and client.  Ignored if impl or client
> +                    is not being generated.
> +                    
> +                    Optionally specify the name of the class to provide the default vaules.
> +                    (default is a RandomValueProvider)
> +                </annotation>
> +                <switch>defaultValues</switch>
> +                <associatedArgument placement="immediate">
> +                    <annotation>=class name for DefaultValueProvider</annotation>
> +                </associatedArgument>
> +            </option>
> +
>              <option id="ant" maxOccurs="1">
>                  <annotation>
>                      ant script generation.
>
> Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java (original)
> +++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ParameterProcessor.java Fri Jul 13 06:08:28 2007
> @@ -118,7 +118,9 @@
>          String namespace = part == null ? null : ProcessorUtil.resolvePartNamespace(part);
>  
>          JavaReturn returnType = new JavaReturn(name, type, namespace);
> -
> +        if (part != null) {
> +            returnType.setDefaultValueWriter(ProcessorUtil.getDefaultValueWriter(part, context));
> +        }
>  
>          returnType.setQName(ProcessorUtil.getElementName(part));
>          returnType.setStyle(JavaType.Style.OUT);
> @@ -402,6 +404,10 @@
>          JavaParameter parameter = new JavaParameter(jpname, fullJavaName, targetNamespace);
>          parameter.setStyle(style);
>          parameter.setQName(item);
> +        
> +        parameter.setDefaultValueWriter(ProcessorUtil.getDefaultValueWriterForWrappedElement(part,
> +                                                                                             context,
> +                                                                                             item));
>  
>          if (style == JavaType.Style.OUT || style == JavaType.Style.INOUT) {
>              parameter.setHolder(true);
> @@ -410,7 +416,7 @@
>              if (JAXBUtils.holderClass(fullJavaName) != null) {
>                  holderClass = JAXBUtils.holderClass(fullJavaName).getName();
>              }
> -            parameter.setHolderClass(holderClass);
> +            parameter.setClassName(holderClass);
>          }
>          return parameter;
>  
> @@ -439,6 +445,10 @@
>  
>          String jpname = ProcessorUtil.mangleNameToVariableName(simpleJavaName);
>          JavaReturn returnType = new JavaReturn(jpname, fullJavaName , targetNamespace);
> +        
> +        returnType.setDefaultValueWriter(
> +            ProcessorUtil.getDefaultValueWriterForWrappedElement(part, context, element));
> +
>          returnType.setQName(element);
>          returnType.setStyle(JavaType.Style.OUT);
>          return returnType;
>
> Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java (original)
> +++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java Fri Jul 13 06:08:28 2007
> @@ -41,6 +41,7 @@
>  import org.apache.cxf.service.model.MessagePartInfo;
>  import org.apache.cxf.service.model.ServiceInfo;
>  import org.apache.cxf.tools.common.ToolContext;
> +import org.apache.cxf.tools.common.model.DefaultValueWriter;
>  import org.apache.cxf.tools.util.ClassCollector;
>  import org.apache.cxf.tools.util.NameUtil;
>  import org.apache.cxf.tools.util.URIParserUtil;
> @@ -85,7 +86,21 @@
>          }
>          return type;
>      }
> -    
> +    public static DefaultValueWriter getDefaultValueWriter(MessagePartInfo part,
> +                                                             ToolContext context) {
> +        DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
> +        if (part.isElement()) {
> +            return dataBinding.createDefaultValueWriter(getElementName(part), true);
> +        } 
> +        return dataBinding.createDefaultValueWriter(part.getTypeQName(), false);
> +    }
> +    public static DefaultValueWriter getDefaultValueWriterForWrappedElement(MessagePartInfo part,
> +                                                           ToolContext context,
> +                                                           QName subElement) {
> +        DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
> +        return dataBinding.createDefaultValueWriterForWrappedElement(part.getElementQName(), subElement);
> +    }
> +
>      public static QName getElementName(MessagePartInfo part) {
>          return part == null ? null : part.getConcreteName();
>      }
>
> Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java (original)
> +++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java Fri Jul 13 06:08:28 2007
> @@ -543,7 +543,7 @@
>                                  }
>                              }
>                              if (jp != null) {
> -                                ((JavaParameter)jp).setHolderClass(mimeJavaType);
> +                                ((JavaParameter)jp).setClassName(mimeJavaType);
>                              }
>  
>                          }
>
> Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/ParameterMapper.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/ParameterMapper.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/ParameterMapper.java (original)
> +++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/mapper/ParameterMapper.java Fri Jul 13 06:08:28 2007
> @@ -40,6 +40,7 @@
>          JavaParameter parameter = new JavaParameter(name, type, namespace);
>          parameter.setPartName(part.getName().getLocalPart());
>          parameter.setQName(ProcessorUtil.getElementName(part));
> +        parameter.setDefaultValueWriter(ProcessorUtil.getDefaultValueWriter(part, context));
>          String fullJavaName = ProcessorUtil.getFullClzName(part, context, false);
>          
>          parameter.setClassName(fullJavaName);
> @@ -51,7 +52,7 @@
>              if (JAXBUtils.holderClass(fullJavaName) != null) {
>                  holderClass = JAXBUtils.holderClass(fullJavaName).getName();
>              }  
> -            parameter.setHolderClass(holderClass);
> +            parameter.setClassName(holderClass);
>          }
>          parameter.setStyle(style);
>          return parameter;
>
> Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/client.vm
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/client.vm?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/client.vm (original)
> +++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/client.vm Fri Jul 13 06:08:28 2007
> @@ -68,24 +68,43 @@
>  #foreach ($method in $intf.Methods)
>  
>          System.out.println("Invoking ${method.Name}...");
> +#foreach ($parameter in $method.Parameters)
> +#set($paramValueName = "_${method.Name}_${parameter.Name}")
> +#if ($parameter.Style.toString() == "IN")
> +        ${parameter.writeDefaultValue(${out}, "        ", ${method.Name}, ${paramValueName})}
> +#elseif ($parameter.Style.toString() == "INOUT")          
> +#set($paramValueName2 = "${paramValueName}Val")
> +        ${parameter.writeDefaultValue(${out}, "        ", ${method.Name}, ${paramValueName2})}
> +        javax.xml.ws.Holder<${parameter.ClassName}> $paramValueName = new javax.xml.ws.Holder<${parameter.ClassName}>(${paramValueName2});
> +#elseif ($parameter.Style.toString() == "OUT")   
> +        javax.xml.ws.Holder<${parameter.ClassName}> $paramValueName = new javax.xml.ws.Holder<${parameter.ClassName}>();
> +#end    
> +#end    
> +#set($indent = "        ")
> +#if($method.Exceptions.size() > 0)
> +#set($indent = "            ")
> +        try {
> +#end
> +#if($method.return.ClassName != "void")${indent}${method.return.ClassName} _${method.Name}__return = #else${indent}#end
> +port.${method.Name}(#foreach($parameter in $method.Parameters)_${method.Name}_${parameter.Name}#if($velocityCount != $method.parameterCount), #end#end);
> +#if($method.return.Type != "void")
> +${indent}System.out.println("${method.Name}.result=" + _${method.Name}__return);
> +#end
> +#foreach ($parameter in $method.Parameters)
> +#if ($parameter.Style.toString() != "IN")
> +#set($paramValueName = "_${method.Name}_${parameter.Name}")
> +${indent}System.out.println("${method.Name}.${paramValueName}=" + ${paramValueName}.value);
> +#end
> +#end
>  #if($method.Exceptions.size() > 0)
> -        try{
> -            #if($method.return.Type != "void")
> -            $method.return.ClassName _${method.Name}_$method.return.Name=#end  port.${method.Name}(#foreach ($parameter in $method.Parameters) ${parameter.DefaultTypeValue}  #if ($velocityCount != $method.parameterCount) , #end #end);
> -            #if($method.return.Type != "void")
> -            System.out.println("${method.Name}.result=" + _${method.Name}_$method.return.Name);
> -            #end
>          }#foreach($exception in $method.Exceptions)
> -        catch($exception.ClassName e){ 
> -        System.out.println("Expected exception: $exception.Name has occurred.");
> -        System.out.println(e.toString());
> + catch ($exception.ClassName e) { 
> +            System.out.println("Expected exception: $exception.Name has occurred.");
> +            System.out.println(e.toString());
>          }#end
> -        #else
> -        #if($method.return.ClassName != "void")$method.return.ClassName _${method.Name}_$method.return.Name =#end port.${method.Name}(#foreach($parameter in $method.Parameters)${parameter.DefaultTypeValue}#if($velocityCount != $method.parameterCount),#end#end);
> -#end#if($method.return.Type != "void")
> -        #end
> +#end        
> +
>  #end
> -        
>          
>          System.exit(0);
>      }
>
> Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm (original)
> +++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm Fri Jul 13 06:08:28 2007
> @@ -56,17 +56,36 @@
>          $param
>  #end
>      )#end
> -
> -###foreach ($parameter in $method.Parameters)$parameter.ClassName  _$parameter.Name #if ($velocityCounter != $method.getParameters().size()),#end#end)
>  #if($method.Exceptions.size() > 0) throws #foreach($exception in $method.Exceptions)$exception.ClassName #if($velocityCount != $method.Exceptions.size()),#end #end #end
> +
>      { 
> -       LOG.info("Executing operation $method.Name");
> -#if ($method.return.ClassName != "void")    ##
> -    return ${method.return.DefaultTypeValue};
> +        LOG.info("Executing operation $method.Name");
> +#foreach ($parameter in $method.Parameters)
> +#if ($parameter.Style.toString() == "IN")
> +        System.out.println($parameter.Name);
> +#elseif ($parameter.Style.toString() == "INOUT")        
> +        System.out.println(${parameter.Name}.value);
> +#end
> +#end
> +        try {
> +#foreach ($parameter in $method.Parameters)
> +#if ($parameter.Style.toString() == "OUT")
> +#set($paramValueName = "${parameter.Name}Value")
> +            ${parameter.writeDefaultValue(${out}, "            ", ${method.Name}, ${paramValueName})}
> +            ${parameter.Name}.value = ${paramValueName};
> +#end        
> +#end
> +#if ($method.return.ClassName != "void")
> +            ${method.return.writeDefaultValue(${out}, "            ", ${method.Name}, "_return")}
> +            return _return;
>  #end
> +        } catch (Exception ex) {
> +            ex.printStackTrace();
> +            throw new RuntimeException(ex);
> +        }
>  #if ($method.Exceptions.size() > 0) 
>  #foreach($exception in $method.Exceptions)
> -    //throw new ${exception.ClassName}("${exception.Name}...");
> +        //throw new ${exception.ClassName}("${exception.Name}...");
>  #end
>  #end
>      }
>
> Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/DummyDataBinding.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/DummyDataBinding.java?view=diff&rev=555978&r1=555977&r2=555978
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/DummyDataBinding.java (original)
> +++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/DummyDataBinding.java Fri Jul 13 06:08:28 2007
> @@ -23,6 +23,7 @@
>  
>  import org.apache.cxf.tools.common.ToolContext;
>  import org.apache.cxf.tools.common.ToolException;
> +import org.apache.cxf.tools.common.model.DefaultValueWriter;
>  
>  public class DummyDataBinding implements org.apache.cxf.tools.wsdlto.core.DataBindingProfile {
>      public void generate(ToolContext context) throws ToolException {
> @@ -37,6 +38,14 @@
>      }
>      
>      public String getWrappedElementType(QName parent, QName qn) {
> +        return null;
> +    }
> +
> +    public DefaultValueWriter createDefaultValueWriter(QName qn, boolean element) {
> +        return null;
> +    }
> +
> +    public DefaultValueWriter createDefaultValueWriterForWrappedElement(QName wrapperElement, QName qn) {
>          return null;
>      }
>  }
>
>
>   

Re: svn commit: r555978 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/tools/common/ buildtools/src/main/resources/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/common/src/main/java/org/apache/cxf/tools/common/model/ tools/com...

Posted by James Mao <ja...@iona.com>.
Thanks,  Dan

Basically the generated jaxb binding files can be used in the wsdl2java
So, I'll add a test for it.

James

> On Saturday 14 July 2007 03:58, James Mao wrote:
>   
>> Why remove the DataTypeAdapter?,
>> The adapter class is used in the jaxb binding file which will be
>> generated automatically if the sei has a java.util.Date or
>> java.util.Calendar type
>>     
>
> Oh.  Ok.   Eclipse basically said it was unused code since NOTHING in the 
> compile tree referenced it at all.   There also wasn't a comment in the 
> code itself saying why it was there.  I'll put it back on Monday (unless 
> you or someone beats me to it).    However, it really needs to go back 
> with some tests or something.   
>
> Dan
>
>
>   
>> Or maybe you have added another class for this purpose, but i can not
>> see in this commit
>>
>> James
>>
>>     
>>> Author: dkulp
>>> Date: Fri Jul 13 06:08:28 2007
>>> New Revision: 555978
>>>
>>> URL: http://svn.apache.org/viewvc?view=rev&rev=555978
>>> Log:
>>> Cleanup formatting of client and impl code
>>> Add option to generate some default data (may not be schema
>>> compliant at this point) into client/impl to make testing easier
>>>
>>>
>>>       

RE: Require developer privilage on Jira to pickup JIRA issue CXF-790.

Posted by "Bhole, Ulhas" <ul...@iona.com>.
Thanks Dan.

-- Ulhas Bhole


-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org]
Sent: Mon 16/07/2007 21:27
To: cxf-dev@incubator.apache.org
Subject: Re: Require developer privilage on Jira to pickup JIRA issue CXF-790.
 

Done.

Dan


On Monday 16 July 2007 06:40, Ulhas Bhole(IONA) wrote:
> Hi,
>
> I do not see option on CXF Jira to assign a issue to myself. Can
> someone add my name to the list of developers so that I can assign the
> issue to me and start looking at it? I am already a committer on CXF.
>
> Here is the JIRA I will be looking at.
> https://issues.apache.org/jira/browse/CXF-790
>
> Regards,
>
> Ulhas Bhole
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
> Ireland

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog


----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: Require developer privilage on Jira to pickup JIRA issue CXF-790.

Posted by Daniel Kulp <dk...@apache.org>.
Done.

Dan


On Monday 16 July 2007 06:40, Ulhas Bhole(IONA) wrote:
> Hi,
>
> I do not see option on CXF Jira to assign a issue to myself. Can
> someone add my name to the list of developers so that I can assign the
> issue to me and start looking at it? I am already a committer on CXF.
>
> Here is the JIRA I will be looking at.
> https://issues.apache.org/jira/browse/CXF-790
>
> Regards,
>
> Ulhas Bhole
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
> Ireland

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Require developer privilage on Jira to pickup JIRA issue CXF-790.

Posted by "Ulhas Bhole(IONA)" <ul...@iona.com>.
Hi,

I do not see option on CXF Jira to assign a issue to myself. Can someone
add my name to the list of developers so that I can assign the issue to
me and start looking at it? I am already a committer on CXF.

Here is the JIRA I will be looking at.
https://issues.apache.org/jira/browse/CXF-790

Regards,

Ulhas Bhole

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: svn commit: r555978 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/tools/common/ buildtools/src/main/resources/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/common/src/main/java/org/apache/cxf/tools/common/model/ tools/com...

Posted by Daniel Kulp <dk...@apache.org>.
On Saturday 14 July 2007 03:58, James Mao wrote:
> Why remove the DataTypeAdapter?,
> The adapter class is used in the jaxb binding file which will be
> generated automatically if the sei has a java.util.Date or
> java.util.Calendar type

Oh.  Ok.   Eclipse basically said it was unused code since NOTHING in the 
compile tree referenced it at all.   There also wasn't a comment in the 
code itself saying why it was there.  I'll put it back on Monday (unless 
you or someone beats me to it).    However, it really needs to go back 
with some tests or something.   

Dan


>
> Or maybe you have added another class for this purpose, but i can not
> see in this commit
>
> James
>
> > Author: dkulp
> > Date: Fri Jul 13 06:08:28 2007
> > New Revision: 555978
> >
> > URL: http://svn.apache.org/viewvc?view=rev&rev=555978
> > Log:
> > Cleanup formatting of client and impl code
> > Add option to generate some default data (may not be schema
> > compliant at this point) into client/impl to make testing easier
> >
> >
-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog