You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/08/01 22:35:53 UTC

svn commit: r681813 - in /cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory: AbstractServiceConfiguration.java DefaultServiceConfiguration.java ReflectionServiceFactoryBean.java

Author: dkulp
Date: Fri Aug  1 13:35:52 2008
New Revision: 681813

URL: http://svn.apache.org/viewvc?rev=681813&view=rev
Log:
Add flags to service configuration stuff to allow controlling the nillable/minOccurs/maxOccurs of the wrapper parts.

Modified:
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java

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=681813&r1=681812&r2=681813&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 Fri Aug  1 13:35:52 2008
@@ -25,6 +25,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
 
 public abstract class AbstractServiceConfiguration {
@@ -187,4 +188,15 @@
     public Type getHolderType(Class<?> cls, Type type) {
         return null;
     }
+    
+    public Boolean isWrapperPartNillable(MessagePartInfo mpi) {
+        return null;
+    }
+    public Long getWrapperPartMaxOccurs(MessagePartInfo mpi) {
+        //return Long.MAX_VALUE for unbounded
+        return null;
+    }
+    public Long getWrapperPartMinOccurs(MessagePartInfo mpi) {
+        return null;
+    }
 }

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java?rev=681813&r1=681812&r2=681813&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java (original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java Fri Aug  1 13:35:52 2008
@@ -33,6 +33,7 @@
 import org.apache.cxf.helpers.ServiceUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
 
 public class DefaultServiceConfiguration extends AbstractServiceConfiguration {
@@ -284,6 +285,32 @@
         }
         return rawClass;
     }
+    
+    
+    public Boolean isWrapperPartNillable(MessagePartInfo mpi) {
+        return (Boolean)mpi.getProperty("nillable");
+    }
+    public Long getWrapperPartMaxOccurs(MessagePartInfo mpi) {
+        String max = (String)mpi.getProperty("maxOccurs");
+        long maxi = 1;
+        if (max == null) {
+            if (mpi.getTypeClass() != null && mpi.getTypeClass().isArray()
+                && !Byte.TYPE.equals(mpi.getTypeClass().getComponentType())) {
+                maxi = Long.MAX_VALUE;
+            }
+        } else {
+            maxi = "unbounded".equals(max) ? Long.MAX_VALUE : Long.parseLong(max);
+        }
+        return maxi;
+    }
+    public Long getWrapperPartMinOccurs(MessagePartInfo mpi) {
+        String min = (String)mpi.getProperty("minOccurs");
+        long mini = 1;
+        if (min == null && mpi.getTypeClass() != null && !mpi.getTypeClass().isPrimitive()) {
+            mini = 0;
+        }
+        return mini;
+    }
 
     
 }

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=681813&r1=681812&r2=681813&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Fri Aug  1 13:35:52 2008
@@ -1123,35 +1123,24 @@
                     addMimeType(el, methodAnnotations);
                 }
 
-                if (mpi.getTypeClass() != null && mpi.getTypeClass().isArray()
-                    && !Byte.TYPE.equals(mpi.getTypeClass().getComponentType())) {
-
-                    String min = (String)mpi.getProperty("minOccurs");
-                    String max = (String)mpi.getProperty("maxOccurs");
-                    min = min == null ? "0" : min;
-                    max = max == null ? "unbounded" : max;
-                    el.setMinOccurs(Long.parseLong(min));
-                    el.setMaxOccurs("unbounded".equals(max) ? Long.MAX_VALUE : Long.parseLong(max));
-                    Boolean b = (Boolean)mpi.getProperty("nillable");
-                    if (b != null && b.booleanValue()) {
-                        el.setNillable(b.booleanValue());
-                    }
-
-                } else if (Collection.class.isAssignableFrom(mpi.getTypeClass())
+                long min = getWrapperPartMinOccurs(mpi);
+                long max = getWrapperPartMaxOccurs(mpi);
+                boolean nillable = isWrapperPartNillable(mpi);
+                
+                if (Collection.class.isAssignableFrom(mpi.getTypeClass())
                            && mpi.getTypeClass().isInterface()) {
                     Type type = (Type)mpi.getProperty(GENERIC_TYPE);
 
                     if (!(type instanceof java.lang.reflect.ParameterizedType)
                         && el.getSchemaTypeName() == null && el.getSchemaType() == null) {
-                        el.setMinOccurs(0);
-                        el.setMaxOccurs(Long.MAX_VALUE);
+                        max = Long.MAX_VALUE;
                         el.setSchemaTypeName(Constants.XSD_ANYTYPE);
                     }
-                } else {
-                    el.setMaxOccurs(1);
-                    if (mpi.getTypeClass() != null && !mpi.getTypeClass().isPrimitive()) {
-                        el.setMinOccurs(0);
-                    }
+                }
+                el.setMinOccurs(min);
+                el.setMaxOccurs(max);
+                if (nillable) {
+                    el.setNillable(nillable);
                 }
                 seq.getItems().add(el);
                 mpi.setXmlSchema(el);
@@ -1974,6 +1963,34 @@
         }
         return null;
     }
+    
+    public boolean isWrapperPartNillable(MessagePartInfo mpi) {
+        for (AbstractServiceConfiguration c : serviceConfigurations) {
+            Boolean b = c.isWrapperPartNillable(mpi);
+            if (b != null) {
+                return b;
+            }
+        }
+        return false;
+    }
+    public long getWrapperPartMaxOccurs(MessagePartInfo mpi) {
+        for (AbstractServiceConfiguration c : serviceConfigurations) {
+            Long b = c.getWrapperPartMaxOccurs(mpi);
+            if (b != null) {
+                return b;
+            }
+        }
+        return 1;
+    }
+    public long getWrapperPartMinOccurs(MessagePartInfo mpi) {
+        for (AbstractServiceConfiguration c : serviceConfigurations) {
+            Long b = c.getWrapperPartMinOccurs(mpi);
+            if (b != null) {
+                return b;
+            }
+        }
+        return 1;
+    }
 
     protected MethodDispatcher getMethodDispatcher() {
         return methodDispatcher;