cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r806980 - in /cxf/trunk/rt: databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ databinding/aegis/src/main/java/org/apache/cxf/aegis/type/ databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/ databinding/aegis/src/...
Date Sun, 23 Aug 2009 14:35:03 GMT
Author: bimargulies
Date: Sun Aug 23 14:35:02 2009
New Revision: 806980

URL: http://svn.apache.org/viewvc?rev=806980&view=rev
Log:
CXF-2402 Allow minOccurs and maxOccurs and nillable specs for parameters for custom
and builtin types.

Added:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java
  (with props)
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.aegis.xml
  (with props)
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.java
  (with props)
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/NillableTest.java
  (with props)
Modified:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeCreator.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreator.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=806980&r1=806979&r2=806980&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
Sun Aug 23 14:35:02 2009
@@ -35,8 +35,8 @@
 
 import org.apache.cxf.aegis.AegisContext;
 import org.apache.cxf.aegis.DatabindingException;
-import org.apache.cxf.aegis.type.AbstractTypeCreator;
 import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeClassInfo;
 import org.apache.cxf.aegis.type.TypeCreationOptions;
 import org.apache.cxf.aegis.type.TypeCreator;
 import org.apache.cxf.aegis.type.TypeMapping;
@@ -352,7 +352,11 @@
                 }
             }
             
