cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r603333 [1/2] - in /incubator/cxf/trunk/rt/databinding/aegis/src: main/java/org/apache/cxf/aegis/type/basic/ main/java/org/apache/cxf/aegis/type/encoded/ test/java/org/apache/cxf/aegis/type/encoded/
Date Tue, 11 Dec 2007 19:01:36 GMT
Author: bimargulies
Date: Tue Dec 11 11:01:33 2007
New Revision: 603333

URL: http://svn.apache.org/viewvc?rev=603333&view=rev
Log:
Dain's first round of 'encoded' implementation.

Added:
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRef.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefType.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/TrailingBlocks.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/Address.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/PurchaseOrder.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref1.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref2.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref3.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct1.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct2.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct3.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct4.xml   (with props)
Modified:
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=603333&r1=603332&r2=603333&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java Tue Dec 11 11:01:33 2007
@@ -20,6 +20,7 @@
 
 import java.beans.PropertyDescriptor;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
@@ -27,7 +28,6 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
-
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.aegis.Context;
@@ -46,7 +46,7 @@
 
 /**
  * Serializes JavaBeans.
- * 
+ *
  * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
  * @author <a href="mailto:jack.xu.hong@gmail.com">Jack Hong</a>
  */
@@ -83,22 +83,23 @@
 
         try {
             Class clazz = getTypeClass();
-            Object object = null;
-            InterfaceInvocationHandler delegate = null;
-            boolean isProxy = false;
+            Object object;
+            // the target for properties; either the object or the proxy handler
+            Object target;
 
             if (isInterface) {
                 String impl = (String)context.get(clazz.getName() + ".implementation");
 
                 if (impl == null) {
-                    delegate = new InterfaceInvocationHandler();
+                    InvocationHandler handler = new InterfaceInvocationHandler();
                     object = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {clazz},
-                                                    delegate);
-                    isProxy = true;
+                                                    handler);
+                    target = handler;
                 } else {
                     try {
                         clazz = ClassLoaderUtils.loadClass(impl, getClass());
                         object = clazz.newInstance();
+                        target = object;
                     } catch (ClassNotFoundException e) {
                         throw new DatabindingException("Could not find implementation class " + impl
                                                        + " for class " + clazz.getName());
@@ -106,8 +107,10 @@
                 }
             } else if (isException) {
                 object = createFromFault(context);
+                target = object;
             } else {
                 object = clazz.newInstance();
+                target = object;
             }
 
             // Read attributes
@@ -119,11 +122,7 @@
 
                 if (type != null) {
                     Object writeObj = type.readObject(childReader, context);
-                    if (isProxy) {
-                        delegate.writeProperty(name.getLocalPart(), writeObj);
-                    } else {
-                        writeProperty(name, object, writeObj, clazz, inf);
-                    }
+                    writeProperty(name, target, writeObj, clazz, inf);
                 }
             }
 
@@ -132,39 +131,20 @@
                 MessageReader childReader = reader.getNextElementReader();
                 QName name = childReader.getName();
 
-                BeanType parent = getBeanTypeWithProperty(name);
-                Type defaultType = null;
-                if (parent != null) {
-                    info = parent.getTypeInfo();
-                    defaultType = info.getType(name);
-                }
+                // Find the BeanTypeInfo that contains a property for the element name
+                BeanTypeInfo propertyTypeInfo = getBeanTypeInfoWithProperty(name);
 
