geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r202371 - in /geronimo/trunk/modules: axis-builder/src/java/org/apache/geronimo/axis/builder/ axis/src/java/org/apache/geronimo/axis/client/
Date Wed, 29 Jun 2005 13:19:21 GMT
Author: djencks
Date: Wed Jun 29 06:19:20 2005
New Revision: 202371

URL: http://svn.apache.org/viewcvs?rev=202371&view=rev
Log:
Add more info for array mappings from schema

Added:
    geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ArrayTypeInfo.java
Modified:
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightTypeInfoBuilder.java
    geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/TypeInfo.java

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightTypeInfoBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightTypeInfoBuilder.java?rev=202371&r1=202370&r2=202371&view=diff
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightTypeInfoBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightTypeInfoBuilder.java
Wed Jun 29 06:19:20 2005
@@ -28,7 +28,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import javax.xml.namespace.QName;
 import javax.xml.rpc.encoding.DeserializerFactory;
 import javax.xml.rpc.encoding.SerializerFactory;
@@ -48,12 +47,11 @@
 import org.apache.axis.encoding.ser.BeanSerializerFactory;
 import org.apache.axis.encoding.ser.EnumDeserializerFactory;
 import org.apache.axis.encoding.ser.EnumSerializerFactory;
-import org.apache.axis.encoding.ser.SimpleDeserializerFactory;
 import org.apache.axis.encoding.ser.SimpleListDeserializerFactory;
 import org.apache.axis.encoding.ser.SimpleListSerializerFactory;
-import org.apache.axis.encoding.ser.SimpleSerializerFactory;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.axis.client.ArrayTypeInfo;
 import org.apache.geronimo.axis.client.TypeInfo;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.kernel.ClassLoading;
@@ -62,7 +60,10 @@
 import org.apache.geronimo.xbeans.j2ee.VariableMappingType;
 import org.apache.xmlbeans.SchemaLocalAttribute;
 import org.apache.xmlbeans.SchemaParticle;
+import org.apache.xmlbeans.SchemaProperty;
 import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.soap.SOAPArrayType;
