You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2006/02/01 15:17:36 UTC

svn commit: r374072 [2/3] - in /webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed: ./ rpc/ src/ src/org/ src/org/apache/ src/org/apache/axis2/ src/org/apache/axis2/databinding/ src/org/apache/axis2/databinding/beans/ src/org/apache/axis2/databin...

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/beans/BeanPropertyDescriptor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/beans/BeanPropertyDescriptor.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/beans/BeanPropertyDescriptor.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/beans/BeanPropertyDescriptor.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2004,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.axis2.databinding.beans;
+
+import org.apache.axis2.databinding.metadata.FieldAccessor;
+import org.apache.axis2.databinding.metadata.IndexedFieldAccessor;
+
+import java.lang.reflect.Method;
+
+/**
+ * BeanPropertyDescriptor
+ */
+public class BeanPropertyDescriptor implements FieldAccessor, IndexedFieldAccessor {
+    Method readMethod;
+    Method writeMethod;
+    Method indexedReadMethod;
+    Method indexedWriteMethod;
+
+    public Method getReadMethod() {
+        return readMethod;
+    }
+
+    public void setReadMethod(Method readMethod) {
+        this.readMethod = readMethod;
+    }
+
+    public Method getWriteMethod() {
+        return writeMethod;
+    }
+
+    public void setWriteMethod(Method writeMethod) {
+        this.writeMethod = writeMethod;
+    }
+
+    public Method getIndexedReadMethod() {
+        return indexedReadMethod;
+    }
+
+    public void setIndexedReadMethod(Method indexedReadMethod) {
+        this.indexedReadMethod = indexedReadMethod;
+    }
+
+    public Method getIndexedWriteMethod() {
+        return indexedWriteMethod;
+    }
+
+    public void setIndexedWriteMethod(Method indexedWriteMethod) {
+        this.indexedWriteMethod = indexedWriteMethod;
+    }
+
+    public Object getValue(Object targetObject) throws Exception {
+        return readMethod.invoke(targetObject, null);
+    }
+
+    public void setValue(Object targetObject, Object value) throws Exception {
+        writeMethod.invoke(targetObject, new Object [] { value });
+    }
+    
+    public Object getIndexedValue(Object targetObject, int index)
+            throws Exception {
+        return indexedReadMethod.invoke(targetObject,
+                                        new Object [] { new Integer(index) });
+    }
+
+    public void setIndexedValue(Object targetObject,
+                                Object value,
+                                int index) throws Exception {
+        indexedWriteMethod.invoke(targetObject,
+                                  new Object [] { new Integer(index), value });
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/BeanDeserializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/BeanDeserializer.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/BeanDeserializer.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/BeanDeserializer.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2004,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.axis2.databinding.deserializers;
+
+import org.apache.axis2.databinding.DeserializationContext;
+import org.apache.axis2.databinding.DeserializationTarget;
+import org.apache.axis2.databinding.Deserializer;
+import org.apache.axis2.databinding.metadata.AttributeDesc;
+import org.apache.axis2.databinding.metadata.ElementDesc;
+import org.apache.axis2.databinding.metadata.TypeDesc;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * BeanDeserializer
+ */
+public class BeanDeserializer implements Deserializer {
+    private DeserializationTarget target;
+
+    TypeDesc typeDesc;
+    Object targetObject;
+    Class javaClass;
+
+    public BeanDeserializer(TypeDesc typeDesc) {
+        this.typeDesc = typeDesc;
+        this.javaClass = typeDesc.getJavaClass();
+    }
+
+    public void deserialize(XMLStreamReader reader,
+                            DeserializationContext context) throws Exception {
+        targetObject = createTargetObject();
+        Map elementCounts = new HashMap();
+
+        // Get the attributes
+        for (Iterator i = typeDesc.getAttributeDescs(); i.hasNext();) {
+            AttributeDesc attrDesc = (AttributeDesc)i.next();
+            QName qname = attrDesc.getQName();
+            String val = reader.getAttributeValue(qname.getNamespaceURI(),
+                                                  qname.getLocalPart());
+            if (val != null) {
+                Object value =
+                        ((SimpleDeserializer)attrDesc.getDeserializer(0)).
+                        makeValue(val);
+                attrDesc.setValue(targetObject, value);
+            }
+        }
+
+        boolean done = false;
+        while (!done) {
+            int event = reader.next();
+            if (event == XMLStreamConstants.END_ELEMENT) {
+                target.setValue(targetObject);
+                return;
+            }
+            if (event == XMLStreamConstants.END_DOCUMENT) {
+                throw new Exception("Unfinished element!");
+            }
+
+            if (event == XMLStreamConstants.START_ELEMENT) {
+                // Work through the child elements
+                QName elementName = reader.getName();
+                ElementDesc desc = typeDesc.getElementDesc(elementName);
+                if (desc != null) {
+                    Integer count = (Integer)elementCounts.get(elementName);
+                    if (count == null) count = new Integer(0);
+                    elementCounts.put(elementName,
+                                      new Integer(count.intValue() + 1));
+                    Deserializer dser =
+                            desc.getDeserializer(count.intValue(), targetObject);
+                    context.deserialize(reader, dser);
+                }
+            }
+        }
+    }
+
+    private Object createTargetObject() throws Exception {
+        return javaClass.newInstance();
+    }
+
+    public void setTarget(DeserializationTarget target) {
+        this.target = target;
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/BeanDeserializerFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/BeanDeserializerFactory.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/BeanDeserializerFactory.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/BeanDeserializerFactory.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2004,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.axis2.databinding.deserializers;
+
+import org.apache.axis2.databinding.Deserializer;
+import org.apache.axis2.databinding.DeserializerFactory;
+import org.apache.axis2.databinding.metadata.TypeDesc;
+
+/**
+ * BeanDeserializerFactory
+ */
+public class BeanDeserializerFactory implements DeserializerFactory {
+    TypeDesc typeDesc;
+
+    public BeanDeserializerFactory(TypeDesc typeDesc) {
+        this.typeDesc = typeDesc;
+    }
+
+    public Deserializer getDeserializer() {
+        return new BeanDeserializer(typeDesc);
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/CollectionDeserializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/CollectionDeserializer.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/CollectionDeserializer.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/CollectionDeserializer.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2004,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.axis2.databinding.deserializers;
+
+import org.apache.axis2.databinding.DeserializationContext;
+import org.apache.axis2.databinding.DeserializationTarget;
+import org.apache.axis2.databinding.Deserializer;
+
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * CollectionDeserializer
+ */
+public class CollectionDeserializer implements Deserializer {
+    Deserializer itemDeserializer;
+
+    public void deserialize(XMLStreamReader reader, DeserializationContext context) throws Exception {
+        // strip the wrapper element.
+        reader.next();
+
+        // Now deserialize each inner element
+        itemDeserializer.deserialize(reader, context);
+    }
+
+    public void setTarget(DeserializationTarget target) {
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/SimpleDeserializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/SimpleDeserializer.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/SimpleDeserializer.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/SimpleDeserializer.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,350 @@
+/*
+ * Copyright 2004,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.axis2.databinding.deserializers;
+
+import org.apache.axis2.databinding.DeserializationContext;
+import org.apache.axis2.databinding.DeserializationTarget;
+import org.apache.axis2.databinding.Deserializer;
+import org.apache.axis2.databinding.metadata.TypeDesc;
+import org.apache.axis2.i18n.Messages;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+import java.lang.reflect.Constructor;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+/**
+ * SimpleDeserializer
+ */
+public class SimpleDeserializer implements Deserializer {
+    private static SimpleDateFormat zulu =
+            new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+    //  0123456789 0 123456789
+
+    static {
+        zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
+    }
+
+    private static final Class[] STRING_STRING_CLASS =
+        new Class [] {String.class, String.class};
+
+    public static final Class[] STRING_CLASS =
+        new Class [] {String.class};
+
+    Class javaType;
+    QName xmlType;
+    Constructor constructor;
+    XMLStreamReader reader;
+    TypeDesc typeDesc;
+    DeserializationTarget target;
+
+    public SimpleDeserializer(Class javaType, QName xmlType) {
+        this.javaType = javaType;
+        this.xmlType = xmlType;
+    }
+
+    public void setTypeDesc(TypeDesc typeDesc) {
+        this.typeDesc = typeDesc;
+    }
+
+    public void setTarget(DeserializationTarget target) {
+        this.target = target;
+    }
+
+    public void deserialize(XMLStreamReader reader,
+                            DeserializationContext context) throws Exception {
+        this.reader = reader;
+        // We're expecting text and then an end element.
+        int eventType;
+        String text = new String();
+        while ((eventType = reader.next()) != XMLStreamConstants.END_DOCUMENT) {
+            if (eventType == XMLStreamConstants.START_ELEMENT) {
+                eventType = reader.next();
+            }
+            if (eventType == XMLStreamConstants.CHARACTERS) {
+                text = text.concat(reader.getText());
+            }
+            if (eventType == XMLStreamConstants.END_ELEMENT) {
+                // End of element
+                target.setValue(makeValue(text));
+                return;
+            }
+        }
+        throw new Exception("End of document reached prematurely!");
+    }
+
+    /**
+     * Convert the string that has been accumulated into an Object.  Subclasses
+     * may override this.  Note that if the javaType is a primitive, the returned
+     * object is a wrapper class.
+     * @param source the serialized value to be deserialized
+     * @throws Exception any exception thrown by this method will be wrapped
+     */
+    public Object makeValue(String source) throws Exception
+    {
+        if (javaType == java.lang.String.class) {
+            return source;
+        }
+
+        // Trim whitespace if non-String
+        source = source.trim();
+
+        if (source.length() == 0) {
+            return null;
+        }
+
+        // if constructor is set skip all basic java type checks
+        if (this.constructor == null) {
+            Object value = makeBasicValue(source);
+            if (value != null) {
+                return value;
+            }
+        }
+
+        Object [] args = null;
+
+        boolean isQNameSubclass = QName.class.isAssignableFrom(javaType);
+
+        if (isQNameSubclass) {
+            int colon = source.lastIndexOf(":");
+            String namespace = colon < 0 ? "" :
+                reader.getNamespaceURI(source.substring(0, colon));
+            String localPart = colon < 0 ? source : source.substring(colon + 1);
+            args = new Object [] {namespace, localPart};
+        }
+
+        if (constructor == null) {
+            try {
+                if (isQNameSubclass) {
+                    constructor =
+                        javaType.getDeclaredConstructor(STRING_STRING_CLASS);
+                } else {
+                    constructor =
+                        javaType.getDeclaredConstructor(STRING_CLASS);
+                }
+            } catch (Exception e) {
+                return null;
+            }
+        }
+
+        if(constructor.getParameterTypes().length==0){
+            try {
+                Object obj = constructor.newInstance(new Object[]{});
+                obj.getClass().getMethod("set_value", new Class[]{String.class})
+                        .invoke(obj, new Object[]{source});
+                return obj;
+            } catch (Exception e){
+                //Ignore exception
+            }
+        }
+        if (args == null) {
+            args = new Object[]{source};
+        }
+        return constructor.newInstance(args);
+    }
+
+    private Object makeBasicValue(String source) throws Exception {
+        // If the javaType is a boolean, except a number of different sources
+        if (javaType == boolean.class ||
+            javaType == Boolean.class) {
+            // This is a pretty lame test, but it is what the previous code did.
+            switch (source.charAt(0)) {
+                case '0': case 'f': case 'F':
+                    return Boolean.FALSE;
+
+                case '1': case 't': case 'T':
+                    return Boolean.TRUE;
+
+                default:
+                    throw new NumberFormatException("Bad boolean expression");
+                }
+
+        }
+
+        // If expecting a Float or a Double, need to accept some special cases.
+        if (javaType == float.class ||
+            javaType == java.lang.Float.class) {
+            if (source.equals("NaN")) {
+                return new Float(Float.NaN);
+            } else if (source.equals("INF")) {
+                return new Float(Float.POSITIVE_INFINITY);
+            } else if (source.equals("-INF")) {
+                return new Float(Float.NEGATIVE_INFINITY);
+            } else {
+                return new Float(source);
+            }
+        }
+
+        if (javaType == double.class ||
+            javaType == java.lang.Double.class) {
+            if (source.equals("NaN")) {
+                return new Double(Double.NaN);
+            } else if (source.equals("INF")) {
+                return new Double(Double.POSITIVE_INFINITY);
+            } else if (source.equals("-INF")) {
+                return new Double(Double.NEGATIVE_INFINITY);
+            } else {
+                return new Double(source);
+            }
+        }
+
+        if (javaType == int.class ||
+            javaType == java.lang.Integer.class) {
+            return new Integer(source);
+        }
+
+        if (javaType == short.class ||
+            javaType == java.lang.Short.class) {
+            return new Short(source);
+        }
+
+        if (javaType == long.class ||
+            javaType == java.lang.Long.class) {
+            return new Long(source);
+        }
+
+        if (javaType == byte.class ||
+            javaType == java.lang.Byte.class) {
+            return new Byte(source);
+        }
+
+/*
+        if (javaType == org.apache.axis.types.URI.class) {
+            return new org.apache.axis.types.URI(source);
+        }
+*/
+
+        if (javaType == Calendar.class) {
+            return makeCalendar(source, false);
+        }
+
+        return null;
+    }
+
+    public static Object makeCalendar(String source, boolean returnDate) {
+        Calendar calendar = Calendar.getInstance();
+        Date date;
+        boolean bc = false;
+
+        // validate fixed portion of format
+        if (source == null || source.length() == 0) {
+            throw new NumberFormatException(
+                    Messages.getMessage("badDateTime00"));
+        }
+        if (source.charAt(0) == '+') {
+            source = source.substring(1);
+        }
+        if (source.charAt(0) == '-') {
+            source = source.substring(1);
+            bc = true;
+        }
+        if (source.length() < 19) {
+            throw new NumberFormatException(
+                    Messages.getMessage("badDateTime00"));
+        }
+        if (source.charAt(4) != '-' || source.charAt(7) != '-' ||
+                source.charAt(10) != 'T') {
+            throw new NumberFormatException(Messages.getMessage("badDate00"));
+        }
+        if (source.charAt(13) != ':' || source.charAt(16) != ':') {
+            throw new NumberFormatException(Messages.getMessage("badTime00"));
+        }
+        // convert what we have validated so far
+        try {
+            synchronized (zulu) {
+                date = zulu.parse(source.substring(0, 19) + ".000Z");
+            }
+        } catch (Exception e) {
+            throw new NumberFormatException(e.toString());
+        }
+        int pos = 19;
+
+        // parse optional milliseconds
+        if (pos < source.length() && source.charAt(pos) == '.') {
+            int milliseconds = 0;
+            int start = ++pos;
+            while (pos < source.length() &&
+                    Character.isDigit(source.charAt(pos))) {
+                pos++;
+            }
+            String decimal = source.substring(start, pos);
+            if (decimal.length() == 3) {
+                milliseconds = Integer.parseInt(decimal);
+            } else if (decimal.length() < 3) {
+                milliseconds = Integer.parseInt((decimal + "000")
+                        .substring(0, 3));
+            } else {
+                milliseconds = Integer.parseInt(decimal.substring(0, 3));
+                if (decimal.charAt(3) >= '5') {
+                    ++milliseconds;
+                }
+            }
+
+            // add milliseconds to the current date
+            date.setTime(date.getTime() + milliseconds);
+        }
+
+        // parse optional timezone
+        if (pos + 5 < source.length() &&
+                (source.charAt(pos) == '+' || (source.charAt(pos) == '-'))) {
+            if (!Character.isDigit(source.charAt(pos + 1)) ||
+                    !Character.isDigit(source.charAt(pos + 2)) ||
+                    source.charAt(pos + 3) != ':' ||
+                    !Character.isDigit(source.charAt(pos + 4)) ||
+                    !Character.isDigit(source.charAt(pos + 5))) {
+                throw new NumberFormatException(
+                        Messages.getMessage("badTimezone00"));
+            }
+            int hours = (source.charAt(pos + 1) - '0') * 10
+                    + source.charAt(pos + 2) - '0';
+            int mins = (source.charAt(pos + 4) - '0') * 10
+                    + source.charAt(pos + 5) - '0';
+            int milliseconds = (hours * 60 + mins) * 60 * 1000;
+
+            // subtract milliseconds from current date to obtain GMT
+            if (source.charAt(pos) == '+') {
+                milliseconds = -milliseconds;
+            }
+            date.setTime(date.getTime() + milliseconds);
+            pos += 6;
+        }
+        if (pos < source.length() && source.charAt(pos) == 'Z') {
+            pos++;
+            calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
+        }
+        if (pos < source.length()) {
+            throw new NumberFormatException(Messages.getMessage("badChars00"));
+        }
+        calendar.setTime(date);
+
+        // support dates before the Christian era
+        if (bc) {
+            calendar.set(Calendar.ERA, GregorianCalendar.BC);
+        }
+
+        if (returnDate) {
+            return date;
+        } else {
+            return calendar;
+        }
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/SimpleDeserializerFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/SimpleDeserializerFactory.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/SimpleDeserializerFactory.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/deserializers/SimpleDeserializerFactory.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2004,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.axis2.databinding.deserializers;
+
+import org.apache.axis2.databinding.Deserializer;
+import org.apache.axis2.databinding.DeserializerFactory;
+
+import javax.xml.namespace.QName;
+
+/**
+ * SimpleDeserializerFactory
+ */
+public class SimpleDeserializerFactory implements DeserializerFactory {
+    QName xmlType;
+    Class javaType;
+
+    public SimpleDeserializerFactory(Class javaType, QName xmlType) {
+        this.xmlType = xmlType;
+        this.javaType = javaType;
+    }
+
+    public Deserializer getDeserializer() {
+        return new SimpleDeserializer(javaType, xmlType);
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/AttributeDesc.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/AttributeDesc.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/AttributeDesc.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/AttributeDesc.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2004,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.axis2.databinding.metadata;
+
+/**
+ * AttributeDesc
+ */
+public class AttributeDesc extends FieldDesc {
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/BeanManager.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/BeanManager.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/BeanManager.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/BeanManager.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2004,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.axis2.databinding.metadata;
+
+import org.apache.axis2.databinding.DeserializerFactory;
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.beans.BeanPropertyDescriptor;
+import org.apache.axis2.databinding.typemapping.TypeMappingRegistry;
+
+import javax.xml.namespace.QName;
+import java.beans.BeanInfo;
+import java.beans.IndexedPropertyDescriptor;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * BeanManager
+ */
+public class BeanManager {
+    static Map class2TypeMap = new HashMap();
+
+    public static TypeDesc getTypeDesc(Class beanClass) {
+        // If we're already done with this class, just return the cached one
+        TypeDesc desc = (TypeDesc)class2TypeMap.get(beanClass);
+        if (desc != null)
+            return desc;
+
+        // OK, nothing cached.  See if the class has supplied some data itself
+        desc = TypeDesc.getTypeDescForClass(beanClass);
+        if (desc == null) {
+            desc = new TypeDesc();
+        }
+
+        class2TypeMap.put(beanClass, desc);
+
+        try {
+            fillInTypeDesc(desc, beanClass);
+        } catch (Exception e) {
+            desc = null;
+            class2TypeMap.remove(beanClass);
+        }
+
+        return desc;
+    }
+
+    private static void fillInTypeDesc(TypeDesc desc, Class beanClass)
+            throws Exception {
+        TypeMappingRegistry tmr = new TypeMappingRegistry();
+
+        desc.setJavaClass(beanClass);
+
+        BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
+        PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
+        for (int i = 0; i < propDescs.length; i++) {
+            PropertyDescriptor propDesc = propDescs[i];
+            String name = propDesc.getName();
+
+            if (name.equals("class"))
+                continue;
+
+            BeanPropertyDescriptor beanDesc = new BeanPropertyDescriptor();
+            beanDesc.setReadMethod(propDesc.getReadMethod());
+            beanDesc.setWriteMethod(propDesc.getWriteMethod());
+
+            ElementDesc elDesc = desc.getElementDesc(name);
+            boolean addDesc = true;  // Should we add this (new) element?
+            if (elDesc == null) {
+                elDesc = new ElementDesc();
+                elDesc.setFieldName(name);
+            } else {
+                addDesc = false; // Already present, so don't add it again
+            }
+            Class type;
+            boolean isCollection = false;
+            if (propDesc instanceof IndexedPropertyDescriptor) {
+                IndexedPropertyDescriptor iProp =
+                        (IndexedPropertyDescriptor)propDesc;
+                beanDesc.setIndexedReadMethod(iProp.getIndexedReadMethod());
+                beanDesc.setIndexedWriteMethod(iProp.getIndexedWriteMethod());
+                type = iProp.getIndexedPropertyType();
+                elDesc.setIndexedAccessor(beanDesc);
+                isCollection = true;
+            } else {
+                type = propDesc.getPropertyType();
+                // TODO : check if this is a supported collection type
+            }
+
+            if (isCollection && elDesc.getMaxOccurs() == 0)
+                elDesc.setMaxOccurs(-1);
+
+            elDesc.setAccessor(beanDesc);
+
+            if (elDesc.getQName() == null) {
+                elDesc.setQName(new QName(name));
+            }
+
+            if (elDesc.getDeserializerFactory() == null) {
+                DeserializerFactory dser = tmr.getDeserializerFactory(type);
+                elDesc.setDeserializerFactory(dser);
+            }
+
+            if (elDesc.getRawSerializer() == null) {
+                Serializer ser = tmr.getSerializer(type);
+                elDesc.setSerializer(ser);
+            }
+
+            if (addDesc)
+                desc.addField(elDesc);
+        }
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/ElementDesc.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/ElementDesc.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/ElementDesc.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/ElementDesc.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2004,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.axis2.databinding.metadata;
+
+import org.apache.axis2.databinding.DeserializationTarget;
+import org.apache.axis2.databinding.Deserializer;
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.serializers.CollectionSerializer;
+
+import javax.xml.namespace.QName;
+
+/**
+ * ElementDesc
+ */
+public class ElementDesc extends FieldDesc {
+    protected IndexedFieldAccessor indexedAccessor;
+    protected QName itemQName;
+
+    class FieldTarget implements DeserializationTarget {
+        Object targetObject;
+        FieldAccessor accessor;
+
+        public FieldTarget(Object targetObject, FieldAccessor accessor) {
+            this.targetObject = targetObject;
+            this.accessor = accessor;
+        }
+
+        public void setValue(Object value) throws Exception {
+            accessor.setValue(targetObject, value);
+        }
+    }
+
+    protected int minOccurs = 0;
+
+    // Might seem strange to default this to zero, but we do it because
+    // we want to be able to tell in BeanManager.fillInTypeDesc() if someone
+    // set this manually or not.  If it's still zero in there (meaning default
+    // values are good) we'll set it to 1 for a normal field and -1 (unbounded)
+    // for a collection field.
+    protected int maxOccurs = 0;
+
+    public int getMinOccurs() {
+        return minOccurs;
+    }
+
+    public void setMinOccurs(int minOccurs) {
+        this.minOccurs = minOccurs;
+    }
+
+    public int getMaxOccurs() {
+        return maxOccurs;
+    }
+
+    public void setMaxOccurs(int maxOccurs) {
+        this.maxOccurs = maxOccurs;
+    }
+
+    public QName getItemQName() {
+        return itemQName;
+    }
+
+    public void setItemQName(QName itemQName) {
+        this.itemQName = itemQName;
+    }
+
+    public Deserializer getDeserializer(int index, Object targetObject) {
+        if (index > maxOccurs && maxOccurs > -1) {
+            throw new RuntimeException("Too many elements (maxOccurs = " +
+                                       maxOccurs + ") called " + qname + " !");
+        }
+
+        Deserializer dser = deserializerFactory.getDeserializer();
+        FieldAccessor accessor;
+        if (maxOccurs > 1 || maxOccurs == -1) {
+            accessor = new IndexedAccessorWrapper(indexedAccessor, index);
+        } else {
+            accessor = this.accessor;
+        }
+
+        dser.setTarget(new FieldTarget(targetObject, accessor));
+
+        return dser;
+    }
+
+    public Serializer getSerializer() {
+        if (maxOccurs > 1 || maxOccurs == -1) {
+            if (itemQName != null) {
+                return new CollectionSerializer(itemQName,
+                                                true,
+                                                super.getSerializer());
+            } else {
+                return new CollectionSerializer(qname,
+                                                false,
+                                                super.getSerializer());
+            }
+        }
+        return super.getSerializer();
+    }
+
+    public void setIndexedAccessor(IndexedFieldAccessor indexedAccessor) {
+        this.indexedAccessor = indexedAccessor;
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/FieldAccessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/FieldAccessor.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/FieldAccessor.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/FieldAccessor.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2004,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.axis2.databinding.metadata;
+
+/**
+ * FieldAccessor
+ */
+public interface FieldAccessor {
+    public Object getValue(Object targetObject) throws Exception;
+    public void setValue(Object targetObject, Object value) throws Exception;
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/FieldDesc.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/FieldDesc.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/FieldDesc.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/FieldDesc.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004,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.axis2.databinding.metadata;
+
+import org.apache.axis2.databinding.Deserializer;
+import org.apache.axis2.databinding.DeserializerFactory;
+import org.apache.axis2.databinding.Serializer;
+
+import javax.xml.namespace.QName;
+
+/**
+ * FieldDesc
+ */
+public abstract class FieldDesc implements FieldAccessor {
+    protected QName qname;
+    protected FieldAccessor accessor;
+    protected DeserializerFactory deserializerFactory;
+    protected Serializer ser;
+    protected String fieldName;
+
+    public String getFieldName() {
+        return fieldName;
+    }
+
+    public void setFieldName(String fieldName) {
+        this.fieldName = fieldName;
+    }
+
+    public QName getQName() {
+        return qname;
+    }
+
+    public void setQName(QName qname) {
+        this.qname = qname;
+    }
+
+    public FieldAccessor getAccessor() {
+        return accessor;
+    }
+
+    public void setAccessor(FieldAccessor accessor) {
+        this.accessor = accessor;
+    }
+
+    public Object getValue(Object targetObject) throws Exception {
+        return accessor.getValue(targetObject);
+    }
+
+    public void setValue(Object targetObject, Object value) throws Exception {
+        accessor.setValue(targetObject, value);
+    }
+
+    public Serializer getSerializer() {
+        return ser;
+    }
+
+    public void setSerializer(Serializer ser) {
+        this.ser = ser;
+    }
+
+    Serializer getRawSerializer() {
+        return ser;
+    }
+
+    public Deserializer getDeserializer(int index) {
+        if (index > 0)
+            throw new RuntimeException("Only one element " + qname + " allowed");
+        return deserializerFactory.getDeserializer();
+    }
+
+    public void setDeserializerFactory(DeserializerFactory deser) {
+        this.deserializerFactory = deser;
+    }
+
+    public DeserializerFactory getDeserializerFactory() {
+        return deserializerFactory;
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/IndexedAccessorWrapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/IndexedAccessorWrapper.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/IndexedAccessorWrapper.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/IndexedAccessorWrapper.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004,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.axis2.databinding.metadata;
+
+/**
+ * IndexedAccessorWrapper
+ */
+public class IndexedAccessorWrapper implements FieldAccessor {
+    IndexedFieldAccessor accessor;
+    int index;
+
+    public IndexedAccessorWrapper(IndexedFieldAccessor accessor, int index) {
+        this.accessor = accessor;
+        this.index = index;
+    }
+
+    public Object getValue(Object targetObject) throws Exception {
+        return accessor.getIndexedValue(targetObject, index);
+    }
+
+    public void setValue(Object targetObject, Object value) throws Exception {
+        accessor.setIndexedValue(targetObject, value, index);
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/IndexedFieldAccessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/IndexedFieldAccessor.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/IndexedFieldAccessor.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/IndexedFieldAccessor.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2004,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.axis2.databinding.metadata;
+
+/**
+ * IndexedFieldAccessor
+ */
+public interface IndexedFieldAccessor {
+    public Object getIndexedValue(Object targetObject, int index)
+            throws Exception;
+
+    public void setIndexedValue(Object targetObject,
+                                Object value,
+                                int index) throws Exception;
+
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/TypeDesc.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/TypeDesc.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/TypeDesc.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/metadata/TypeDesc.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2004,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.axis2.databinding.metadata;
+
+import org.apache.axis2.databinding.utils.MethodCache;
+
+import javax.xml.namespace.QName;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * TypeDesc
+ */
+public class TypeDesc {
+    public static final Class [] noClasses = new Class [] {};
+    public static final Object[] noObjects = new Object[] {};
+
+    /** A map of class -> TypeDesc */
+    private static Map classMap = new Hashtable();
+
+    /**
+     * Static function for centralizing access to type metadata for a
+     * given class.
+     *
+     * This checks for a static getTypeDesc() method on the
+     * class or _Helper class.
+     * Eventually we may extend this to provide for external
+     * metadata config (via files sitting in the classpath, etc).
+     *
+     */
+    public static TypeDesc getTypeDescForClass(Class cls)
+    {
+        // First see if we have one explicitly registered
+        // or cached from previous lookup
+        TypeDesc result = (TypeDesc)classMap.get(cls);
+
+        if (result == null) {
+            try {
+                Method getTypeDesc =
+                    MethodCache.getInstance().getMethod(cls,
+                                                        "getTypeDesc",
+                                                        noClasses);
+                if (getTypeDesc != null) {
+                    result = (TypeDesc)getTypeDesc.invoke(null, noObjects);
+                    if (result != null) {
+                        classMap.put(cls, result);
+                    }
+                }
+            } catch (Exception e) {
+            }
+        }
+
+        return result;
+    }
+
+    Map elements = new HashMap();
+    Map fieldsByName = new HashMap();
+    Map attrs = new HashMap();
+    Class javaClass;
+
+    public Iterator getAttributeDescs() {
+        return attrs.values().iterator();
+    }
+
+    public void addField(ElementDesc fieldDesc) {
+        elements.put(fieldDesc.getQName(), fieldDesc);
+        fieldsByName.put(fieldDesc.getFieldName(), fieldDesc);
+    }
+
+    public void addField(AttributeDesc fieldDesc) {
+        attrs.put(fieldDesc.getQName(), fieldDesc);
+    }
+
+    public ElementDesc getElementDesc(QName qname) {
+        return (ElementDesc)elements.get(qname);
+    }
+
+    public ElementDesc getElementDesc(String fieldName) {
+        return (ElementDesc)fieldsByName.get(fieldName);
+    }
+
+    public Iterator getElementDescs() {
+        return elements.values().iterator();
+    }
+
+    public Class getJavaClass() {
+        return javaClass;
+    }
+
+    public void setJavaClass(Class javaClass) {
+        this.javaClass = javaClass;
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/AbstractSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/AbstractSerializer.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/AbstractSerializer.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/AbstractSerializer.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004,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.axis2.databinding.serializers;
+
+import org.apache.axis2.databinding.SerializationContext;
+import org.apache.axis2.databinding.Serializer;
+
+/**
+ * AbstractSerializer
+ */
+public abstract class AbstractSerializer implements Serializer {
+    public void serialize(Object object, SerializationContext context)
+            throws Exception {
+        if (!context.checkMultiref(object, this)) {
+            serializeData(object, context);
+        }
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/BeanSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/BeanSerializer.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/BeanSerializer.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/BeanSerializer.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004,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.axis2.databinding.serializers;
+
+import org.apache.axis2.databinding.SerializationContext;
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.metadata.ElementDesc;
+import org.apache.axis2.databinding.metadata.TypeDesc;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * BeanSerializer
+ */
+public class BeanSerializer extends AbstractSerializer {
+    TypeDesc typeDesc;
+
+    public BeanSerializer(TypeDesc typeDesc) {
+        this.typeDesc = typeDesc;
+    }
+
+    public void serializeData(Object object, SerializationContext context)
+            throws Exception {
+        // Write any attributes that need writing here
+
+        Iterator elements = typeDesc.getElementDescs();
+        while (elements.hasNext()) {
+            ElementDesc desc = (ElementDesc) elements.next();
+            Object fieldValue = desc.getValue(object);
+            Serializer ser = desc.getSerializer();
+            QName qname = desc.getQName();
+            context.serializeElement(qname, fieldValue, ser);
+        }
+
+        context.getWriter().writeEndElement();
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/CollectionSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/CollectionSerializer.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/CollectionSerializer.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/CollectionSerializer.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2004,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.axis2.databinding.serializers;
+
+import org.apache.axis2.databinding.SerializationContext;
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.utils.Converter;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamWriter;
+import java.lang.reflect.Array;
+import java.util.Collection;
+
+/**
+ * CollectionSerializer
+ */
+public class CollectionSerializer extends AbstractSerializer {
+    public final QName DEFAULT_ITEM_QNAME = new QName("item");
+
+    boolean isWrapped;
+    QName itemQName;
+    Serializer serializer;
+
+    public CollectionSerializer(QName itemQName,
+                                boolean isWrapped,
+                                Serializer serializer) {
+        this.isWrapped = isWrapped;
+        this.itemQName = itemQName == null ? DEFAULT_ITEM_QNAME : itemQName;
+        this.serializer = serializer;
+    }
+
+    public void serialize(Object object, SerializationContext context) throws Exception {
+        if (isWrapped) {
+            // We have a wrapper element, so it's fine to do multiref checking
+            // on the actual collection object
+            super.serialize(object, context);
+            return;
+        }
+
+        // No wrapper, so need to do multiref checks on individual elements.
+        serializeData(object, context);
+    }
+
+    public void serializeData(Object object, SerializationContext context)
+            throws Exception {
+        if (object instanceof Collection) {
+            Converter.convert(object, Object[].class);
+        }
+        XMLStreamWriter writer = context.getWriter();
+        if (isWrapped) {
+            writer.writeStartElement(itemQName.getNamespaceURI(),
+                                     itemQName.getLocalPart());
+        }
+
+        int len = Array.getLength(object);
+        for (int i = 0; i < len; i++) {
+            Object item = Array.get(object, i);
+            if (i == 0) {
+                if (isWrapped) {
+                    if (!context.checkMultiref(item, serializer)) {
+                        serializer.serializeData(item, context);
+                    }
+                } else {
+                    serializer.serializeData(item, context);
+                }
+            } else {
+                context.serializeElement(itemQName, item, serializer);
+            }
+        }
+
+        if (isWrapped) {
+            writer.writeEndElement();
+        }
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/SimpleSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/SimpleSerializer.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/SimpleSerializer.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/serializers/SimpleSerializer.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2004,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.axis2.databinding.serializers;
+
+import org.apache.axis2.databinding.SerializationContext;
+
+import javax.xml.namespace.QName;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+/**
+ * SimpleSerializer
+ */
+public class SimpleSerializer extends AbstractSerializer {
+    private static SimpleDateFormat zulu =
+       new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+                         //  0123456789 0 123456789
+
+    static {
+        zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
+    }
+
+    public void serialize(Object object, SerializationContext context) throws Exception {
+        // Simple types never get multiref'd, so just write the data now.
+        serializeData(object, context);
+    }
+
+    public void serializeData(Object object, SerializationContext context)
+            throws Exception {
+        String value = object.toString();
+        context.getWriter().writeCharacters(value);
+        context.getWriter().writeEndElement();
+    }
+
+    public String getValueAsString(Object value, SerializationContext context) {
+        // We could have separate serializers/deserializers to take
+        // care of Float/Double cases, but it makes more sence to
+        // put them here with the rest of the java lang primitives.
+        if (value instanceof Float ||
+            value instanceof Double) {
+            double data = 0.0;
+            if (value instanceof Float) {
+                data = ((Float) value).doubleValue();
+            } else {
+                data = ((Double) value).doubleValue();
+            }
+            if (Double.isNaN(data)) {
+                return "NaN";
+            } else if (data == Double.POSITIVE_INFINITY) {
+                return "INF";
+            } else if (data == Double.NEGATIVE_INFINITY) {
+                return "-INF";
+            }
+        } else if (value instanceof QName) {
+            return context.qName2String((QName)value);
+        }
+
+        return value.toString();
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/typemapping/TypeMappingRegistry.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/typemapping/TypeMappingRegistry.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/typemapping/TypeMappingRegistry.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/databinding/typemapping/TypeMappingRegistry.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2004,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.axis2.databinding.typemapping;
+
+import org.apache.axis2.databinding.DeserializerFactory;
+import org.apache.axis2.databinding.Serializer;
+import org.apache.axis2.databinding.deserializers.BeanDeserializerFactory;
+import org.apache.axis2.databinding.deserializers.SimpleDeserializerFactory;
+import org.apache.axis2.databinding.metadata.BeanManager;
+import org.apache.axis2.databinding.serializers.BeanSerializer;
+import org.apache.axis2.databinding.serializers.SimpleSerializer;
+import org.apache.ws.commons.schema.constants.Constants;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * TypeMappingRegistry
+ */
+public class TypeMappingRegistry {
+    public static boolean isPrimitive(Object value) {
+        if (value == null) return true;
+
+        Class javaType = (value instanceof Class) ? (Class)value :
+                value.getClass();
+
+        if (javaType.isPrimitive()) return true;
+
+        if (javaType == String.class) return true;
+        if (Calendar.class.isAssignableFrom(javaType)) return true;
+        if (Date.class.isAssignableFrom(javaType)) return true;
+        if (Element.class.isAssignableFrom(javaType)) return true;
+        if (javaType == byte[].class) return true;
+        if (Number.class.isAssignableFrom(javaType)) return true;
+
+        // There has been discussion as to whether arrays themselves should
+        // be regarded as multi-ref.
+        // Here are the three options:
+        //   1) Arrays are full-fledged Objects and therefore should always be
+        //      multi-ref'd  (Pro: This is like java.  Con: Some runtimes don't
+        //      support this yet, and it requires more stuff to be passed over the wire.)
+        //   2) Arrays are not full-fledged Objects and therefore should
+        //      always be passed as single ref (note the elements of the array
+        //      may be multi-ref'd.) (Pro:  This seems reasonable, if a user
+        //      wants multi-referencing put the array in a container.  Also
+        //      is more interop compatible.  Con: Not like java serialization.)
+        //   3) Arrays of primitives should be single ref, and arrays of
+        //      non-primitives should be multi-ref.  (Pro: Takes care of the
+        //      looping case.  Con: Seems like an obtuse rule.)
+        //
+        // Changing the code from (1) to (2) to see if interop fairs better.
+        return javaType.isArray();
+
+    }
+
+    public boolean isCollection() {
+        return false;
+    }
+
+    public DeserializerFactory getDeserializerFactory(Class cls) {
+        if (isPrimitive(cls)) {
+            return new SimpleDeserializerFactory(cls, new QName("xsd", cls.getName()));
+        }
+
+        
+
+        return new BeanDeserializerFactory(BeanManager.getTypeDesc(cls));
+    }
+
+    public Serializer getSerializer(Class cls) {
+        if (isPrimitive(cls)) {
+            return new SimpleSerializer();
+        }
+
+        return new BeanSerializer(BeanManager.getTypeDesc(cls));
+    }
+    
+    public void registerMapping(Class javaType,
+                                QName xmlType,
+                                Serializer serializer,
+                                DeserializerFactory deserFactory) {
+
+    }
+
+    public void initializeSchemaTypes() {
+        myRegisterSimple(Constants.XSD_STRING, java.lang.String.class);
+        myRegisterSimple(Constants.XSD_BOOLEAN, java.lang.Boolean.class);
+        myRegisterSimple(Constants.XSD_DOUBLE, java.lang.Double.class);
+        myRegisterSimple(Constants.XSD_FLOAT, java.lang.Float.class);
+        myRegisterSimple(Constants.XSD_INT, java.lang.Integer.class);
+        myRegisterSimple(Constants.XSD_INTEGER, java.math.BigInteger.class
+        );
+        myRegisterSimple(Constants.XSD_DECIMAL, java.math.BigDecimal.class
+        );
+        myRegisterSimple(Constants.XSD_LONG, java.lang.Long.class);
+        myRegisterSimple(Constants.XSD_SHORT, java.lang.Short.class);
+        myRegisterSimple(Constants.XSD_BYTE, java.lang.Byte.class);
+
+        // The XSD Primitives are mapped to java primitives.
+        myRegisterSimple(Constants.XSD_BOOLEAN, boolean.class);
+        myRegisterSimple(Constants.XSD_DOUBLE, double.class);
+        myRegisterSimple(Constants.XSD_FLOAT, float.class);
+        myRegisterSimple(Constants.XSD_INT, int.class);
+        myRegisterSimple(Constants.XSD_LONG, long.class);
+        myRegisterSimple(Constants.XSD_SHORT, short.class);
+        myRegisterSimple(Constants.XSD_BYTE, byte.class);
+    }
+
+    private void myRegisterSimple(QName xmlType, Class javaType) {
+        DeserializerFactory dser = new SimpleDeserializerFactory(javaType,
+                                                                 xmlType);
+        Serializer ser = new SimpleSerializer();
+        registerMapping(javaType, xmlType, ser, dser);
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCInOutMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCInOutMessageReceiver.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCInOutMessageReceiver.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCInOutMessageReceiver.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2004,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.axis2.rpc;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.databinding.DeserializationContext;
+import org.apache.axis2.databinding.Deserializer;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.axis2.soap.SOAPBody;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+
+import javax.xml.namespace.QName;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ *
+ */
+public class RPCInOutMessageReceiver extends AbstractInOutSyncMessageReceiver {
+    public static final String RPCMETHOD_PROPERTY = "rpc.method";
+
+    public RPCInOutMessageReceiver() {
+    }
+
+    public void invokeBusinessLogic(MessageContext inMessage,
+                                    MessageContext outMessage) throws AxisFault {
+        SOAPEnvelope env = inMessage.getEnvelope();
+        SOAPBody body = env.getBody();
+        OMElement rpcElement = body.getFirstElement();
+
+        /**
+         * Locate method descriptor using QName or action
+         */
+        OperationContext oc = inMessage.getOperationContext();
+        AxisOperation axisOperation = oc.getAxisOperation();
+        //soryy , I removed WSDL infor from AxisOperation
+//        RPCMethod method = (RPCMethod)axisOperation.getMetadataBag().get(RPCMETHOD_PROPERTY);
+        RPCMethod method = (RPCMethod) axisOperation.getParameter(RPCMETHOD_PROPERTY).getValue();
+        if (method == null) {
+            throw new AxisFault("Couldn't find RPCMethod in AxisOperation");
+        }
+
+        Method javaMethod = method.getJavaMethod();
+        Object [] arguments = null;
+        Object targetObject = this.getTheImplementationObject(inMessage);
+
+        DeserializationContext dserContext = new DeserializationContext();
+        RPCValues values = null;
+        try {
+            values = deserializeRPCElement(dserContext, method, rpcElement);
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+
+        arguments = new Object [method.getNumInParams()];
+        Iterator params = method.getInParams();
+        for (int i = 0; i < arguments.length; i++) {
+            RPCParameter param = (RPCParameter) params.next();
+            arguments[i] = param.getValue(values);
+        }
+
+        Object returnValue = null;
+        try {
+            returnValue = javaMethod.invoke(targetObject, arguments);
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+
+        RPCValues responseValues = new RPCValues();
+
+        // The response parameter, if any, is where the return value should go
+        RPCParameter responseParam = method.getResponseParameter();
+        if (responseParam != null) {
+            responseValues.setValue(responseParam.getQName(), returnValue);
+        }
+
+        // Now make the response message.
+        try {
+            SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+            SOAPEnvelope responseEnv = factory.createSOAPEnvelope();
+            SOAPBody respBody = factory.createSOAPBody(responseEnv);
+
+            // Just need to create this, since it automatically links itself
+            // to the response body and will therefore get serializeAndConsume()d at
+            // the appropriate time.
+            new RPCResponseElement(method, responseValues, respBody);
+
+            outMessage.setEnvelope(responseEnv);
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+    }
+
+    public RPCValues deserializeRPCElement(DeserializationContext dserContext,
+                                           RPCMethod method,
+                                           OMElement rpcElement)
+            throws Exception {
+        RPCValues values = new RPCValues();
+
+        // Run each argument (sub-element) through the appropriate deser
+        Iterator args = rpcElement.getChildElements();
+        Map elementCounts = new HashMap();
+        while (args.hasNext()) {
+            OMElement arg = (OMElement) args.next();
+            QName qname = arg.getQName();
+            RPCParameter param = method.getParameter(qname);
+            if (param == null) {
+                // unknown parameter.  Fault or continue depending on
+                // strictness configuration.
+                continue;
+            }
+            Integer count = (Integer) elementCounts.get(qname);
+            if (count == null) count = new Integer(0);
+            elementCounts.put(qname, new Integer(count.intValue() + 1));
+            Deserializer dser = param.getDeserializer(count.intValue(), values);
+            // Got a recognized param, so feed this through the deserializer
+            try {
+                dserContext.deserialize(arg.getXMLStreamReader(), dser);
+            } catch (Exception e) {
+                throw AxisFault.makeFault(e);
+            }
+        }
+
+        // OK, now we're done with the children.  If this is SOAP 1.2, we're
+        // finished.  If it's SOAP 1.1, there may be multirefs which still
+        // need to be deserialized after the RPC element.
+        if (dserContext.isIncomplete()) {
+            try {
+                dserContext.processRest(rpcElement);
+            } catch (Exception e) {
+                throw AxisFault.makeFault(e);
+            }
+
+            if (dserContext.isIncomplete()) {
+                throw new AxisFault("Unresolved multirefs!");
+            }
+        }
+
+        return values;
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCMethod.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCMethod.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCMethod.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCMethod.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2004,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.axis2.rpc;
+
+import javax.xml.namespace.QName;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * RPCMethod
+ */
+public class RPCMethod {
+    static class Outerator implements Iterator {
+        ArrayList params;
+        RPCParameter cache = null;
+        int badMode;
+        int idx = 0;
+
+        public Outerator(ArrayList params, int badMode) {
+            this.params = params;
+            this.badMode = badMode;
+        }
+
+        public void remove() {
+
+        }
+
+        public boolean hasNext() {
+            if (cache != null) return true;
+            while (idx < params.size()) {
+                RPCParameter param = (RPCParameter) params.get(idx);
+                idx++;
+                if (param.mode != badMode) {
+                    cache = param;
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        public Object next() {
+            RPCParameter ret = null;
+            if (hasNext()) {
+                ret = cache;
+                cache = null;
+            }
+            return ret;
+        }
+    }
+
+    int numInParams, numOutParams;
+    Map parameters = new HashMap();
+    ArrayList orderedParameters = new ArrayList();
+    Method javaMethod;
+
+    QName qname;
+    QName responseQName;
+
+    public RPCMethod(QName qname) {
+        this.qname = qname;
+    }
+
+    public ArrayList getParams() {
+        return orderedParameters;
+    }
+
+    public void addParameter(RPCParameter param) {
+        orderedParameters.add(param);
+        parameters.put(param.getQName(), param);
+        if (param.getMode() != RPCParameter.MODE_OUT) {
+            numInParams++;
+        }
+        if (param.getMode() != RPCParameter.MODE_IN) {
+            numOutParams++;
+        }
+    }
+
+    public RPCParameter getParameter(QName qname) {
+        return (RPCParameter) parameters.get(qname);
+    }
+
+    public Method getJavaMethod() {
+        return javaMethod;
+    }
+
+    public void setJavaMethod(Method javaMethod) {
+        this.javaMethod = javaMethod;
+    }
+
+    public QName getResponseQName() {
+        return responseQName;
+    }
+
+    public void setResponseQName(QName responseQName) {
+        this.responseQName = responseQName;
+    }
+
+    public QName getQName() {
+        return qname;
+    }
+
+    public RPCParameter getResponseParameter() {
+        for (Iterator i = orderedParameters.iterator(); i.hasNext();) {
+            RPCParameter parameter = (RPCParameter) i.next();
+            if (parameter.getMode() == RPCParameter.MODE_OUT)
+                return parameter;
+        }
+        return null;
+    }
+
+    public Iterator getOutParams() {
+        return new Outerator(orderedParameters, RPCParameter.MODE_IN);
+    }
+
+    public Iterator getInParams() {
+        return new Outerator(orderedParameters, RPCParameter.MODE_OUT);
+    }
+
+    public int getNumInParams() {
+        return numInParams;
+    }
+
+    public int getNumOutParams() {
+        return numOutParams;
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCParameter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCParameter.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCParameter.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCParameter.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2004,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.axis2.rpc;
+
+import org.apache.axis2.databinding.DeserializationTarget;
+import org.apache.axis2.databinding.Deserializer;
+import org.apache.axis2.databinding.SerializationContext;
+import org.apache.axis2.databinding.metadata.ElementDesc;
+import org.apache.axis2.databinding.utils.Converter;
+
+import javax.xml.namespace.QName;
+
+/**
+ * RPCParameter
+ */
+public class RPCParameter extends ElementDesc {
+    class ParamTarget implements DeserializationTarget {
+        QName paramName;
+        RPCValues values;
+
+        public ParamTarget(QName paramName, RPCValues values) {
+            this.paramName = paramName;
+            this.values = values;
+        }
+
+        public void setValue(Object value) throws Exception {
+            values.setValue(paramName, value);
+        }
+    }
+
+    class IndexedParamTarget extends ParamTarget {
+        int index;
+
+        public IndexedParamTarget(QName paramName,
+                                  RPCValues values,
+                                  int index) {
+            super(paramName, values);
+            this.index = index;
+        }
+
+        public void setValue(Object value) throws Exception {
+            values.setIndexedValue(paramName, index, value);
+        }
+    }
+
+    public static final int MODE_IN = 0;
+    public static final int MODE_OUT = 1;
+    public static final int MODE_INOUT = 2;
+
+    int mode;
+    Class destClass;
+
+    public Object getValue(RPCValues values) {
+        Object value = values.getValue(qname);
+
+        if (destClass != null)
+            return Converter.convert(value, destClass);
+
+        return value;
+    }
+
+    public int getMode() {
+        return mode;
+    }
+
+    public void setMode(int mode) {
+        this.mode = mode;
+    }
+
+    public Class getDestClass() {
+        return destClass;
+    }
+
+    public void setDestClass(Class destClass) {
+        this.destClass = destClass;
+    }
+
+    public void serialize(SerializationContext context, Object value)
+            throws Exception {
+        if (ser == null) {
+            // no serializer!
+            throw new Exception("No serializer in RPCParameter");
+        }
+        context.serializeElement(qname, value, ser);
+    }
+
+    public Deserializer getDeserializer(int i, RPCValues values) {
+        if (i > maxOccurs && maxOccurs > -1) {
+            // fail
+            throw new RuntimeException("Too many elements");
+        }
+
+        DeserializationTarget target;
+        if (maxOccurs == -1 || maxOccurs > 1) {
+            target = new IndexedParamTarget(qname, values, i);
+        } else {
+            target = new ParamTarget(qname, values);
+        }
+
+        Deserializer dser = deserializerFactory.getDeserializer();
+        dser.setTarget(target);
+        return dser;
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCRequestElement.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCRequestElement.java?rev=374072&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCRequestElement.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ADB-NotUsed/src/org/apache/axis2/rpc/RPCRequestElement.java Wed Feb  1 06:17:03 2006
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2004,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.axis2.rpc;
+
+import org.apache.axis2.databinding.SerializationContext;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.om.impl.llom.OMElementImpl;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.Iterator;
+
+/**
+ * RPCResponseElement
+ */
+public class RPCRequestElement extends OMElementImpl {
+    RPCMethod method;
+    RPCValues values;
+
+    public RPCRequestElement(RPCMethod method,
+                             RPCValues values,
+                             OMElement parent) {
+        super(method.getQName(), parent);
+        this.method = method;
+        this.values = values;
+    }
+
+    protected void serialize(OMOutputImpl omOutput, boolean cache)
+            throws XMLStreamException {
+        XMLStreamWriter writer = omOutput.getXmlStreamWriter();
+        SerializationContext context = new SerializationContext(writer);
+
+        // Write wrapper element
+        if (ns == null) {
+            writer.writeStartElement(localName);
+        } else {
+            writer.writeStartElement(localName, ns.getName(), ns.getPrefix());
+        }
+        Iterator inParams = method.getInParams();
+        while (inParams.hasNext()) {
+            RPCParameter parameter = (RPCParameter) inParams.next();
+            Object value = values.getValue(parameter.getQName());
+            try {
+                parameter.serialize(context, value);
+            } catch (Exception e) {
+                throw new XMLStreamException("Couldn't serialize RPCParameter",
+                        e);
+            }
+        }
+        writer.writeEndElement();
+
+        try {
+            context.finish();
+        } catch (Exception e) {
+            throw new XMLStreamException(e);
+        }
+    }
+}