-                Type type = TypeUtil.getReadType(childReader.getXMLStreamReader(), context, defaultType);
-                
-                // If the xsi:type lookup didn't work or there was none, use the
-                // normal Type.
-                if (type == null) {
-                    parent = getBeanTypeWithProperty(name);
-                    if (parent != null) {
-                        inf = parent.getTypeInfo();
-                        type = inf.getType(name);
-                    } else {
-                        type = null;
-                    }
-                }
+                // Get the Type for the property
+                Type type = getElementType(name, propertyTypeInfo, childReader, context);
 
                 if (type != null) {
                     if (!childReader.isXsiNil()) {
                         Object writeObj = type.readObject(childReader, context);
 
-                        if (isProxy) {
-                            delegate.writeProperty(name.getLocalPart(), writeObj);
-                        } else {
-                            writeProperty(name, object, writeObj, clazz, inf);
-                        }
+                        writeProperty(name, target, writeObj, clazz, propertyTypeInfo);
                     } else {
-                        if (!inf.isNillable(name)) {
-                            throw new DatabindingException(name.getLocalPart() 
+                        if (!propertyTypeInfo.isNillable(name)) {
+                            throw new DatabindingException(name.getLocalPart()
                                                            + " is nil, but not nillable.");
 
                         }
@@ -188,6 +168,19 @@
             throw new DatabindingException("Could not create class: " + e.getMessage(), e);
         }
     }
+
+    protected Type getElementType(QName name,
+            BeanTypeInfo beanTypeInfo,
+            MessageReader reader,
+            Context context) {
+        
+        Type type = beanTypeInfo.getType(name);
+
+        // Type can be overriden with a xsi:type attribute
+        type = TypeUtil.getReadType(reader.getXMLStreamReader(), context, type);
+        return type;
+    }
+
     /**
      * If the class is an exception, this will try and instantiate it with
      * information from the XFireFault (if it exists).
@@ -198,7 +191,7 @@
         Class clazz = getTypeClass();
         Constructor ctr;
         Object o;
-        
+
         Fault fault = context.getFault();
 
         try {
@@ -220,12 +213,19 @@
 
         return o;
     }
-    
+
     /**
      * Write the specified property to a field.
      */
     protected void writeProperty(QName name, Object object, Object property, Class impl, BeanTypeInfo inf)
         throws DatabindingException {
+
+        if (object instanceof InterfaceInvocationHandler) {
+            InterfaceInvocationHandler delegate = (InterfaceInvocationHandler) object;
+            delegate.writeProperty(name.getLocalPart(), property);
+            return;
+        }
+
         try {
             PropertyDescriptor desc = inf.getPropertyDescriptorFromMappedName(name);
 
@@ -273,7 +273,7 @@
      *      org.apache.cxf.aegis.Context)
      */
     @Override
-    public void writeObject(Object object, MessageWriter writer, Context context) 
+    public void writeObject(Object object, MessageWriter writer, Context context)
         throws DatabindingException {
         if (object == null) {
             return;
@@ -281,7 +281,7 @@
 
         BeanTypeInfo inf = getTypeInfo();
 
-        if (object.getClass() == getTypeClass() 
+        if (object.getClass() == getTypeClass()
             && context.isWriteXsiTypes()) {
             writer.writeXsiType(getSchemaType());
         }
@@ -323,22 +323,17 @@
 
             Type defaultType = getType(inf, name);
             Type type = TypeUtil.getWriteType(context, value, defaultType);
-            MessageWriter cwriter;
 
             // Write the value if it is not null.
             if (value != null) {
-                cwriter = getWriter(writer, name, type);
-
                 if (type == null) {
                     throw new DatabindingException("Couldn't find type for " + value.getClass()
                                                    + " for property " + name);
                 }
 
-                type.writeObject(value, cwriter, context);
-
-                cwriter.close();
+                writeElement(name, value, type, writer, context);
             } else if (inf.isNillable(name)) {
-                cwriter = getWriter(writer, name, type);
+                MessageWriter cwriter = getWriter(writer, name, type);
 
                 // Write the xsi:nil if it is null.
                 cwriter.writeXsiNil();
@@ -354,6 +349,14 @@
         }
     }
 
+    protected void writeElement(QName name, Object value, Type type, MessageWriter writer, Context context) {
+        MessageWriter cwriter = getWriter(writer, name, type);
+
+        type.writeObject(value, cwriter, context);
+
+        cwriter.close();
+    }
+
     private MessageWriter getWriter(MessageWriter writer, QName name, Type type) {
         MessageWriter cwriter;
         if (type.isAbstract()) {
@@ -403,8 +406,8 @@
         }
 
         if (inf.isExtension() && sooperType != null) {
-            Element complexContent = new Element("complexContent", 
-                                                 SOAPConstants.XSD_PREFIX, 
+            Element complexContent = new Element("complexContent",
+                                                 SOAPConstants.XSD_PREFIX,
                                                  SOAPConstants.XSD);
             complex.addContent(complexContent);
             complex = complexContent;
@@ -561,7 +564,7 @@
 
     /**
      * We need to write a complex type schema for Beans, so return true.
-     * 
+     *
      * @see org.apache.cxf.aegis.type.Type#isComplex()
      */
     @Override
@@ -603,22 +606,29 @@
         return deps;
     }
 
-    private BeanType getBeanTypeWithProperty(QName name) {
-        BeanType sooper = this;
+    protected BeanTypeInfo getBeanTypeInfoWithProperty(QName name) {
+        // search the BeanType superType tree for the first BeanType with a property named 'name'
+        BeanType beanType = this;
         Type type = null;
-
-        while (type == null && sooper != null) {
-            type = sooper.getTypeInfo().getType(name);
+        while (type == null && beanType != null) {
+            type = beanType.getTypeInfo().getType(name);
 
             if (type == null) {
-                sooper = sooper.getSuperType();
+                beanType = beanType.getSuperType();
             }
         }
 
-        return sooper;
+        BeanTypeInfo elementTypeInfo;
+        if (beanType != null) {
+            elementTypeInfo = beanType.getTypeInfo();
+        } else {
+            // didn't find a bean type so just use this bean't type info
+            elementTypeInfo = getTypeInfo();
+        }
+        return elementTypeInfo;
     }
 
-    private BeanType getSuperType() {
+    public BeanType getSuperType() {
         BeanTypeInfo inf = getTypeInfo();
         Class c = inf.getTypeClass().getSuperclass();
         /*
@@ -647,7 +657,7 @@
         }
 
         info.initialize();
-        
+
         return info;
     }
 
@@ -662,7 +672,7 @@
     /**
      * Create an element to represent any future elements that might get added
      * to the schema <xsd:any minOccurs="0" maxOccurs="unbounded"/>
-     * 
+     *
      * @return
      */
     private Element createAnyElement() {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java?rev=603333&r1=603332&r2=603333&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java Tue Dec 11 11:01:33 2007
@@ -198,7 +198,7 @@
         }
     }
 
-    private Type determineType(Context context, Class clazz) {
+    public Type determineType(Context context, Class clazz) {
         TypeMapping tm = context.getTypeMapping();
         if (tm == null) {
             tm = getTypeMapping();

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java Tue Dec 11 11:01:33 2007
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.cxf.aegis.Context;
+
+/**
+ * MarshalRegistry maintains tracks which object instnces have been marshalled and which objects still need to
+ * be marshalled.
+ * <p/>
+ * Note: only the StructType register objects with this class.
+ */
+public class MarshalRegistry implements Iterable<Object> {
+    /**
+     * All objects instances with ids.  It is CRITICAL that is be an IdentityHashMap to assure we don't
+     * exclude instances that are equivilant but different instances.
+     */
+    private final Map<Object, String> instances = new IdentityHashMap<Object, String>();
+
+    /**
+     * The objects not yet marshalled.  The is maintained as a map for debugging purpuses. It is IMPORTANT
+     * that this be a LinkedHashMap so we write the objects in the order they were discovered in the object
+     * graphs (and writes them in numeric order).
+     */
+    private final Map<String, Object> notMarshalled = new LinkedHashMap<String, Object>();
+
+    /**
+     * The next id.
+     */
+    private int nextId;
+
+    /**
+     * Get the MarshalRegistry stored in the context, and if necessary create a new one.
+     *
+     * @param context the unmarshal context
+     * @return the SoapRefRegistry; never null
+     */
+    public static MarshalRegistry get(Context context) {
+        MarshalRegistry marshalRegistry = (MarshalRegistry) context.get(MarshalRegistry.class.getName());
+        if (marshalRegistry == null) {
+            marshalRegistry = new MarshalRegistry();
+            context.put(MarshalRegistry.class.getName(), marshalRegistry);
+        }
+        return marshalRegistry;
+    }
+
+
+    public String getInstanceId(Object instance) {
+        String id = instances.get(instance);
+        if (id == null) {
+            id = "" + nextId++;
+            instances.put(instance, id);
+            notMarshalled.put(id, instance);
+        }
+        return id;
+    }
+
+    /**
+     * Returns an iterator over the object instances that have not been marshalled yet.  As each instance in
+     * this iterator is written, it may contain references to additional objects that have not been written.
+     * Those references objects will be added to the end of this iterator, so the "list" that is being
+     * iterated over grows as the iteration preceeds.
+     * <p/>
+     * When an instance is returned from this iterator it is marked as marshalled.
+     *
+     * @return an iterator over the objects to be marshalled.
+     */
+    public Iterator<Object> iterator() {
+        return new Iterator<Object>() {
+            public boolean hasNext() {
+                return !notMarshalled.isEmpty();
+            }
+
+            public Object next() {
+                // remove the first entry in the notMarshalled map
+                Iterator<Object> iterator = notMarshalled.values().iterator();
+                Object instance = iterator.next();
+                iterator.remove();
+
+                // return the instance
+                return instance;
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        };
+    }
+}
\ No newline at end of file

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/MarshalRegistry.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java Tue Dec 11 11:01:33 2007
@@ -0,0 +1,122 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+import org.apache.cxf.binding.soap.Soap12;
+
+/**
+ * Utilitiy methods for SOAP reading and writing encoded mesages.
+ */
+public final class SoapEncodingUtil {
+    private static final String SOAP_ENCODING_NS = Soap12.getInstance().getSoapEncodingStyle();
+    private static final QName SOAP_ENCODING_ID_1_2 = new QName(SOAP_ENCODING_NS, "id");
+    private static final QName SOAP_ENCODING_ID_1_1 = new QName("id");
+    private static final QName SOAP_ENCODING_REF_1_2 = new QName(SOAP_ENCODING_NS, "ref");
+    private static final QName SOAP_ENCODING_REF_1_1 = new QName("href");
+
+    private SoapEncodingUtil() {
+    }
+
+    /**
+     * Reads the SOAP 1.2 or SOAP 1.1 id attribute.
+     *
+     * @param reader the stream to read; must not be null
+     * @return the id or null of neither attribute was present
+     */
+    public static String readId(MessageReader reader) {
+        if (reader == null) {
+            throw new NullPointerException("reader is null");
+        }
+        String id = readAttributeValue(reader, SOAP_ENCODING_ID_1_2);
+        if (id == null) {
+            id = readAttributeValue(reader, SOAP_ENCODING_ID_1_1);
+        }
+        return id;
+    }
+
+    /**
+     * Writes a SOAP 1.1 id attribute.
+     *
+     * @param writer the stream to which the id should be written; must not be null
+     * @param id the id to write; must not be null
+     */
+    public static void writeId(MessageWriter writer, String id) {
+        if (writer == null) {
+            throw new NullPointerException("writer is null");
+        }
+        if (id == null) {
+            throw new NullPointerException("id is null");
+        }
+        writeAttribute(writer, SOAP_ENCODING_ID_1_1, id);
+    }
+
+    /**
+     * Reads the SOAP 1.2 or SOAP 1.1 refernce attribute.
+     *
+     * @param reader the stream to read; must not be null
+     * @return the reference id or null of neither attribute was present
+     */
+    public static String readRef(MessageReader reader) {
+        if (reader == null) {
+            throw new NullPointerException("reader is null");
+        }
+        String ref = readAttributeValue(reader, SOAP_ENCODING_REF_1_2);
+        if (ref == null) {
+            ref = readAttributeValue(reader, SOAP_ENCODING_REF_1_1);
+        }
+        return ref;
+    }
+
+    /**
+     * Writes a SOAP 1.1 ref attribute.
+     *
+     * @param writer the stream to which the id should be written; must not be null
+     * @param refId the reference id to write; must not be null
+     */
+    public static void writeRef(MessageWriter writer, String refId) {
+        if (writer == null) {
+            throw new NullPointerException("writer is null");
+        }
+        if (refId == null) {
+            throw new NullPointerException("refId is null");
+        }
+        writeAttribute(writer, SOAP_ENCODING_REF_1_1, refId);
+    }
+
+    private static String readAttributeValue(MessageReader reader, QName name) {
+        MessageReader attributeReader = reader.getAttributeReader(name);
+        if (attributeReader != null) {
+            String id = attributeReader.getValue();
+            if (id != null) {
+                return id;
+            }
+        }
+        return null;
+    }
+
+    private static void writeAttribute(MessageWriter writer, QName name, String refId) {
+        MessageWriter attributeWriter = writer.getAttributeWriter(name);
+        attributeWriter.writeValue(refId);
+        attributeWriter.close();
+    }
+}

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRef.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRef.java?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRef.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRef.java Tue Dec 11 11:01:33 2007
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+/**
+ * SoapRef represents an encoded SOAP 1.1 href or SOAP 1.2 ref object. This data class is updated when the ref
+ * is resolved which can be immedately when the ref is resolved, or later when an instance with the referenced
+ * id is unmarshalled.
+ * <p/>
+ * When the reference is resolved, an optional Action will be invoked which is commonly used to update a
+ * property on the source object of the reference.
+ */
+public class SoapRef {
+    private Object instance;
+    private Action action;
+
+    /**
+     * Gets the referenced object instance or null if the reference has not been resolved yet;
+     *
+     * @return the referenced object instance or null
+     */
+    public Object get() {
+        return instance;
+    }
+
+    /**
+     * Sets the referenced object instance.  If an action is registered the onSet method is invoked.
+     *
+     * @param object the reference instance; not null
+     */
+    public void set(Object object) {
+        if (object == null) {
+            throw new NullPointerException("object is null");
+        }
+        this.instance = object;
+        if (action != null) {
+            action.onSet(this);
+        }
+    }
+
+    /**
+     * Registers an action to invoke when the instance is set.  If the instance, has already been set, the
+     * onSet method will immedately be invoked.
+     *
+     * @return the action to invoke when this refernce is resolved; not null
+     */
+    public void setAction(Action action) {
+        if (action == null) {
+            throw new NullPointerException("action is null");
+        }
+        this.action = action;
+        if (instance != null) {
+            action.onSet(this);
+        }
+    }
+
+    public static interface Action {
+        void onSet(SoapRef ref);
+    }
+}
\ No newline at end of file

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRef.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java Tue Dec 11 11:01:33 2007
@@ -0,0 +1,126 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+
+/**
+ * SoapRefRegistry handles resolving all SOAP encoded references.  After each object is unmarshalled if the
+ * xml contained a SOAP id attribute it is registered with that attribute.  As each object is unmarshalled if
+ * any nested elements have a SOAP ref attribute it, the references is registered.  If there is a object
+ * instance already registered with the referenced id, the SOAP reference is immedately set. Otherwise, the
+ * reference is set when an object instance is registered with the id.  This allows for the objects to occur
+ * in any order in the XML document.
+ * <p/>
+ * Note: only the StructType and TraillingBlocks register objects with this class.
+ */
+public class SoapRefRegistry {
+    /**
+     * The unmarshalled object instances by id.
+     */
+    private final SortedMap<String, Object> instances = new TreeMap<String, Object>();
+
+    /**
+     * The unresolved SOAP references by referenced id.
+     */
+    private final SortedMap<String, List<SoapRef>> unresolvedRefs = new TreeMap<String, List<SoapRef>>();
+
+    /**
+     * Get the SoapRefRegistry stored in the context, and if necessary create a new one.
+     *
+     * @param context the unmarshal context
+     * @return the SoapRefRegistry; never null
+     */
+    public static SoapRefRegistry get(Context context) {
+        SoapRefRegistry soapRefRegistry = (SoapRefRegistry) context.get(SoapRefRegistry.class.getName());
+        if (soapRefRegistry == null) {
+            soapRefRegistry = new SoapRefRegistry();
+            context.put(SoapRefRegistry.class.getName(), soapRefRegistry);
+        }
+        return soapRefRegistry;
+    }
+
+    /**
+     * Add an object instance to the registry.
+     *
+     * @param id the unique identifier of the instance
+     * @param instance the instance
+     * @throws DatabindingException if another object instance is already registered with the id
+     */
+    public void addInstance(String id, Object instance) {
+        Object oldInstance = instances.put(id, instance);
+        if (oldInstance != null) {
+            throw new DatabindingException("Id " + id + " is already registered to instance " + instance);
+        }
+        List<SoapRef> list = unresolvedRefs.remove(id);
+        if (list != null) {
+            for (SoapRef soapRef : list) {
+                soapRef.set(instance);
+            }
+        }
+    }
+
+    /**
+     * Adds a reference to the specified id.  If an object is already registered with the specified id, the
+     * SOAP reference will immedately be set.  Otherwise, the reference will be set when an object is
+     * registered with the specified id.
+     *
+     * @param id the id of the referenced object instance
+     * @param soapRef the reference to set
+     */
+    public void addRef(String id, SoapRef soapRef) {
+        Object value = instances.get(id);
+        if (value != null) {
+            soapRef.set(value);
+        } else {
+            List<SoapRef> list = unresolvedRefs.get(id);
+            if (list == null) {
+                list = new ArrayList<SoapRef>();
+                unresolvedRefs.put(id, list);
+            }
+            list.add(soapRef);
+        }
+    }
+
+    /**
+     * Gets the ids of the registered object instances.
+     *
+     * @return the ids of the registered object instances
+     */
+    public Set<String> getIds() {
+        return Collections.unmodifiableSet(instances.keySet());
+    }
+
+    /**
+     * Gets the unresolved SOAP references by referenced id.
+     *
+     * @return the unresolved SOAP references by referenced id
+     */
+    public SortedMap<String, List<SoapRef>> getUnresolvedRefs() {
+        return unresolvedRefs;
+    }
+}

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefRegistry.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefType.java?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefType.java Tue Dec 11 11:01:33 2007
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import java.util.Set;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+import org.jdom.Element;
+
+/**
+ * SoapRefType reads and writes SoapRef objects.
+ * <p/>
+ * When reading, this class checks for a SOAP ref attribute, and if present creates SoapRef and registers it
+ * with the SoapRefRegistry.  If the SOAP ref attribute is not present, this class delegates to the baseType
+ * specified in the constructor.  Regardless of the element containing SOAP ref or not, a SoapRef object is
+ * returned. In the case of an inline object the SoapRef will contain a null value.
+ * <p/>
+ * When writing, the class always writes an element containing a SOAP ref attribute.  The actual object
+ * instance is registered with the MarshalRegistry, and is written at the end of the message body by the
+ * TrailingBlocks class.
+ */
+public class SoapRefType extends Type {
+    private final Type baseType;
+
+    public SoapRefType(Type baseType) {
+        if (baseType == null) {
+            throw new NullPointerException("baseType is null");
+        }
+        this.baseType = baseType;
+    }
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        SoapRef soapRef = new SoapRef();
+
+        // if we have a ref, register our soap ref with context
+        String ref = SoapEncodingUtil.readRef(reader);
+        if (ref != null) {
+            SoapRefRegistry.get(context).addRef(ref, soapRef);
+            reader.readToEnd();
+            return soapRef;
+        }
+
+        Object object = baseType.readObject(reader, context);
+        soapRef.set(object);
+        return soapRef;
+    }
+
+    public void writeObject(Object object,
+            MessageWriter writer,
+            Context context) throws DatabindingException {
+
+        // write the ref id
+        String refId = MarshalRegistry.get(context).getInstanceId(object);
+        SoapEncodingUtil.writeRef(writer, refId);
+    }
+
+    public void writeSchema(Element root) {
+        baseType.writeSchema(root);
+    }
+
+    public TypeMapping getTypeMapping() {
+        return baseType.getTypeMapping();
+    }
+
+    public void setTypeMapping(TypeMapping typeMapping) {
+        baseType.setTypeMapping(typeMapping);
+    }
+
+    public Class getTypeClass() {
+        return baseType.getTypeClass();
+    }
+
+    public void setTypeClass(Class typeClass) {
+        baseType.setTypeClass(typeClass);
+    }
+
+    public boolean isComplex() {
+        return baseType.isComplex();
+    }
+
+    public boolean isAbstract() {
+        return baseType.isAbstract();
+    }
+
+    public void setAbstract(boolean ab) {
+        baseType.setAbstract(ab);
+    }
+
+    public boolean isNillable() {
+        return baseType.isNillable();
+    }
+
+    public void setNillable(boolean nillable) {
+        baseType.setNillable(nillable);
+    }
+
+    public Set<Type> getDependencies() {
+        return baseType.getDependencies();
+    }
+
+    public QName getSchemaType() {
+        return baseType.getSchemaType();
+    }
+
+    public void setSchemaType(QName name) {
+        baseType.setSchemaType(name);
+    }
+
+    public boolean isWriteOuter() {
+        return baseType.isWriteOuter();
+    }
+
+    public void setWriteOuter(boolean writeOuter) {
+        baseType.setWriteOuter(writeOuter);
+    }
+}

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java Tue Dec 11 11:01:33 2007
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.basic.BeanType;
+import org.apache.cxf.aegis.type.basic.BeanTypeInfo;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * StructType is a small extension of the BeanType which can properly read and write SOAP encoded structs. The
+ * modifications are:
+ * <ul>
+ * <li>Nested elements MUST be unqualified</li>
+ * <li>Nested elements MAY contain a SOAP ref attribute instead of an inline value</li>
+ * <li>Struct MAY contain a SOAP id attribute</li>
+ * </ul>
+ * </p>
+ * When writting, the class will always write the struct in the following connonical format:
+ * <ul>
+ * <li>Struct will contain a SOAP id</li>
+ * <li>Nested structs will be written as SOAP references (with SoapRefType)</li>
+ * </ul>
+ */
+public class StructType extends BeanType {
+    public StructType() {
+    }
+
+    public StructType(BeanTypeInfo info) {
+        super(info);
+    }
+
+    /**
+     * Gets the BeanTypeInfo using an unqualified name.
+     * @param name the unqualified name of the element
+     * @return the BeanTypeInfo containing a property with the specified unqualified name
+     */
+    @Override
+    protected BeanTypeInfo getBeanTypeInfoWithProperty(QName name) {
+        // nested elements use unqualified names
+        name = qualifyName(name);
+
+        return super.getBeanTypeInfoWithProperty(name);
+    }
+
+    /**
+     * Returns a SoapRefType wrapping the actual type.
+     */
+    @Override
+    protected Type getElementType(QName name,
+            BeanTypeInfo beanTypeInfo,
+            MessageReader reader,
+            Context context) {
+        
+        // nested elements use unqualified names
+        name = qualifyName(name);
+
+        Type type = super.getElementType(name, beanTypeInfo, reader, context);
+        if (type != null) {
+            type = new SoapRefType(type);
+        }
+        return type;
+    }
+
+    /**
+     * Adds special handeling for SoapRefs
+     */
+    @Override
+    protected void writeProperty(QName name,
+            Object object,
+            Object property,
+            Class impl,
+            BeanTypeInfo inf) throws DatabindingException {
+
+        // nested elements use unqualified names
+        name = qualifyName(name);
+
+        if (property instanceof SoapRef) {
+            SoapRef soapRef = (SoapRef) property;
+
+            // register an action with the ref that will set the bean property
+            // if the reference has already been resolved the action will be
+            // invoked immedately
+            soapRef.setAction(new WritePropertyAction(name, object, impl, inf));
+        } else {
+            // normal property
+            super.writeProperty(name, object, property, impl, inf);
+        }
+    }
+
+    /**
+     * Writes a nested element with an unqualified name.
+     */
+    @Override
+    protected void writeElement(QName name, Object value, Type type, MessageWriter writer, Context context) {
+        // Nested elements are unqualified
+        name = new QName("", name.getLocalPart());
+
+        MessageWriter cwriter = writer.getElementWriter(name);
+
+        // todo check if the property value is a simple Java type instead of looking or a BeanType
+        if (type instanceof BeanType) {
+            String refId = MarshalRegistry.get(context).getInstanceId(value);
+            SoapEncodingUtil.writeRef(cwriter, refId);
+        } else {
+            type.writeObject(value, cwriter, context);
+        }
+
+        cwriter.close();
+    }
+
+    /**
+     * Gets the qualified name of a nested element.  Soap encoded structs contain unqualified elements so
+     * the method searches for a property matching the local part of the unqualified name.
+     */
+    private QName qualifyName(QName name) {
+        // is the name already qualified, we're done
+        if (!"".equals(name.getNamespaceURI())) {
+            return name;
+        }
+
+        // find the matching property and get it's name
+        for (BeanType sooper = this; sooper != null; sooper = sooper.getSuperType()) {
+            QName qualifiedName = new QName(sooper.getTypeInfo().getDefaultNamespace(), name.getLocalPart());
+
+            if (sooper.getTypeInfo().getType(qualifiedName) != null) {
+                return qualifiedName;
+            }
+        }
+
+        return name;
+    }
+
+    /**
+     * When the SoapRef is resolved write the matching property on the target object.
+     */
+    private final class WritePropertyAction implements SoapRef.Action {
+        private final QName name;
+        private final Object targetObject;
+        private final Class targetClass;
+        private final BeanTypeInfo beanTypeInfo;
+
+        private WritePropertyAction(QName name,
+                Object targetObject,
+                Class targetClass,
+                BeanTypeInfo beanTypeInfo) {
+            this.name = name;
+            this.targetObject = targetObject;
+            this.targetClass = targetClass;
+            this.beanTypeInfo = beanTypeInfo;
+        }
+
+        public void onSet(SoapRef ref) {
+            writeProperty(name, targetObject, ref.get(), targetClass, beanTypeInfo);
+        }
+    }
+}

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/TrailingBlocks.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/TrailingBlocks.java?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/TrailingBlocks.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/TrailingBlocks.java Tue Dec 11 11:01:33 2007
@@ -0,0 +1,157 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.aegis.type.basic.ObjectType;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * TrailingBlocks reads and writes the extra objects referenced but not written in the main message parts.
+ * These objects are commonly refered to as serialization (SOAP spec) roots and trailing blocks (JaxRpc spec).
+ * This class uses ObjectType to perform the actual reading and writting, so each block will (and must)
+ * contain an xsi type element.
+ * <p/>
+ * Typically, all message parts are read or written using the SoapRefType and before closing the SOAP body
+ * element the trailing blocks are read or written using this class.
+ */
+public class TrailingBlocks {
+    /**
+     * The ObjectType used to read and write the trailing block instances.
+     */
+    private ObjectType objectType;
+
+    public TrailingBlocks() {
+        // we only work with mapped types
+        objectType = new ObjectType();
+        objectType.setReadToDocument(false);
+        objectType.setSerializedWhenUnknown(false);
+    }
+
+    public TrailingBlocks(TypeMapping typeMapping) {
+        this();
+        objectType.setTypeMapping(typeMapping);
+    }
+
+    public TrailingBlocks(ObjectType objectType) {
+        this.objectType = objectType;
+    }
+
+    /**
+     * Gets the ObjectType used to read and write the trailing block instances.
+     *
+     * @return the ObjectType used to read and write the trailing block instances.
+     */
+    public ObjectType getObjectType() {
+        return objectType;
+    }
+
+    /**
+     * Sets the ObjectType used to read and write the trailing block instances.
+     *
+     * @param objectType the ObjectType used to read and write the trailing block instances.
+     */
+    public void setObjectType(ObjectType objectType) {
+        this.objectType = objectType;
+    }
+
+    /**
+     * Reads all remailing elements in the reader and registers them with the SoapRefRegistry in the context.
+     *
+     * @param reader the stream to read
+     * @param context the unmarshal context
+     * @return a list containing the object instances read
+     * @throws DatabindingException if a trailing block element does not contain a soap id attribute
+     */
+    public List<Object> readBlocks(MessageReader reader, Context context) throws DatabindingException {
+        List<Object> blocks = new ArrayList<Object>();
+
+        // read extra serialization roots
+        while (reader.hasMoreElementReaders()) {
+            MessageReader creader = reader.getNextElementReader();
+
+            // read the instance id
+            String id = SoapEncodingUtil.readId(creader);
+            if (id == null) {
+                throw new DatabindingException(
+                        "Trailing block does not contain a SOAP id attribute " + creader.getName());
+            }
+
+            // read the instance
+            Object instance = objectType.readObject(creader, context);
+            blocks.add(instance);
+
+            // register the instance 
+            SoapRefRegistry.get(context).addInstance(id, instance);
+
+            // close the element reader
+            creader.readToEnd();
+        }
+        return blocks;
+    }
+
+    /**
+     * Writes all of the unmarshalled objects in the MarshalRegistry.
+     *
+     * @param writer the stream to write the objects
+     * @param context the marshal context
+     * @return a list containing the object instances written
+     */
+    public List<Object> writeBlocks(MessageWriter writer, Context context) {
+        List<Object> blocks = new ArrayList<Object>();
+
+        for (Object instance : MarshalRegistry.get(context)) {
+            // determine instance type
+            Type type = objectType.determineType(context, instance.getClass());
+            if (type == null) {
+                TypeMapping tm = context.getTypeMapping();
+                if (tm == null) {
+                    tm = objectType.getTypeMapping();
+                }
+
+                type = tm.getTypeCreator().createType(instance.getClass());
+                tm.register(type);
+            }
+
+            // create an new element for the instance
+            MessageWriter cwriter = writer.getElementWriter(type.getSchemaType());
+
+            // write the id attribute
+            String id = MarshalRegistry.get(context).getInstanceId(instance);
+            SoapEncodingUtil.writeId(cwriter, id);
+
+            // write the instance
+            objectType.writeObject(instance, cwriter, context);
+            blocks.add(instance);
+
+            // close the element
+            cwriter.close();
+        }
+
+        return blocks;
+    }
+
+}

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/TrailingBlocks.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/Address.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/Address.java?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/Address.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/Address.java Tue Dec 11 11:01:33 2007
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+public class Address {
+    private String street;
+    private String city;
+    private String state;
+    private String zip;
+
+    public String getStreet() {
+        return street;
+    }
+
+    public void setStreet(String street) {
+        this.street = street;
+    }
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getZip() {
+        return zip;
+    }
+
+    public void setZip(String zip) {
+        this.zip = zip;
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/Address.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/Address.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/PurchaseOrder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/PurchaseOrder.java?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/PurchaseOrder.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/PurchaseOrder.java Tue Dec 11 11:01:33 2007
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+public class PurchaseOrder {
+    private Address shipping;
+    private Address billing;
+
+    public Address getShipping() {
+        return shipping;
+    }
+
+    public void setShipping(Address shipping) {
+        this.shipping = shipping;
+    }
+
+    public Address getBilling() {
+        return billing;
+    }
+
+    public void setBilling(Address billing) {
+        this.billing = billing;
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/PurchaseOrder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/PurchaseOrder.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java Tue Dec 11 11:01:33 2007
@@ -0,0 +1,296 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.aegis.type.basic.BeanTypeInfo;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+import org.apache.cxf.aegis.xml.jdom.JDOMWriter;
+import org.apache.cxf.aegis.xml.stax.ElementReader;
+import org.apache.cxf.common.util.SOAPConstants;
+import org.apache.cxf.helpers.CastUtils;
+import org.jdom.Attribute;
+import org.jdom.Content;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.output.XMLOutputter;
+import org.junit.Test;
+
+public class StructTypeTest extends AbstractAegisTest {
+    private TypeMapping mapping;
+    private StructType addressType;
+    private StructType purchaseOrderType;
+    private TrailingBlocks trailingBlocks;
+
+    public void setUp() throws Exception {
+        super.setUp();
+
+        addNamespace("b", "urn:Bean");
+        addNamespace("a", "urn:anotherns");
+        addNamespace("xsi", SOAPConstants.XSI_NS);
+
+        DefaultTypeMappingRegistry reg = new DefaultTypeMappingRegistry(true);
+        mapping = reg.createTypeMapping(true);
+
+        // address type
+        BeanTypeInfo addressInfo = new BeanTypeInfo(Address.class, "urn:Bean");
+        addressInfo.setTypeMapping(mapping);
+
+        addressType = new StructType(addressInfo);
+        addressType.setTypeClass(Address.class);
+        addressType.setSchemaType(new QName("urn:Bean", "address"));
+        mapping.register(addressType);
+
+        // purchase order type
+        BeanTypeInfo poInfo = new BeanTypeInfo(PurchaseOrder.class, "urn:Bean");
+        poInfo.setTypeMapping(mapping);
+
+        purchaseOrderType = new StructType(poInfo);
+        purchaseOrderType.setTypeClass(PurchaseOrder.class);
+        purchaseOrderType.setTypeMapping(mapping);
+        purchaseOrderType.setSchemaType(new QName("urn:Bean", "po"));
+        mapping.register(purchaseOrderType);
+
+        // serialization root type
+        trailingBlocks = new TrailingBlocks();
+//        trailingBlocks.setTypeMapping(mapping);
+
+    }
+
+    @Test
+    public void testSimpleStruct() throws Exception {
+        // Test reading
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream("struct1.xml"));
+        Address address = (Address) addressType.readObject(reader, new Context());
+        validateAddress(address);
+        reader.getXMLStreamReader().close();
+
+        // Test reading - no namespace on nested elements
+        reader = new ElementReader(getClass().getResourceAsStream("struct2.xml"));
+        address = (Address) addressType.readObject(reader, new Context());
+        validateAddress(address);
+        reader.getXMLStreamReader().close();
+
+        // Test writing
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        addressType.writeObject(address, new JDOMWriter(element), new Context());
+        validateShippingAddress(element);
+    }
+
+    @Test
+    public void testComplexStruct() throws Exception {
+        // Test reading
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream("struct3.xml"));
+        PurchaseOrder po = (PurchaseOrder) purchaseOrderType.readObject(reader, new Context());
+        validatePurchaseOrder(po);
+        reader.getXMLStreamReader().close();
+
+        // Test reading - no namespace on nested elements
+        reader = new ElementReader(getClass().getResourceAsStream("struct4.xml"));
+        po = (PurchaseOrder) purchaseOrderType.readObject(reader, new Context());
+        validatePurchaseOrder(po);
+        reader.getXMLStreamReader().close();
+
+        // Test writing
+        Element element = writeRef(po);
+        validatePurchaseOrder(element);
+    }
+
+    @Test
+    public void testStructRef() throws Exception {
+        PurchaseOrder purchaseOrder;
+
+        // Simple nested ref
+        purchaseOrder = (PurchaseOrder) readRef("ref1.xml");
+        validatePurchaseOrder(purchaseOrder);
+
+        // Strings referenced
+        purchaseOrder = (PurchaseOrder) readRef("ref2.xml");
+        validatePurchaseOrder(purchaseOrder);
+
+        // completely unrolled
+        purchaseOrder = (PurchaseOrder) readRef("ref3.xml");
+        validatePurchaseOrder(purchaseOrder);
+
+        // Test writing
+        Element element = writeRef(purchaseOrder);
+
+        validatePurchaseOrder(element);
+    }
+
+    private Object readRef(String file) throws XMLStreamException {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+        ElementReader root = new ElementReader(getClass().getResourceAsStream(file));
+
+        // get Type based on the element qname
+        MessageReader reader = root.getNextElementReader();
+        Type type = this.mapping.getType(reader.getName());
+        assertNotNull("type is null", type);
+
+        // read ref
+        SoapRefType soapRefType = new SoapRefType(type);
+        SoapRef ref = (SoapRef) soapRefType.readObject(reader, context);
+        reader.readToEnd();
+
+        // read the trailing blocks (referenced objects)
+        List<Object> roots = trailingBlocks.readBlocks(root, context);
+        assertNotNull(roots);
+
+        // close the input stream
+        root.getXMLStreamReader().close();
+
+        // return the ref
+        return ref.get();
+    }
+
+    private Element writeRef(Object instance) {
+        // create the document
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        JDOMWriter rootWriter = new JDOMWriter(element);
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // get Type based on the object instance
+        Type type = this.mapping.getType(instance.getClass());
+        assertNotNull("type is null", type);
+
+        // write the ref
+        SoapRefType soapRefType = new SoapRefType(type);
+        MessageWriter cwriter = rootWriter.getElementWriter(soapRefType.getSchemaType());
+        soapRefType.writeObject(instance, cwriter, context);
+        cwriter.close();
+
+        // write the trailing blocks (referenced objects)
+        trailingBlocks.writeBlocks(rootWriter, context);
+        return element;
+    }
+
+    private void validateAddress(Address address) {
+        assertNotNull(address);
+        assertEquals("1234 Riverside Drive", address.getStreet());
+        assertEquals("Gainesville", address.getCity());
+        assertEquals("FL", address.getState());
+        assertEquals("30506", address.getZip());
+    }
+
+    private void validateShippingAddress(Element shipping) {
+        assertNotNull("shipping is null", shipping);
+        assertChildEquals("1234 Riverside Drive", shipping, "street");
+        assertChildEquals("Gainesville", shipping, "city");
+        assertChildEquals("FL", shipping, "state");
+        assertChildEquals("30506", shipping, "zip");
+    }
+
+    private void validateBillingAddress(Element billing) {
+        assertNotNull("billing is null", billing);
+        assertChildEquals("1234 Fake Street", billing, "street");
+        assertChildEquals("Las Vegas", billing, "city");
+        assertChildEquals("NV", billing, "state");
+        assertChildEquals("89102", billing, "zip");
+    }
+
+    private void validatePurchaseOrder(PurchaseOrder purchaseOrder) {
+        assertNotNull(purchaseOrder);
+        assertNotNull(purchaseOrder.getShipping());
+        assertEquals("1234 Riverside Drive", purchaseOrder.getShipping().getStreet());
+        assertEquals("Gainesville", purchaseOrder.getShipping().getCity());
+        assertEquals("FL", purchaseOrder.getShipping().getState());
+        assertEquals("30506", purchaseOrder.getShipping().getZip());
+        assertNotNull(purchaseOrder.getBilling());
+        assertEquals("1234 Fake Street", purchaseOrder.getBilling().getStreet());
+        assertEquals("Las Vegas", purchaseOrder.getBilling().getCity());
+        assertEquals("NV", purchaseOrder.getBilling().getState());
+        assertEquals("89102", purchaseOrder.getBilling().getZip());
+    }
+
+    private void validatePurchaseOrder(Element element) throws Exception {
+        Element poRefElement = null;
+        Map<String, Element> blocks = new TreeMap<String, Element>();
+        for (Content content : CastUtils.<Content>cast(element.getContent())) {
+            if (content instanceof Element) {
+                Element child = (Element) content;
+                if (poRefElement == null) {
+                    poRefElement = child;
+                } else {
+                    String id = getId("Trailing block ", child);
+                    blocks.put(id, child);
+                }
+            }
+        }
+
+        Element po = getReferencedElement("poRef", poRefElement, blocks);
+
+        Element shippingRef = po.getChild("shipping");
+        Element shipping = getReferencedElement("shipping", shippingRef, blocks);
+        validateShippingAddress(shipping);
+
+        Element billingRef = po.getChild("billing");
+        Element billing = getReferencedElement("billing", billingRef, blocks);
+        validateBillingAddress(billing);
+    }
+
+    private Element getReferencedElement(String childName,
+            Element element,
+            Map<String, Element> blocks) {
+        assertNotNull(childName + " is null", element);
+        assertNotNull("element is null", element);
+        String refId = getRef(childName, element);
+        Element refElement = blocks.get(refId);
+        assertNotNull(childName + " referenced non-existant element " + refId, refElement);
+        return refElement;
+    }
+
+    private void assertChildEquals(String expected, Element element, String childName) {
+        assertEquals(expected, element.getChild(childName).getText());
+    }
+
+    private String getId(String childName, Element child) {
+        assertNotNull(childName + " is null", child);
+        Attribute idAttribute = child.getAttribute("id");
+        XMLOutputter xmlOutputter = new XMLOutputter();
+        assertNotNull(childName + " id is null \n" + xmlOutputter.outputString(child), idAttribute);
+        String id = idAttribute.getValue();
+        assertNotNull(childName + " id is null \n" + xmlOutputter.outputString(child), id);
+        return id;
+    }
+
+    private String getRef(String childName, Element child) {
+        assertNotNull(childName + " is null", child);
+        Attribute hrefAttribute = child.getAttribute("href");
+        XMLOutputter xmlOutputter = new XMLOutputter();
+        assertNotNull(childName + " href is null \n" + xmlOutputter.outputString(child), hrefAttribute);
+        String href = hrefAttribute.getValue();
+        assertNotNull(childName + " href is null \n" + xmlOutputter.outputString(child), href);
+        return href;
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref1.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref1.xml?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref1.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref1.xml Tue Dec 11 11:01:33 2007
@@ -0,0 +1,37 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<root xmlns:b="urn:Bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <b:po>
+    <shipping href="#real"/>
+    <billing href="#fake"/>
+  </b:po>
+
+  <real id="#real" xsi:type="b:address">
+    <street>1234 Riverside Drive</street>
+    <city>Gainesville</city>
+    <state>FL</state>
+    <zip>30506</zip>
+  </real>
+  <fake id="#fake" xsi:type="b:address">
+    <street>1234 Fake Street</street>
+    <city>Las Vegas</city>
+    <state>NV</state>
+    <zip>89102</zip>
+  </fake>
+</root>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref1.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref2.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref2.xml?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref2.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref2.xml Tue Dec 11 11:01:33 2007
@@ -0,0 +1,51 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<root xmlns:b="urn:Bean"
+      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
+
+  <b:po>
+    <shipping href="#real"/>
+    <billing href="#fake"/>
+  </b:po>
+
+  <real id="#real" xsi:type="b:address">
+    <street href="#real-street"/>
+    <city href="#real-city"/>
+    <state href="#real-state"/>
+    <zip href="#real-zip"/>
+  </real>
+  <fake id="#fake" xsi:type="b:address">
+    <street href="#fake-street"/>
+    <city href="#fake-city"/>
+    <state href="#fake-state"/>
+    <zip href="#fake-zip"/>
+  </fake>
+
+  <soapenc:string xsi:type="xsd:string" id="#real-street">1234 Riverside Drive</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#real-city">Gainesville</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#real-state">FL</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#real-zip">30506</soapenc:string>
+
+  <soapenc:string xsi:type="xsd:string" id="#fake-street">1234 Fake Street</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#fake-city">Las Vegas</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#fake-state">NV</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#fake-zip">89102</soapenc:string>
+</root>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref2.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref3.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref3.xml?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref3.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref3.xml Tue Dec 11 11:01:33 2007
@@ -0,0 +1,53 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<root xmlns:b="urn:Bean"
+      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
+
+  <b:po href="#po"/>
+
+  <object id="#po" xsi:type="b:po">
+    <shipping href="#real"/>
+    <billing href="#fake"/>
+  </object>
+
+  <real id="#real" xsi:type="b:address">
+    <street href="#real-street"/>
+    <city href="#real-city"/>
+    <state href="#real-state"/>
+    <zip href="#real-zip"/>
+  </real>
+  <fake id="#fake" xsi:type="b:address">
+    <street href="#fake-street"/>
+    <city href="#fake-city"/>
+    <state href="#fake-state"/>
+    <zip href="#fake-zip"/>
+  </fake>
+
+  <soapenc:string xsi:type="xsd:string" id="#real-street">1234 Riverside Drive</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#real-city">Gainesville</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#real-state">FL</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#real-zip">30506</soapenc:string>
+
+  <soapenc:string xsi:type="xsd:string" id="#fake-street">1234 Fake Street</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#fake-city">Las Vegas</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#fake-state">NV</soapenc:string>
+  <soapenc:string xsi:type="xsd:string" id="#fake-zip">89102</soapenc:string>
+</root>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref3.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ref3.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct1.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct1.xml?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct1.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct1.xml Tue Dec 11 11:01:33 2007
@@ -0,0 +1,24 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<b:shipping xmlns:b="urn:Bean">
+    <b:street>1234 Riverside Drive</b:street>
+    <b:city>Gainesville</b:city>
+    <b:state>FL</b:state>
+    <b:zip>30506</b:zip>
+</b:shipping>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct1.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct2.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct2.xml?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct2.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct2.xml Tue Dec 11 11:01:33 2007
@@ -0,0 +1,24 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<b:shipping xmlns:b="urn:Bean">
+    <street>1234 Riverside Drive</street>
+    <city>Gainesville</city>
+    <state>FL</state>
+    <zip>30506</zip>
+</b:shipping>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct2.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct3.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct3.xml?rev=603333&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct3.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct3.xml Tue Dec 11 11:01:33 2007
@@ -0,0 +1,32 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<b:po xmlns:b="urn:Bean">
+  <b:shipping>
+      <b:street>1234 Riverside Drive</b:street>
+      <b:city>Gainesville</b:city>
+      <b:state>FL</b:state>
+      <b:zip>30506</b:zip>
+  </b:shipping>
+  <b:billing>
+      <b:street>1234 Fake Street</b:street>
+      <b:city>Las Vegas</b:city>
+      <b:state>NV</b:state>
+      <b:zip>89102</b:zip>
+  </b:billing>
+</b:po>
\ No newline at end of file



Mime
View raw message