-            part.setProperty("nillable", Boolean.valueOf(type.isNillable()));
+            // The concept of type.isNillable is questionable: how are types nillable? 
+            // However, this if at least allow .aegis.xml files to get control.
+            if (part.getProperty("nillable") == null) {
+                part.setProperty("nillable", Boolean.valueOf(type.isNillable()));
+            }
             if (type.hasMinOccurs()) {
                 long miValue = type.getMinOccurs();
                 if (miValue != 0) {
@@ -554,11 +558,6 @@
     private Type getParameterType(Service s, TypeMapping tm, MessagePartInfo param, int paramtype)
{
         Type type = tm.getType(param.getTypeQName());
 
-        /*
-         * if (type == null && tm.isRegistered(param.getTypeClass())) { type =
-         * tm.getType(param.getTypeClass()); part2type.put(param, type); }
-         */
-
         int offset = 0;
         if (paramtype == OUT_PARAM) {
             offset = 1;
@@ -569,12 +568,18 @@
             OperationInfo op = param.getMessageInfo().getOperation();
 
             Method m = getMethod(s, op);
-            AbstractTypeCreator.TypeClassInfo info;
+            TypeClassInfo info;
             if (paramtype != FAULT_PARAM && m != null) {
                 info = typeCreator.createClassInfo(m, param.getIndex() - offset);
             } else {
                 info = typeCreator.createBasicClassInfo(param.getTypeClass());
             }
+            Boolean nillable = info.getNillable();
+            /* Note that, for types from the mapping, the minOccurs, maxOccurs, and nillable
+             * from the 'info' will be ignored by createTypeForClass below. So we need
+             * to override.
+             */
+
             if (param.getMessageInfo().getOperation().isUnwrapped() && param.getTypeClass().isArray())
{
                 // The service factory expects arrays going into the wrapper to
                 // be
@@ -584,15 +589,32 @@
                 // want the default.
                 param.setProperty("minOccurs", "1");
                 param.setProperty("maxOccurs", "1");
-                param.setProperty("nillable", Boolean.TRUE);
+                if (nillable == null) {
+                    nillable = Boolean.TRUE;
+                }
+                param.setProperty("nillable", nillable);
+            } else {
+                if (nillable != null) {
+                    param.setProperty("nillable", nillable);
+                }
+                /*
+                 * TypeClassInfo uses -1 to mean 'not specified'
+                 */
+                if (info.getMinOccurs() != -1) {
+                    param.setProperty("minOccurs", Long.toString(info.getMinOccurs()));
+                }
+                if (info.getMaxOccurs() != -1) {
+                    param.setProperty("maxOccurs", Long.toString(info.getMaxOccurs()));
+                }
             }
             if (info.getMappedName() != null) {
                 param.setConcreteName(info.getMappedName());
                 param.setName(info.getMappedName());
             }
             type = typeCreator.createTypeForClass(info);
-            // We have to register the type if we want minOccurs and such to
-            // work.
+            
+            //We have to register the type if we want minOccurs and such to
+            // work. (for custom types)
             if (info.nonDefaultAttributes()) {
                 tm.register(type);
             }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java?rev=806980&r1=806979&r2=806980&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
Sun Aug 23 14:35:02 2009
@@ -135,7 +135,8 @@
             result = type;
         }
 
-        if (newType && !getConfiguration().isDefaultNillable()) {
+        if (newType
+            && !getConfiguration().isDefaultNillable()) {
             result.setNillable(false);
         }
 
@@ -337,11 +338,11 @@
         if (info.nonDefaultAttributes()) {
             localName += "-";
             if (info.getMinOccurs() >= 0) {
-                localName += info.minOccurs;
+                localName += info.getMinOccurs();
             }
             localName += "-";
             if (info.getMaxOccurs() >= 0) {
-                localName += info.maxOccurs;
+                localName += info.getMaxOccurs();
             }
             if (info.isFlat()) {
                 localName += "Flat";
@@ -433,131 +434,4 @@
     public void setConfiguration(TypeCreationOptions tpConfiguration) {
         this.typeConfiguration = tpConfiguration;
     }
-
-    /**
-     * Object to carry information for a type, such as that from an XML mapping file. 
-     */
-    public static class TypeClassInfo {
-        Class typeClass;
-
-        Object[] annotations;
-
-        Object genericType;
-
-        Object keyType;
-        Object valueType;
-        QName mappedName;
-        QName typeName;
-        Class type;
-        String description;
-        long minOccurs = -1;
-        long maxOccurs = -1;
-        boolean flat;
-        
-        public boolean nonDefaultAttributes() {
-            return minOccurs != -1 || maxOccurs != -1 || flat;
-        }
-
-        public String getDescription() {
-            return description;
-        }
-
-        public void setDescription(String description) {
-            this.description = description;
-        }
-
-        public Object[] getAnnotations() {
-            return annotations;
-        }
-
-        public void setAnnotations(Object[] annotations) {
-            this.annotations = annotations;
-        }
-
-        public Object getGenericType() {
-            return genericType;
-        }
-
-        public void setGenericType(Object genericType) {
-            this.genericType = genericType;
-        }
-
-        public Object getKeyType() {
-            return keyType;
-        }
-
-        public void setKeyType(Object keyType) {
-            this.keyType = keyType;
-        }
-
-        public Class getTypeClass() {
-            return typeClass;
-        }
-
-        public void setTypeClass(Class typeClass) {
-            this.typeClass = typeClass;
-        }
-
-        public QName getTypeName() {
-            return typeName;
-        }
-
-        public void setTypeName(QName name) {
-            this.typeName = name;
-        }
-
-        public Class getType() {
-            return type;
-        }
-
-        public void setType(Class type) {
-            this.type = type;
-        }
-
-        public QName getMappedName() {
-            return mappedName;
-        }
-
-        public void setMappedName(QName mappedName) {
-            this.mappedName = mappedName;
-        }
-
-        public long getMaxOccurs() {
-            return maxOccurs;
-        }
-
-        public void setMaxOccurs(long maxOccurs) {
-            this.maxOccurs = maxOccurs;
-        }
-
-        public long getMinOccurs() {
-            return minOccurs;
-        }
-
-        public void setMinOccurs(long minOccurs) {
-            this.minOccurs = minOccurs;
-        }
-
-        public boolean isFlat() {
-            return flat;
-        }
-
-        public void setFlat(boolean flat) {
-            this.flat = flat;
-        }
-
-        @Override
-        public String toString() {
-            return "TypeClassInfo " + getDescription();
-        }
-
-        public Object getValueType() {
-            return valueType;
-        }
-
-        public void setValueType(Object valueType) {
-            this.valueType = valueType;
-        }
-
-    }
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeCreator.java?rev=806980&r1=806979&r2=806980&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeCreator.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeCreator.java
Sun Aug 23 14:35:02 2009
@@ -22,7 +22,6 @@
 import java.lang.reflect.Method;
 
 import org.apache.cxf.aegis.DatabindingException;
-import org.apache.cxf.aegis.type.AbstractTypeCreator.TypeClassInfo;
 import org.apache.cxf.aegis.type.basic.BeanType;
 import org.apache.cxf.aegis.type.basic.BeanTypeInfo;
 

Added: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java?rev=806980&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java
(added)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java
Sun Aug 23 14:35:02 2009
@@ -0,0 +1,172 @@
+/**
+ * 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.aegis.type;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Object to carry information for a type, such as that from an XML mapping file.
+ * 
+ * Note that this class has a misleading name. It is used both for 
+ * type information that corresponds to a type, and also for parameters 
+ * of methods and elements of beans. When describing a top-level type,
+ * minOccurs and maxOccurs are not meaningful. Nillable is only used for
+ * parameters. It might be that the code could be deconfused by
+ * using the nillable property in here for the non-parameters cases
+ * that look at minOccurs and maxOccurs.
+ * 
+ * Historically, the code for dealing with nillable was very confused,
+ * and so the support here is a bit ginger, until someone figures out how
+ * to sort things out. Thus the three-valued support instead
+ * of a plain boolean.
+ */
+public class TypeClassInfo {
+    private Class typeClass;
+    private Object[] annotations;
+    // Object because it can be either a TypeClassInfo or a
+    // java.lang.reflect.Type
+    private Object genericType;
+    // ditto
+    private Object keyType;
+    // ditto
+    private Object valueType;
+    private QName mappedName;
+    private QName typeName;
+    private Class type;
+    private String description;
+    private long minOccurs = -1;
+    private long maxOccurs = -1;
+    // not yet implemented
+    private boolean flat;
+    private Boolean nillable;
+    
+    public boolean nonDefaultAttributes() {
+        return minOccurs != -1 || maxOccurs != -1 || flat;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Object[] getAnnotations() {
+        return annotations;
+    }
+
+    public void setAnnotations(Object[] annotations) {
+        this.annotations = annotations;
+    }
+
+    public Object getGenericType() {
+        return genericType;
+    }
+
+    public void setGenericType(Object genericType) {
+        this.genericType = genericType;
+    }
+
+    public Object getKeyType() {
+        return keyType;
+    }
+
+    public void setKeyType(Object keyType) {
+        this.keyType = keyType;
+    }
+
+    public Class getTypeClass() {
+        return typeClass;
+    }
+
+    public void setTypeClass(Class typeClass) {
+        this.typeClass = typeClass;
+    }
+
+    public QName getTypeName() {
+        return typeName;
+    }
+
+    public void setTypeName(QName name) {
+        this.typeName = name;
+    }
+
+    public Class getType() {
+        return type;
+    }
+
+    public void setType(Class type) {
+        this.type = type;
+    }
+
+    public QName getMappedName() {
+        return mappedName;
+    }
+
+    public void setMappedName(QName mappedName) {
+        this.mappedName = mappedName;
+    }
+
+    public long getMaxOccurs() {
+        return maxOccurs;
+    }
+
+    public void setMaxOccurs(long maxOccurs) {
+        this.maxOccurs = maxOccurs;
+    }
+
+    public long getMinOccurs() {
+        return minOccurs;
+    }
+
+    public void setMinOccurs(long minOccurs) {
+        this.minOccurs = minOccurs;
+    }
+
+    public boolean isFlat() {
+        return flat;
+    }
+
+    public void setFlat(boolean flat) {
+        this.flat = flat;
+    }
+
+    @Override
+    public String toString() {
+        return "TypeClassInfo " + getDescription();
+    }
+
+    public Object getValueType() {
+        return valueType;
+    }
+
+    public void setValueType(Object valueType) {
+        this.valueType = valueType;
+    }
+
+    public Boolean getNillable() {
+        return nillable;
+    }
+
+    public void setNillable(Boolean nillable) {
+        this.nillable = nillable;
+    }
+}
\ No newline at end of file

Propchange: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreator.java?rev=806980&r1=806979&r2=806980&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreator.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreator.java
Sun Aug 23 14:35:02 2009
@@ -24,7 +24,6 @@
 
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.aegis.type.AbstractTypeCreator.TypeClassInfo;
 
 /**
  * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java?rev=806980&r1=806979&r2=806980&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
Sun Aug 23 14:35:02 2009
@@ -471,6 +471,11 @@
         if (flat != null) {
             info.setFlat(Boolean.valueOf(flat.toLowerCase()).booleanValue());
         }
+        
+        String nillable = DOMUtils.getAttributeValueEmptyNull(parameter, "nillable");
+        if (nillable != null) {
+            info.setNillable(Boolean.valueOf(nillable.toLowerCase()).booleanValue());
+        }
     }
 
     @Override

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java?rev=806980&r1=806979&r2=806980&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
Sun Aug 23 14:35:02 2009
@@ -29,6 +29,7 @@
 
 import org.apache.cxf.aegis.type.AbstractTypeCreator;
 import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeClassInfo;
 import org.apache.cxf.aegis.type.basic.BeanType;
 import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.apache.cxf.aegis.util.ServiceUtils;

Added: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.aegis.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.aegis.xml?rev=806980&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.aegis.xml
(added)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.aegis.xml
Sun Aug 23 14:35:02 2009
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<mappings>
+    <mapping name="NillableService">
+        <method name="submitStringArray">
+            <parameter index="0" minOccurs='2' maxOccurs='50' nillable='false' />
+        </method>
+         <method name="takeNotNillableString">
+            <parameter index="0" minOccurs="1" nillable='false' />
+        </method>
+    </mapping>
+</mappings>

Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.aegis.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.aegis.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.java?rev=806980&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.java
(added)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.java
Sun Aug 23 14:35:02 2009
@@ -0,0 +1,35 @@
+/**
+ * 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.aegis.services;
+
+/**
+ * A minimal service for testing nillable annotations in Aegis XML.
+ */
+public class NillableService {
+    
+    public NillableService() {
+    }
+    
+    public boolean submitStringArray(String[] array) {
+        return true;
+    }
+    
+    public void takeNotNillableString(String string) {
+    }
+}

Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/NillableService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/NillableTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/NillableTest.java?rev=806980&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/NillableTest.java
(added)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/NillableTest.java
Sun Aug 23 14:35:02 2009
@@ -0,0 +1,66 @@
+/**
+ * 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.aegis.xmlconfig;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.services.NillableService;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class NillableTest extends AbstractAegisTest {
+
+    private Document arrayWsdlDoc;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        createService(NillableService.class, new NillableService(), "Nillable", new QName("urn:nillable",
+                                                                                        
 "Nillable"));
+        arrayWsdlDoc = getWSDLDocument("Nillable");
+    }
+
+    @Test
+    public void testXmlConfigurationOfParameterTypeSchema() throws Exception {
+        NodeList typeList = assertValid(
+                                        "/wsdl:definitions/wsdl:types"
+                                            + "/xsd:schema[@targetNamespace='urn:nillable']"
+                                            + "/xsd:complexType[@name=\"submitStringArray\"]"
+                                            + "/xsd:sequence/xsd:element"
+                                            + "[@name='array']", arrayWsdlDoc);
+        Element typeElement = (Element)typeList.item(0);
+        String nillableValue = typeElement.getAttribute("nillable");
+        assertTrue(nillableValue == null || "".equals(nillableValue) || "false".equals("nillableValue"));
+
+        typeList = assertValid("/wsdl:definitions/wsdl:types"
+                               + "/xsd:schema[@targetNamespace='urn:nillable']"
+                               + "/xsd:complexType[@name=\"takeNotNillableString\"]"
+                               + "/xsd:sequence/xsd:element[@name='string']", arrayWsdlDoc);
+        typeElement = (Element)typeList.item(0);
+        nillableValue = typeElement.getAttribute("nillable");
+        assertTrue(nillableValue == null || "".equals(nillableValue) || "false".equals("nillableValue"));
+
+    }
+}

Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/NillableTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java?rev=806980&r1=806979&r2=806980&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
Sun Aug 23 14:35:02 2009
@@ -189,17 +189,34 @@
         return null;
     }
     
+    /**
+     * If Aegis is at work, the XML can render a wrapper part non-nillable.
+     * @param mpi part
+     * @return nillability
+     */
     public Boolean isWrapperPartNillable(MessagePartInfo mpi) {
-        return null;
+        return (Boolean)mpi.getProperty("nillable");
     }
+    
     public Boolean isWrapperPartQualified(MessagePartInfo mpi) {
         return null;
     }
     public Long getWrapperPartMaxOccurs(MessagePartInfo mpi) {
-        //return Long.MAX_VALUE for unbounded
+        String miString = (String)mpi.getProperty("maxOccurs");
+        if (miString != null) {
+            if ("unbounded".equals(miString)) {
+                return Long.MAX_VALUE;
+            } else {
+                return Long.valueOf(miString, 10);
+            }
+        }
         return null;
     }
     public Long getWrapperPartMinOccurs(MessagePartInfo mpi) {
+        String miString = (String)mpi.getProperty("minOccurs");
+        if (miString != null) {
+            return Long.valueOf(miString, 10);
+        }
         return null;
     }
 }



Mime
View raw message