+import org.apache.xmlbeans.soap.SchemaWSDLArrayType;
 
 /**
  * @version $Rev:  $ $Date:  $
@@ -140,8 +141,7 @@
                 throw new DeploymentException("Could not load java type", e2);
             }
 
-            TypeInfo.UpdatableTypeInfo internalTypeInfo = new TypeInfo.UpdatableTypeInfo();
-            defineSerializerPair(internalTypeInfo, schemaType, clazz);
+            TypeInfo.UpdatableTypeInfo internalTypeInfo = defineSerializerPair(schemaType,
clazz);
 
             populateInternalTypeInfo(clazz, key, schemaType, javaXmlTypeMapping, internalTypeInfo);
 
@@ -197,9 +197,8 @@
                 }
 
                 Class clazz = parameterDesc.getJavaType();
-                TypeInfo.UpdatableTypeInfo internalTypeInfo = new TypeInfo.UpdatableTypeInfo();
+                TypeInfo.UpdatableTypeInfo internalTypeInfo =  defineSerializerPair(schemaType,
clazz);
                 setTypeQName(internalTypeInfo, key);
-                defineSerializerPair(internalTypeInfo, schemaType, clazz);
                 internalTypeInfo.setFields(new FieldDesc[0]);
 
                 typeInfoList.add(internalTypeInfo.buildTypeInfo());
@@ -209,15 +208,18 @@
         return typeInfoList;
     }
 
-    private void defineSerializerPair(TypeInfo.UpdatableTypeInfo internalTypeInfo, SchemaType
schemaType, Class clazz)
+    private TypeInfo.UpdatableTypeInfo defineSerializerPair(SchemaType schemaType, Class
clazz)
             throws DeploymentException {
+        TypeInfo.UpdatableTypeInfo internalTypeInfo = new TypeInfo.UpdatableTypeInfo();
         Class serializerFactoryClass = null;
         Class deserializerFactoryClass = null;
         if (schemaType.isSimpleType()) {
             if (SchemaType.ATOMIC == schemaType.getSimpleVariety()) {
                 if (clazz.isArray()) {
+                    internalTypeInfo = new ArrayTypeInfo.UpdatableArrayTypeInfo();
                     serializerFactoryClass = ArraySerializerFactory.class;
                     deserializerFactoryClass = ArrayDeserializerFactory.class;
+                    //TODO set componentType, componentQName
                 } else if (null != schemaType.getEnumerationValues()) {
                     serializerFactoryClass = EnumSerializerFactory.class;
                     deserializerFactoryClass = EnumDeserializerFactory.class;
@@ -238,8 +240,56 @@
             }
         } else {
             if (clazz.isArray()) {
+                internalTypeInfo = new ArrayTypeInfo.UpdatableArrayTypeInfo();
                 serializerFactoryClass = ArraySerializerFactory.class;
                 deserializerFactoryClass = ArrayDeserializerFactory.class;
+                QName componentType = null;
+                //First, handle case that looks like this:
+//                <complexType name="ArrayOfstring">
+//                    <complexContent>
+//                        <restriction base="soapenc:Array">
+//                            <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
+//                        </restriction>
+//                    </complexContent>
+//                </complexType>
+                SchemaLocalAttribute arrayTypeAttribute =  schemaType.getAttributeModel().getAttribute(new
QName(SOAP_ENCODING_NS, "arrayType"));
+                if (arrayTypeAttribute != null) {
+                    SchemaWSDLArrayType wsdlArrayType = (SchemaWSDLArrayType) arrayTypeAttribute;
+                    SOAPArrayType soapArrayType = wsdlArrayType.getWSDLArrayType();
+                    if (soapArrayType != null) {
+                        componentType = soapArrayType.getQName();
+                        log.info("extracted componentType " + componentType + " from schemaType
" + schemaType);
+                    } else {
+                    log.info("no SOAPArrayType for component from schemaType " + schemaType);
+                    }
+                } else {
+                    log.warn("No soap array info for schematype: " + schemaType);
+                }
+                if (componentType == null) {
+                    //If that didn't work, try to handle case like this:
+//                    <complexType name="ArrayOfstring1">
+//                        <complexContent>
+//                            <restriction base="soapenc:Array">
+//                                <sequence>
+//                                    <element name="string1" type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/>
+//                                </sequence>
+//                            </restriction>
+//                        </complexContent>
+//                    </complexType>
+                    //todo consider if we should check for maxOccurs > 1
+                    if (schemaType.getBaseType().getName().equals(new QName(SOAP_ENCODING_NS,
"Array"))) {
+                        SchemaProperty[] properties = schemaType.getDerivedProperties();
+                        if (properties.length != 1) {
+                            throw new DeploymentException("more than one element inside array
definition: " + schemaType);
+                        }
+                        componentType = properties[0].getType().getName();
+                        log.info("determined component type from element type");
+                    }
+
+                }
+
+                ((ArrayTypeInfo.UpdatableArrayTypeInfo)internalTypeInfo).setComponentType(componentType);
+                //If we understand the axis comments correctly, componentQName is never set
for j2ee ws.
             } else {
                 QName typeQName;
                 if (SchemaType.SIMPLE_CONTENT == schemaType.getContentType()) {
@@ -265,6 +315,7 @@
         internalTypeInfo.setClazz(clazz);
         internalTypeInfo.setSerializerClass(serializerFactoryClass);
         internalTypeInfo.setDeserializerClass(deserializerFactoryClass);
+        return internalTypeInfo;
     }
 
     private void setTypeQName(TypeInfo.UpdatableTypeInfo typeInfo, SchemaTypeKey key) {

Added: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ArrayTypeInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ArrayTypeInfo.java?rev=202371&view=auto
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ArrayTypeInfo.java
(added)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ArrayTypeInfo.java
Wed Jun 29 06:19:20 2005
@@ -0,0 +1,103 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.geronimo.axis.client;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.encoding.TypeMapping;
+import javax.xml.rpc.encoding.SerializerFactory;
+import javax.xml.rpc.encoding.DeserializerFactory;
+
+import org.apache.axis.description.FieldDesc;
+import org.apache.axis.encoding.ser.BaseSerializerFactory;
+import org.apache.axis.encoding.ser.BaseDeserializerFactory;
+import org.apache.axis.encoding.ser.ArraySerializerFactory;
+import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
+
+/**
+ * @version $Rev:  $ $Date:  $
+ */
+public class ArrayTypeInfo extends TypeInfo {
+
+    private final QName componentType;
+    private final QName componentQName;
+
+    public ArrayTypeInfo(Class clazz,
+                         QName qName,
+                         Class serializerClass,
+                         Class deserializerClass,
+                         boolean canSearchParents,
+                         FieldDesc[] fields,
+                         QName componentType,
+                         QName componentQName) {
+        super(clazz, qName, serializerClass, deserializerClass, canSearchParents, fields);
+        this.componentType = componentType;
+        this.componentQName = componentQName;
+    }
+
+    public void register(TypeMapping typeMapping) {
+//        SerializerFactory ser = BaseSerializerFactory.createFactory(getSerFactoryClass(),
getClazz(), getqName());
+//        ((ArraySerializerFactory)ser).setComponentType(componentType);
+//        ((ArraySerializerFactory)ser).setComponentQName(componentQName);
+//        DeserializerFactory deser = BaseDeserializerFactory.createFactory(getDeserFactoryClass(),
getClazz(), getqName());
+//        ((ArrayDeserializerFactory)deser).setComponentType(componentType);
+        
+        ArraySerializerFactory ser = new ArraySerializerFactory(componentType, componentQName);
+        ArrayDeserializerFactory deser = new ArrayDeserializerFactory();
+
+        typeMapping.register(getClazz(), getqName(), ser, deser);
+    }
+
+    public static class UpdatableArrayTypeInfo extends TypeInfo.UpdatableTypeInfo {
+        private QName componentType;
+        private QName componentQName;
+
+        public TypeInfo buildTypeInfo() {
+            if (null == clazz) {
+                throw new IllegalStateException("clazz is null");
+            } else if (null == qName) {
+                throw new IllegalStateException("qName is null");
+            } else if (null == serializerClass) {
+                throw new IllegalStateException("serializerClass is null");
+            } else if (null == deserializerClass) {
+                throw new IllegalStateException("deserializerClass is null");
+            } else if (null == fields) {
+                throw new IllegalStateException("fields is null");
+            }
+            return new ArrayTypeInfo(clazz, qName, serializerClass, deserializerClass, canSearchParents,
fields, componentType, componentQName);
+        }
+
+
+        public QName getComponentType() {
+            return componentType;
+        }
+
+        public QName getComponentQName() {
+            return componentQName;
+        }
+
+        public void setComponentType(QName componentType) {
+            this.componentType = componentType;
+        }
+
+        public void setComponentQName(QName componentQName) {
+            this.componentQName = componentQName;
+        }
+
+    }
+
+
+}

Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/TypeInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/TypeInfo.java?rev=202371&r1=202370&r2=202371&view=diff
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/TypeInfo.java (original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/TypeInfo.java Wed
Jun 29 06:19:20 2005
@@ -72,7 +72,7 @@
     public Class getDeserFactoryClass() {
         return deserFactoryClass;
     }
-    
+
     public boolean isCanSearchParents() {
         return canSearchParents;
     }
@@ -80,7 +80,7 @@
     public FieldDesc[] getFields() {
         return fields;
     }
-    
+
     public TypeDesc buildTypeDesc() {
         TypeDesc typeDesc = new TypeDesc(clazz, canSearchParents);
         typeDesc.setXmlType(qName);
@@ -94,15 +94,15 @@
 
         typeMapping.register(clazz, qName, ser, deser);
     }
-    
+
     public static class UpdatableTypeInfo {
-        private Class clazz;
-        private QName qName;
-        private Class serializerClass;
-        private Class deserializerClass;
-        private boolean canSearchParents;
-        private FieldDesc[] fields;
-        
+        protected Class clazz;
+        protected QName qName;
+        protected Class serializerClass;
+        protected Class deserializerClass;
+        protected boolean canSearchParents;
+        protected FieldDesc[] fields;
+
         public TypeInfo buildTypeInfo() {
             if (null == clazz) {
                 throw new IllegalStateException("clazz is null");



Mime
View raw message