cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r530639 [1/2] - in /incubator/cxf/trunk: bundle/ common/common/src/main/java/org/apache/cxf/common/util/ common/common/src/main/java/org/apache/cxf/staxutils/ distribution/src/main/release/ rt/databinding/aegis/src/main/java/org/apache/cxf/...
Date Fri, 20 Apr 2007 04:53:57 GMT
Author: dandiep
Date: Thu Apr 19 21:53:54 2007
New Revision: 530639

URL: http://svn.apache.org/viewvc?view=rev&rev=530639
Log:
o Port a bunch of fixes for Aegis from XFire.
o Commit CXF-530 patch for ws-security
o remove dependency on SAAJ 


Added:
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/EchoData.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/GetData.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/MyInterface.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/MyInterface2.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/bean1.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/bean2.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/bean3.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/bean4.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/bean5.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/bean6.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/bean7.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/bean8.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/bean9.xml   (with props)
Removed:
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Aegis.java
Modified:
    incubator/cxf/trunk/bundle/pom.xml
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Base64Utility.java
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
    incubator/cxf/trunk/distribution/src/main/release/BUILDING.txt
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Context.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreator.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
    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/BeanTypeInfo.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/DataBean.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/DataService.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/codehaus/xfire/aegis/inheritance/InheritancePOJOTest.java
    incubator/cxf/trunk/rt/ws/addr/pom.xml
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
    incubator/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
    incubator/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
    incubator/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptor.java
    incubator/cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractSecurityTest.java
    incubator/cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/RoundTripTest.java
    incubator/cxf/trunk/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java

Modified: incubator/cxf/trunk/bundle/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/bundle/pom.xml?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/bundle/pom.xml (original)
+++ incubator/cxf/trunk/bundle/pom.xml Thu Apr 19 21:53:54 2007
@@ -181,25 +181,32 @@
 			<version>${pom.version}</version>
 		    <optional>true</optional>
 		</dependency>
+		<dependency>
+			<groupId>${pom.groupId}</groupId>
+			<artifactId>cxf-rt-databinding-aegis</artifactId>
+			<version>${pom.version}</version>
+		    <optional>true</optional>
+		</dependency>
 
 		<dependency>
 			<groupId>${pom.groupId}</groupId>
-			<artifactId>cxf-rt-ws-addr</artifactId>
+			<artifactId>cxf-rt-frontend-jaxws</artifactId>
 			<version>${pom.version}</version>
 		    <optional>true</optional>
 		</dependency>
 		<dependency>
 			<groupId>${pom.groupId}</groupId>
-			<artifactId>cxf-rt-ws-rm</artifactId>
+			<artifactId>cxf-rt-frontend-js</artifactId>
 			<version>${pom.version}</version>
 		    <optional>true</optional>
 		</dependency>
 		<dependency>
 			<groupId>${pom.groupId}</groupId>
-			<artifactId>cxf-rt-ws-policy</artifactId>
+			<artifactId>cxf-rt-frontend-simple</artifactId>
 			<version>${pom.version}</version>
 		    <optional>true</optional>
 		</dependency>
+
 		<dependency>
             <groupId>${pom.groupId}</groupId>
             <artifactId>cxf-rt-ws-security</artifactId>
@@ -207,29 +214,24 @@
             <optional>true</optional>
 		</dependency>
 		<dependency>
-			<groupId>${pom.groupId}</groupId>
-			<artifactId>cxf-rt-frontend-jaxws</artifactId>
-			<version>${pom.version}</version>
-		    <optional>true</optional>
-		</dependency>
-		<dependency>
-			<groupId>${pom.groupId}</groupId>
-			<artifactId>cxf-rt-frontend-js</artifactId>
-			<version>${pom.version}</version>
-		    <optional>true</optional>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>cxf-rt-ws-policy</artifactId>
+            <version>${pom.version}</version>
+            <optional>true</optional>
 		</dependency>
 		<dependency>
-			<groupId>${pom.groupId}</groupId>
-			<artifactId>cxf-rt-frontend-simple</artifactId>
-			<version>${pom.version}</version>
-		    <optional>true</optional>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>cxf-rt-ws-addr</artifactId>
+            <version>${pom.version}</version>
+            <optional>true</optional>
 		</dependency>
 		<dependency>
-			<groupId>${pom.groupId}</groupId>
-			<artifactId>cxf-rt-databinding-aegis</artifactId>
-			<version>${pom.version}</version>
-		    <optional>true</optional>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>cxf-rt-ws-rm</artifactId>
+            <version>${pom.version}</version>
+            <optional>true</optional>
 		</dependency>
+		
     </dependencies>
 
 	<build>

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Base64Utility.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Base64Utility.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Base64Utility.java (original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Base64Utility.java Thu Apr 19 21:53:54 2007
@@ -219,7 +219,7 @@
                                      int o,
                                      int l) {
         if (l <= 0) {
-            return null;
+            return new char[0];
         }
 
         char[] out;

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java (original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java Thu Apr 19 21:53:54 2007
@@ -156,7 +156,9 @@
 
     @Override
     public String getElementText() throws XMLStreamException {
-        return DOMUtils.getContent(content);
+        String result = DOMUtils.getContent(content);
+        // we should not return null according to the StAx API javadoc
+        return result != null ? result : "";
     }
 
     @Override

Modified: incubator/cxf/trunk/distribution/src/main/release/BUILDING.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/BUILDING.txt?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/BUILDING.txt (original)
+++ incubator/cxf/trunk/distribution/src/main/release/BUILDING.txt Thu Apr 19 21:53:54 2007
@@ -11,7 +11,7 @@
    JDK location, and that your PATH includes %JAVA_HOME%\bin (windows) or 
    $JAVA_HOME$/bin (unix).
 
-3) Install Maven 2.0.4, which can be downloaded from 
+3) Install Maven 2.0.6, which can be downloaded from 
    http://maven.apache.org/download.html. Make sure that your PATH includes 
    the MVN_HOME/bin directory. 
 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Context.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Context.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Context.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/Context.java Thu Apr 19 21:53:54 2007
@@ -20,6 +20,7 @@
 
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 
 import org.apache.cxf.aegis.type.TypeMapping;
 import org.apache.cxf.message.Attachment;
@@ -34,6 +35,8 @@
     private TypeMapping typeMapping;
     private Collection<Attachment> attachments;
     private boolean writeXsiTypes;
+    private boolean readXsiTypes = true;
+    private List<String> overrideTypes;
     
     public Context() {
     }
@@ -61,4 +64,21 @@
     public void setWriteXsiTypes(boolean writeXsiTypes) {
         this.writeXsiTypes = writeXsiTypes;
     }
+
+    public boolean isReadXsiTypes() {
+        return readXsiTypes;
+    }
+
+    public void setReadXsiTypes(boolean readXsiTypes) {
+        this.readXsiTypes = readXsiTypes;
+    }
+
+    public List<String> getOverrideTypes() {
+        return overrideTypes;
+    }
+
+    public void setOverrideTypes(List<String> overrideTypes) {
+        this.overrideTypes = overrideTypes;
+    }
+    
 }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java Thu Apr 19 21:53:54 2007
@@ -33,12 +33,12 @@
 
 import org.w3c.dom.Node;
 
-import org.apache.cxf.aegis.Aegis;
 import org.apache.cxf.aegis.DatabindingException;
 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.TypeMappingRegistry;
+import org.apache.cxf.aegis.type.TypeUtil;
 import org.apache.cxf.aegis.type.basic.BeanType;
 import org.apache.cxf.aegis.util.XmlConstants;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
@@ -64,7 +64,19 @@
 import org.jdom.JDOMException;
 import org.jdom.output.DOMOutputter;
 
+/**
+ * Handles DataBidning functions for Aegis.
+ * <p>
+ * NOTE: There is an assumed 1:1 mapping between an AegisDatabidning and a Service!
+ */
 public class AegisDatabinding implements DataBinding {
+    
+    public static final String CURRENT_MESSAGE_PART = "currentMessagePart";
+    public static final String TYPE_MAPPING_KEY = "type.mapping";
+    public static final String ENCODING_URI_KEY = "type.encodingUri";
+    public static final String WRITE_XSI_TYPE_KEY = "writeXsiType";
+    public static final String OVERRIDE_TYPES_KEY = "overrideTypesList";
+    public static final String READ_XSI_TYPE_KEY = "readXsiType";
 
     protected static final int IN_PARAM = 0;
     protected static final int OUT_PARAM = 1;
@@ -73,6 +85,7 @@
     private TypeMappingRegistry typeMappingRegistry;
     private Map<MessagePartInfo, Type> part2Type;
     private List overrideTypes;
+    private Service service;
 
     public AegisDatabinding() {
         super();
@@ -114,26 +127,28 @@
         this.typeMappingRegistry = typeMappingRegistry;
     }
 
-    public void initialize(Service service) {
-        QName serviceName = service.getServiceInfos().get(0).getName();
+    public void initialize(Service s) {
+        this.service = s;
+        
+        QName serviceName = s.getServiceInfos().get(0).getName();
         TypeMapping serviceTM = typeMappingRegistry.createTypeMapping(XmlConstants.XSD, true);
         typeMappingRegistry.register(serviceName.getNamespaceURI(), serviceTM);
 
-        service.put(TypeMapping.class.getName(), serviceTM);
+        s.put(TypeMapping.class.getName(), serviceTM);
 
         Set<Type> deps = new HashSet<Type>();
 
-        for (ServiceInfo info : service.getServiceInfos()) {
+        for (ServiceInfo info : s.getServiceInfos()) {
             for (OperationInfo opInfo : info.getInterface().getOperations()) {
                 if (opInfo.isUnwrappedCapable()) {
-                    initializeOperation(service, serviceTM, opInfo.getUnwrappedOperation(), deps);
+                    initializeOperation(s, serviceTM, opInfo.getUnwrappedOperation(), deps);
                 } else {
-                    initializeOperation(service, serviceTM, opInfo, deps);
+                    initializeOperation(s, serviceTM, opInfo, deps);
                 }
             }
         }
 
-        List<Type> additional = getAdditionalTypes(service, serviceTM);
+        List<Type> additional = getAdditionalTypes(s, serviceTM);
 
         if (additional != null) {
             for (Type t : additional) {
@@ -143,11 +158,11 @@
             }
         }
 
-        createSchemas(service, deps);
+        createSchemas(s, deps);
     }
 
-    List<Type> getAdditionalTypes(Service service, TypeMapping tm) {
-        List classes = (List)service.get(Aegis.OVERRIDE_TYPES_KEY);
+    List<Type> getAdditionalTypes(Service s, TypeMapping tm) {
+        List classes = (List)s.get(OVERRIDE_TYPES_KEY);
 
         this.overrideTypes = classes;
 
@@ -157,7 +172,7 @@
                 String typeName = (String)it.next();
                 Class c;
                 try {
-                    c = ClassLoaderUtils.loadClass(typeName, Aegis.class);
+                    c = ClassLoaderUtils.loadClass(typeName, TypeUtil.class);
                 } catch (ClassNotFoundException e) {
                     throw new DatabindingException("Could not find override type class: " + typeName, e);
                 }
@@ -178,17 +193,17 @@
         return null;
     }
 
-    private void initializeOperation(Service service, TypeMapping serviceTM, OperationInfo opInfo,
+    private void initializeOperation(Service s, TypeMapping serviceTM, OperationInfo opInfo,
                                      Set<Type> deps) {
         try {
-            initializeMessage(service, serviceTM, opInfo.getInput(), IN_PARAM, deps);
+            initializeMessage(s, serviceTM, opInfo.getInput(), IN_PARAM, deps);
 
             if (opInfo.hasOutput()) {
-                initializeMessage(service, serviceTM, opInfo.getOutput(), OUT_PARAM, deps);
+                initializeMessage(s, serviceTM, opInfo.getOutput(), OUT_PARAM, deps);
             }
 
             for (FaultInfo info : opInfo.getFaults()) {
-                initializeMessage(service, serviceTM, info, FAULT_PARAM, deps);
+                initializeMessage(s, serviceTM, info, FAULT_PARAM, deps);
             }
 
         } catch (DatabindingException e) {
@@ -197,12 +212,12 @@
         }
     }
 
-    protected void initializeMessage(Service service, TypeMapping serviceTM,
+    protected void initializeMessage(Service s, TypeMapping serviceTM,
                                      AbstractMessageContainer container, int partType, Set<Type> deps) {
         for (Iterator itr = container.getMessageParts().iterator(); itr.hasNext();) {
             MessagePartInfo part = (MessagePartInfo)itr.next();
 
-            Type type = getParameterType(service, serviceTM, part, partType);
+            Type type = getParameterType(s, serviceTM, part, partType);
 
             if (type.isAbstract()) {
                 part.setTypeQName(type.getSchemaType());
@@ -226,7 +241,7 @@
         }
     }
 
-    private void createSchemas(Service service, Set<Type> deps) {
+    private void createSchemas(Service s, Set<Type> deps) {
         Map<String, Set<Type>> tns2Type = new HashMap<String, Set<Type>>();
         for (Type t : deps) {
             String ns = t.getSchemaType().getNamespaceURI();
@@ -263,7 +278,7 @@
 
                 org.w3c.dom.Document schema = new DOMOutputter().output(new Document(e));
 
-                for (ServiceInfo si : service.getServiceInfos()) {
+                for (ServiceInfo si : s.getServiceInfos()) {
                     SchemaInfo info = new SchemaInfo(si, entry.getKey());
 
                     info.setElement(schema.getDocumentElement());
@@ -282,8 +297,8 @@
 
     }
 
-    public QName getSuggestedName(Service service, TypeMapping tm, OperationInfo op, int param) {
-        Method m = getMethod(service, op);
+    public QName getSuggestedName(Service s, TypeMapping tm, OperationInfo op, int param) {
+        Method m = getMethod(s, op);
         if (m == null) {
             return null;
         }
@@ -303,7 +318,7 @@
         return name;
     }
 
-    private Type getParameterType(Service service, TypeMapping tm, MessagePartInfo param, int paramtype) {
+    private Type getParameterType(Service s, TypeMapping tm, MessagePartInfo param, int paramtype) {
         Type type = tm.getType(param.getTypeQName());
 
         /*
@@ -314,7 +329,7 @@
         if (type == null) {
             OperationInfo op = param.getMessageInfo().getOperation();
 
-            Method m = getMethod(service, op);
+            Method m = getMethod(s, op);
             if (paramtype != FAULT_PARAM && m != null) {
 
                 /*
@@ -336,8 +351,8 @@
         return type;
     }
 
-    private Method getMethod(Service service, OperationInfo op) {
-        MethodDispatcher md = (MethodDispatcher)service.get(MethodDispatcher.class.getName());
+    private Method getMethod(Service s, OperationInfo op) {
+        MethodDispatcher md = (MethodDispatcher)s.get(MethodDispatcher.class.getName());
         SimpleMethodDispatcher smd = (SimpleMethodDispatcher)md;
         return smd.getPrimaryMethod(op);
     }
@@ -349,4 +364,9 @@
     public List getOverrideTypes() {
         return overrideTypes;
     }
+
+    public Service getService() {
+        return service;
+    }
+    
 }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java Thu Apr 19 21:53:54 2007
@@ -25,13 +25,14 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.validation.Schema;
 
-import org.apache.cxf.aegis.Aegis;
 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.TypeUtil;
 import org.apache.cxf.aegis.xml.stax.ElementReader;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
@@ -51,7 +52,7 @@
     public Object read(MessagePartInfo part, XMLStreamReader input) {
         Type type = databinding.getType(part);
 
-        type = Aegis.getReadType(input, context, type);
+        type = TypeUtil.getReadType(input, context, type);
         
         if (type == null) {
             throw new Fault(new Message("NO_MESSAGE_FOR_PART", LOG));
@@ -59,7 +60,12 @@
 
          // I don't think this is the right type mapping
         context.setTypeMapping(type.getTypeMapping());
-
+        context.setOverrideTypes(CastUtils.cast(databinding.getOverrideTypes(), String.class));
+        Object val = databinding.getService().get(AegisDatabinding.READ_XSI_TYPE_KEY);
+        if ("false".equals(val) || Boolean.FALSE.equals(val)) {
+            context.setReadXsiTypes(false);
+        }
+        
         ElementReader elReader = new ElementReader(input);
         if (elReader.isXsiNil()) {
             elReader.readToEnd();

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java Thu Apr 19 21:53:54 2007
@@ -24,14 +24,15 @@
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.validation.Schema;
 
-import org.apache.cxf.aegis.Aegis;
 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.TypeUtil;
 import org.apache.cxf.aegis.xml.MessageWriter;
 import org.apache.cxf.aegis.xml.stax.ElementWriter;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
@@ -67,15 +68,19 @@
         Context context = new Context();
         // I'm not sure that this is the right type mapping
         context.setTypeMapping(type.getTypeMapping());
-        context.put(Aegis.OVERRIDE_TYPES_KEY, 
-                    databinding.getOverrideTypes());
+        context.setOverrideTypes(CastUtils.cast(databinding.getOverrideTypes(), String.class));
         context.setAttachments(attachments);
-        type = Aegis.getWriteType(context, obj, type);
+        Object val = databinding.getService().get(AegisDatabinding.WRITE_XSI_TYPE_KEY);
+        if ("true".equals(val) || Boolean.TRUE.equals(val)) {
+            context.setWriteXsiTypes(true);
+        }
+        
+        type = TypeUtil.getWriteType(context, obj, type);
         
         try {
             ElementWriter writer = new ElementWriter(output);
             MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
-            if (type.isNillable() && obj == null) {
+            if (type.isNillable() && type.isWriteOuter() && obj == null) {
                 w2.writeXsiNil();
                 return;
             }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java Thu Apr 19 21:53:54 2007
@@ -45,10 +45,30 @@
 
     private Configuration typeConfiguration;
 
+    private TypeCreator parent;
+
     public TypeMapping getTypeMapping() {
         return tm;
     }
 
+    public TypeCreator getTopCreator() {
+        TypeCreator top = this;
+        TypeCreator next = top;
+        while (next != null) {
+            top = next;
+            next = top.getParent();
+        }
+        return top;
+    }
+
+    public TypeCreator getParent() {
+        return parent;
+    }
+
+    public void setParent(TypeCreator parent) {
+        this.parent = parent;
+    }
+
     public void setTypeMapping(TypeMapping typeMapping) {
         this.tm = typeMapping;
 
@@ -59,15 +79,16 @@
 
     public void setNextCreator(AbstractTypeCreator creator) {
         this.nextCreator = creator;
+        nextCreator.parent = this;
     }
 
-    protected TypeClassInfo createClassInfo(Field f) {
+    public TypeClassInfo createClassInfo(Field f) {
         TypeClassInfo info = createBasicClassInfo(f.getType());
         info.setDescription("field " + f.getName() + " in  " + f.getDeclaringClass());
         return info;
     }
 
-    protected TypeClassInfo createBasicClassInfo(Class typeClass) {
+    public TypeClassInfo createBasicClassInfo(Class typeClass) {
         TypeClassInfo info = new TypeClassInfo();
         info.setDescription("class '" + typeClass.getName() + '\'');
         info.setTypeClass(typeClass);

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreator.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreator.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreator.java Thu Apr 19 21:53:54 2007
@@ -45,5 +45,9 @@
 
     Type createType(Class clazz);
 
+    TypeCreator getParent();
+    
+    void setParent(TypeCreator creator);
+        
     void setTypeMapping(TypeMapping typeMapping);
 }

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java?view=auto&rev=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java Thu Apr 19 21:53:54 2007
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type;
+
+import java.util.List;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.util.NamespaceHelper;
+import org.apache.cxf.aegis.util.XmlConstants;
+
+/**
+ * Static methods/constants for Aegis.
+ * 
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public final class TypeUtil {
+    public static final Log LOG = LogFactory.getLog(TypeUtil.class);
+
+    private TypeUtil() {
+        //utility class
+    }
+    
+    public static Type getReadType(XMLStreamReader xsr, Context context, Type type) {
+        if (!context.isReadXsiTypes()) {
+            return type;
+        }
+    
+        String overrideType = xsr.getAttributeValue(XmlConstants.XSI_NS, "type");
+        if (overrideType != null) {
+            QName overrideTypeName = NamespaceHelper.createQName(xsr.getNamespaceContext(), overrideType);
+            if (!overrideTypeName.equals(type.getSchemaType())) {
+                Type type2 = type.getTypeMapping().getType(overrideTypeName);
+                if (type2 == null) {
+                    LOG.info("xsi:type=\"" + overrideTypeName
+                             + "\" was specified, but no corresponding Type was registered; defaulting to "
+                             + type.getSchemaType());
+                } else {
+                    type = type2;
+                }
+            }
+        }
+        return type;
+    }
+
+    public static Type getWriteType(Context context, Object value, Type type) {
+        if (value != null && type != null && type.getTypeClass() != value.getClass()) {
+            List<String> l = context.getOverrideTypes();
+            if (l != null && l.contains(value.getClass().getName())) {
+                type = type.getTypeMapping().getType(value.getClass());
+            }
+        }
+        return type;
+    }
+
+}

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java Thu Apr 19 21:53:54 2007
@@ -28,10 +28,10 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.cxf.aegis.Aegis;
 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.TypeUtil;
 import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.apache.cxf.aegis.util.XmlConstants;
 import org.apache.cxf.aegis.xml.MessageReader;
@@ -75,7 +75,7 @@
 
         while (reader.hasMoreElementReaders()) {
             MessageReader creader = reader.getNextElementReader();
-            Type compType = Aegis.getReadType(creader.getXMLStreamReader(), context,
+            Type compType = TypeUtil.getReadType(creader.getXMLStreamReader(), context,
                                                              getComponentType());
 
             if (creader.isXsiNil()) {
@@ -238,9 +238,14 @@
 
     protected void writeValue(Object value, MessageWriter writer, Context context, Type type, String name,
                               String ns) throws DatabindingException {
-        type = Aegis.getWriteType(context, value, type);
-        MessageWriter cwriter = writer.getElementWriter(name, ns);
-
+        type = TypeUtil.getWriteType(context, value, type);
+        MessageWriter cwriter;
+        if (type.isWriteOuter()) {
+            cwriter = writer.getElementWriter(name, ns);
+        } else {
+            cwriter = writer;
+        }
+        
         if (value == null && type.isNillable()) {
             cwriter.writeXsiNil();
         } else {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java Thu Apr 19 21:53:54 2007
@@ -69,6 +69,7 @@
             }
 
             if (reader.isEndElement()) {
+                reader.next();
                 return new byte[0];
             }
 

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?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- 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 Thu Apr 19 21:53:54 2007
@@ -27,13 +27,12 @@
 import java.util.Set;
 
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
 
-import org.apache.cxf.aegis.Aegis;
 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.TypeUtil;
 import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.apache.cxf.aegis.util.XmlConstants;
 import org.apache.cxf.aegis.xml.MessageReader;
@@ -65,16 +64,6 @@
         this.isInterface = typeClass.isInterface();
     }
 
-    private QName getXsiType(MessageReader reader) {
-        XMLStreamReader xsr = reader.getXMLStreamReader();
-        String value = xsr.getAttributeValue(XmlConstants.XSI_NS, "type");
-        if (value == null) {
-            return null;
-        } else {
-            return NamespaceHelper.createQName(xsr.getNamespaceContext(), value);
-        }
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -108,9 +97,9 @@
                                                        + " for class " + clazz.getName());
                     }
                 }
-            //} else if (isException) {
-            // object = createFromFault(context);
-            // }
+                // } else if (isException) {
+                // object = createFromFault(context);
+                // }
             } else {
                 object = clazz.newInstance();
             }
@@ -136,16 +125,18 @@
             while (reader.hasMoreElementReaders()) {
                 MessageReader childReader = reader.getNextElementReader();
                 QName name = childReader.getName();
-                QName qn = getXsiType(childReader);
-
-                BeanType parent;
-                Type type = null;
 
-                // If an xsi:type has been specified, try to look it up
-                if (qn != null) {
-                    type = getTypeMapping().getType(qn);
+                BeanType parent = getBeanTypeWithProperty(name);
+                Type defaultType = null;
+                if (parent != null) {
+                    info = parent.getTypeInfo();
+                    defaultType = info.getType(name);
+                } else {
+                    defaultType = null;
                 }
 
+                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) {
@@ -169,7 +160,7 @@
                         }
                     } else {
                         if (!inf.isNillable(name)) {
-                            throw new DatabindingException(name.getLocalPart()
+                            throw new DatabindingException(name.getLocalPart() 
                                                            + " is nil, but not nillable.");
 
                         }
@@ -195,8 +186,7 @@
     /**
      * Write the specified property to a field.
      */
-    protected void writeProperty(QName name, Object object,
-                                 Object property, Class impl, BeanTypeInfo inf)
+    protected void writeProperty(QName name, Object object, Object property, Class impl, BeanTypeInfo inf)
         throws DatabindingException {
         try {
             PropertyDescriptor desc = inf.getPropertyDescriptorFromMappedName(name);
@@ -245,8 +235,8 @@
      *      org.apache.cxf.aegis.Context)
      */
     @Override
-    public void writeObject(Object object, MessageWriter writer,
-                            Context context) throws DatabindingException {
+    public void writeObject(Object object, MessageWriter writer, Context context) 
+        throws DatabindingException {
         if (object == null) {
             return;
         }
@@ -293,7 +283,7 @@
             Object value = readProperty(object, name);
 
             Type type = getType(inf, name);
-            type = Aegis.getWriteType(context, value, type);
+            type = TypeUtil.getWriteType(context, value, type);
             MessageWriter cwriter;
 
             // Write the value if it is not null.
@@ -364,12 +354,6 @@
 
         Type sooperType = getSuperType();
 
-        if (inf.isExtension() && sooperType != null) {
-            Element complexContent = new Element("complexContent", XmlConstants.XSD_PREFIX, XmlConstants.XSD);
-            complex.addContent(complexContent);
-            complex = complexContent;
-        }
-
         /*
          * See Java Virtual Machine specification:
          * http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#75734
@@ -379,6 +363,12 @@
             complex.setAttribute(new Attribute("abstract", "true"));
         }
 
+        if (inf.isExtension() && sooperType != null) {
+            Element complexContent = new Element("complexContent", XmlConstants.XSD_PREFIX, XmlConstants.XSD);
+            complex.addContent(complexContent);
+            complex = complexContent;
+        }
+
         /*
          * Decide if we're going to extend another type. If we are going to
          * defer, then make sure that we extend the type for our superclass.
@@ -455,8 +445,7 @@
             String nameNS = name.getNamespaceURI();
             String nameWithPrefix = getNameWithPrefix(root, nameNS, name.getLocalPart());
 
-            String prefix = NamespaceHelper.getUniquePrefix(root, type.getSchemaType()
-                .getNamespaceURI());
+            String prefix = NamespaceHelper.getUniquePrefix(root, type.getSchemaType().getNamespaceURI());
             element.setAttribute(new Attribute("name", nameWithPrefix));
             element.setAttribute(new Attribute("type", prefix + ':' + type.getSchemaType().getLocalPart()));
         }
@@ -617,12 +606,8 @@
             info = createTypeInfo();
         }
 
-        // Delay initialization so things work in recursive scenarios
-        // (XFIRE-117)
-        if (!info.isInitialized()) {
-            info.initialize();
-        }
-
+        info.initialize();
+        
         return info;
     }
 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java Thu Apr 19 21:53:54 2007
@@ -54,7 +54,7 @@
 
     private TypeMapping typeMapping;
 
-    private boolean initialized;
+    private volatile boolean initialized;
 
     private String defaultNamespace;
 
@@ -94,7 +94,7 @@
         this.defaultNamespace = defaultNamespace;
 
         initializeProperties();
-        setInitialized(!initialize);
+        initialized = !initialize;
     }
 
     public String getDefaultNamespace() {
@@ -103,11 +103,8 @@
 
     public void initialize() {
         try {
-            for (int i = 0; i < descriptors.length; i++) {
-                // Don't map the property unless there is a read property
-                if (isMapped(descriptors[i])) {
-                    mapProperty(descriptors[i]);
-                }
+            if (!initialized) {
+                initializeSync();
             }
         } catch (Exception e) {
             if (e instanceof DatabindingException) {
@@ -115,8 +112,18 @@
             }
             throw new DatabindingException("Couldn't create TypeInfo.", e);
         }
+    }
 
-        setInitialized(true);
+    private synchronized void initializeSync() {
+        if (!initialized) {
+            for (int i = 0; i < descriptors.length; i++) {
+                // Don't map the property unless there is a read property
+                if (isMapped(descriptors[i])) {
+                    mapProperty(descriptors[i]);
+                }
+            }
+            initialized = true;
+        }
     }
 
     public boolean isMapped(PropertyDescriptor pd) {
@@ -125,14 +132,6 @@
         }
 
         return true;
-    }
-
-    public boolean isInitialized() {
-        return initialized;
-    }
-
-    private void setInitialized(boolean initialized) {
-        this.initialized = initialized;
     }
 
     protected void mapProperty(PropertyDescriptor pd) {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java Thu Apr 19 21:53:54 2007
@@ -103,8 +103,26 @@
         } else {
             throw new IllegalAccessError(methodName + " is not a valid getter method.");
         }
-
-        return readProperty(attrName);
+        
+        Object prop = readProperty(attrName);
+        if (prop == null && method.getReturnType().isPrimitive()) {
+            if (method.getReturnType() == int.class) {
+                prop = new Integer(0);
+            } else if (method.getReturnType() == boolean.class) {
+                prop = Boolean.FALSE;
+            } else if (method.getReturnType() == long.class) {
+                prop = new Long(0);
+            } else if (method.getReturnType() == double.class) {
+                prop = new Double(0);
+            } else if (method.getReturnType() == short.class) {
+                prop = new Short((short)0);
+            } else if (method.getReturnType() == byte.class) {
+                prop = new Byte((byte)0);
+            } else if (method.getReturnType() == char.class) {
+                prop = new Character((char)0);
+            }
+        }
+        return prop;
     }
 
     protected Object doSetter(Method method, Object[] args) throws Throwable {

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?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- 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 Thu Apr 19 21:53:54 2007
@@ -19,10 +19,7 @@
 package org.apache.cxf.aegis.type.basic;
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
 import java.util.Collections;
 import java.util.Set;
 
@@ -30,7 +27,6 @@
 
 import org.w3c.dom.Document;
 
-import org.apache.cxf.aegis.Aegis;
 import org.apache.cxf.aegis.Context;
 import org.apache.cxf.aegis.DatabindingException;
 import org.apache.cxf.aegis.type.Type;
@@ -111,7 +107,7 @@
             typeQName = reader.getName();
         }
 
-        TypeMapping tm = (TypeMapping)context.get(Aegis.TYPE_MAPPING_KEY);
+        TypeMapping tm = context.getTypeMapping();
         if (tm == null) {
             tm = getTypeMapping();
         }
@@ -164,9 +160,8 @@
     }
 
     @Override
-    public void writeObject(Object object,
-                            MessageWriter writer,
-                            Context context) throws DatabindingException {
+    public void writeObject(Object object, MessageWriter writer, Context context) 
+        throws DatabindingException {
         if (null == object) {
             MessageWriter nilWriter = writer.getAttributeWriter(XSI_NIL);
 
@@ -177,18 +172,24 @@
             Type type = determineType(context, object.getClass());
 
             if (null == type) {
-                handleNullType(object, writer);
-            } else {
-                String prefix = writer.getPrefixForNamespace(type.getSchemaType().getNamespaceURI());
-
-                if (null == prefix || prefix.length() == 0) {
-                    addXsiType(writer, type.getSchemaType().getLocalPart());
-                } else {
-                    addXsiType(writer, prefix + ":" + type.getSchemaType().getLocalPart());
+                TypeMapping tm = context.getTypeMapping();
+                if (tm == null) {
+                    tm = getTypeMapping();
                 }
 
-                type.writeObject(object, writer, context);
+                type = tm.getTypeCreator().createType(object.getClass());
+                tm.register(type);
             }
+
+            String prefix = writer.getPrefixForNamespace(type.getSchemaType().getNamespaceURI());
+
+            if (null == prefix || prefix.length() == 0) {
+                addXsiType(writer, type.getSchemaType().getLocalPart());
+            } else {
+                addXsiType(writer, prefix + ":" + type.getSchemaType().getLocalPart());
+            }
+
+            type.writeObject(object, writer, context);
         }
     }
 
@@ -230,32 +231,6 @@
         typeWriter.writeValue(prefixedType);
 
         typeWriter.close();
-    }
-
-    private void handleNullType(Object object, MessageWriter writer) throws DatabindingException {
-        if (!serializedWhenUnknown) {
-            throw new DatabindingException("Unable to write '" + object + "' [" + object.getClass().getName()
-                                           + "]. Type is unknown.");
-        }
-
-        addXsiType(writer, "serializedJavaObject"); // TODO not sure what
-                                                    // namespace to put
-                                                    // here..should match what
-                                                    // is put in writeSchema
-
-        ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
-
-        try {
-            ObjectOutputStream objectOutputStream = new ObjectOutputStream(out);
-
-            objectOutputStream.writeObject(object);
-            objectOutputStream.close();
-        } catch (IOException e) {
-            throw new DatabindingException("Unable to serialize '" + object + "' ["
-                                           + object.getClass().getName() + "]", e);
-        }
-
-        writer.writeValue(Base64Utility.encode(out.toByteArray()));
     }
 
     public boolean isReadToDocument() {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java Thu Apr 19 21:53:54 2007
@@ -27,10 +27,10 @@
 
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.aegis.Aegis;
 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.TypeUtil;
 import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.apache.cxf.aegis.util.XmlConstants;
 import org.apache.cxf.aegis.xml.MessageReader;
@@ -158,8 +158,8 @@
     private void writeEntry(MessageWriter writer, Context context,
                             Type kType, Type vType,
                             Map.Entry entry) throws DatabindingException {
-        kType = Aegis.getWriteType(context, entry.getKey(), kType);
-        vType = Aegis.getWriteType(context, entry.getValue(), vType);
+        kType = TypeUtil.getWriteType(context, entry.getKey(), kType);
+        vType = TypeUtil.getWriteType(context, entry.getValue(), vType);
 
         MessageWriter entryWriter = writer.getElementWriter(getEntryName());
 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java Thu Apr 19 21:53:54 2007
@@ -23,6 +23,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.WildcardType;
+import java.util.Collection;
 
 import javax.xml.namespace.QName;
 
@@ -150,9 +151,15 @@
     protected Type getOrCreateParameterizedType(Object generic, int index) {
         Class clazz = getComponentType(generic, index);
 
+        if (!Collection.class.isAssignableFrom(clazz)) {
+            return getTopCreator().createType(clazz);
+        }
+        
+        Object component = getGenericComponent(generic, index);
+        
         TypeClassInfo info = createBasicClassInfo(clazz);
         info.setDescription(clazz.toString());
-        info.setGenericType(getGenericComponent(generic, index));
+        info.setGenericType(component);
 
         Type type = createTypeForClass(info);
 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java Thu Apr 19 21:53:54 2007
@@ -131,8 +131,14 @@
             } catch (XMLStreamException e) {
                 throw new DatabindingException("Could not read XML stream.", e);
             }
+            
+            if (value == null) {
+                value = "";
+            } else {
+                value = value.trim();
+            }
         }
-        return value.trim();
+        return value;
     }
 
     public String getValue(String ns, String attr) {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/DataBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/DataBean.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/DataBean.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/DataBean.java Thu Apr 19 21:53:54 2007
@@ -20,7 +20,8 @@
 
 public class DataBean {
     private byte[] data = new byte[0];
-
+    private byte[] moreData = new byte[0];
+    
     public byte[] getData() {
         return data;
     }
@@ -28,4 +29,13 @@
     public void setData(byte[] data) {
         this.data = data;
     }
+
+    public byte[] getMoreData() {
+        return moreData;
+    }
+
+    public void setMoreData(byte[] moreData) {
+        this.moreData = moreData;
+    }
+    
 }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/DataService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/DataService.java?view=diff&rev=530639&r1=530638&r2=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/DataService.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/DataService.java Thu Apr 19 21:53:54 2007
@@ -22,4 +22,8 @@
     public DataBean getData() {
         return new DataBean();
     }
+
+    public DataBean echoData(DataBean bean) {
+        return bean;
+    }
 }

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java?view=auto&rev=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java Thu Apr 19 21:53:54 2007
@@ -0,0 +1,523 @@
+/**
+ * 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.basic;
+
+import java.beans.PropertyDescriptor;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.services.SimpleBean;
+import org.apache.cxf.aegis.type.Configuration;
+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.util.XmlConstants;
+import org.apache.cxf.aegis.util.jdom.StaxBuilder;
+import org.apache.cxf.aegis.xml.jdom.JDOMReader;
+import org.apache.cxf.aegis.xml.jdom.JDOMWriter;
+import org.apache.cxf.aegis.xml.stax.ElementReader;
+import org.apache.cxf.aegis.xml.stax.ElementWriter;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.output.DOMOutputter;
+import org.junit.Test;
+
+public class BeanTest extends AbstractAegisTest {
+    TypeMapping mapping;
+    private DefaultTypeMappingRegistry reg;
+
+    public void setUp() throws Exception {
+        super.setUp();
+
+        addNamespace("b", "urn:Bean");
+        addNamespace("a", "urn:anotherns");
+        addNamespace("xsi", XmlConstants.XSI_NS);
+
+        reg = new DefaultTypeMappingRegistry(true);
+        mapping = reg.createTypeMapping(true);
+    }
+
+    public void testBean() throws Exception {
+        BeanType type = new BeanType();
+        type.setTypeClass(SimpleBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        // Test reading
+        ElementReader reader = new ElementReader(getResourceAsStream("bean1.xml"));
+
+        SimpleBean bean = (SimpleBean)type.readObject(reader, new Context());
+        assertEquals("bleh", bean.getBleh());
+        assertEquals("howdy", bean.getHowdy());
+
+        reader.getXMLStreamReader().close();
+
+        // Test reading with extra elements
+        reader = new ElementReader(getResourceAsStream("bean2.xml"));
+        bean = (SimpleBean)type.readObject(reader, new Context());
+        assertEquals("bleh", bean.getBleh());
+        assertEquals("howdy", bean.getHowdy());
+        reader.getXMLStreamReader().close();
+
+        // test <bleh/> element
+        reader = new ElementReader(getResourceAsStream("bean7.xml"));
+        bean = (SimpleBean)type.readObject(reader, new Context());
+        assertEquals("", bean.getBleh());
+        assertEquals("howdy", bean.getHowdy());
+        reader.getXMLStreamReader().close();
+
+        bean.setBleh("bleh");
+
+        // Test writing
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), new Context());
+
+        assertValid("/b:root/b:bleh[text()='bleh']", element);
+        assertValid("/b:root/b:howdy[text()='howdy']", element);
+    }
+
+    private void assertValid(String xpath, Element element) throws Exception {
+        org.w3c.dom.Document doc = new DOMOutputter().output(element.getDocument());
+        
+        assertValid(xpath, doc);
+    }
+
+    private void assertInvalid(String xpath, Element element) throws Exception {
+        org.w3c.dom.Document doc = new DOMOutputter().output(element.getDocument());
+        
+        assertInvalid(xpath, doc);
+    }
+    
+    @Test
+    public void testBeanWithXsiType() throws Exception {
+        BeanType type = new BeanType();
+        type.setTypeClass(SimpleBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        // Test reading
+        ElementReader reader = new ElementReader(getResourceAsStream("bean9.xml"));
+
+        Context ctx = new Context();
+        ctx.setReadXsiTypes(false);
+
+        SimpleBean bean = (SimpleBean)type.readObject(reader, ctx);
+        assertEquals("bleh", bean.getBleh());
+        assertEquals("howdy", bean.getHowdy());
+
+        reader.getXMLStreamReader().close();
+
+        // Test writing
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), new Context());
+
+        assertValid("/b:root/b:bleh[text()='bleh']", element);
+        assertValid("/b:root/b:howdy[text()='howdy']", element);
+    }
+
+    @Test
+    public void testUnmappedProperty() throws Exception {
+        String ns = "urn:Bean";
+        BeanTypeInfo info = new BeanTypeInfo(SimpleBean.class, ns, false);
+
+        QName name = new QName(ns, "howdycustom");
+        info.mapElement("howdy", name);
+        info.setTypeMapping(mapping);
+
+        assertEquals("howdy", info.getPropertyDescriptorFromMappedName(name).getName());
+
+        BeanType type = new BeanType(info);
+        type.setTypeClass(SimpleBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        ElementReader reader = new ElementReader(getResourceAsStream("bean3.xml"));
+
+        SimpleBean bean = (SimpleBean)type.readObject(reader, new Context());
+        assertEquals("howdy", bean.getHowdy());
+        assertNull(bean.getBleh());
+
+        reader.getXMLStreamReader().close();
+
+        // Test writing
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), new Context());
+
+        assertInvalid("/b:root/b:bleh", element);
+        assertValid("/b:root/b:howdycustom[text()='howdy']", element);
+    }
+
+    @Test
+    public void testAttributeMap() throws Exception {
+        BeanTypeInfo info = new BeanTypeInfo(SimpleBean.class, "urn:Bean");
+        info.mapAttribute("howdy", new QName("urn:Bean", "howdy"));
+        info.mapAttribute("bleh", new QName("urn:Bean", "bleh"));
+        info.setTypeMapping(mapping);
+
+        BeanType type = new BeanType(info);
+        type.setTypeClass(SimpleBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        ElementReader reader = new ElementReader(getResourceAsStream("bean4.xml"));
+
+        SimpleBean bean = (SimpleBean)type.readObject(reader, new Context());
+        assertEquals("bleh", bean.getBleh());
+        assertEquals("howdy", bean.getHowdy());
+
+        reader.getXMLStreamReader().close();
+
+        // Test writing
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), new Context());
+
+        assertValid("/b:root[@b:bleh='bleh']", element);
+        assertValid("/b:root[@b:howdy='howdy']", element);
+
+        Element types = new Element("types", "xsd", XmlConstants.XSD);
+        Element schema = new Element("schema", "xsd", XmlConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
+        type.writeSchema(schema);
+
+        assertValid("//xsd:complexType[@name='bean']/xsd:attribute[@name='howdy']", schema);
+        assertValid("//xsd:complexType[@name='bean']/xsd:attribute[@name='bleh']", schema);
+    }
+
+    @Test
+    public void testAttributeMapDifferentNS() throws Exception {
+        BeanTypeInfo info = new BeanTypeInfo(SimpleBean.class, "urn:Bean");
+        info.mapAttribute("howdy", new QName("urn:Bean2", "howdy"));
+        info.mapAttribute("bleh", new QName("urn:Bean2", "bleh"));
+        info.setTypeMapping(mapping);
+
+        BeanType type = new BeanType(info);
+        type.setTypeClass(SimpleBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        ElementReader reader = new ElementReader(getResourceAsStream("bean8.xml"));
+
+        SimpleBean bean = (SimpleBean)type.readObject(reader, new Context());
+        assertEquals("bleh", bean.getBleh());
+        assertEquals("howdy", bean.getHowdy());
+
+        reader.getXMLStreamReader().close();
+
+        // Test writing
+
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
+        type.writeObject(bean, writer, new Context());
+        writer.close();
+        writer.flush();
+
+        bos.close();
+        
+        StaxBuilder builder = new StaxBuilder();
+        Document doc = builder.build(new ByteArrayInputStream(bos.toByteArray()));
+        Element element = doc.getRootElement();
+
+        addNamespace("b2", "urn:Bean2");
+        assertValid("/b:root[@b2:bleh='bleh']", element);
+        assertValid("/b:root[@b2:howdy='howdy']", element);
+    }
+
+    @Test
+    public void testNullProperties() throws Exception {
+        BeanTypeInfo info = new BeanTypeInfo(SimpleBean.class, "urn:Bean");
+        info.setTypeMapping(mapping);
+        info.mapAttribute("howdy", new QName("urn:Bean", "howdy"));
+        info.mapElement("bleh", new QName("urn:Bean", "bleh"));
+
+        BeanType type = new BeanType(info);
+        type.setTypeClass(SimpleBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        SimpleBean bean = new SimpleBean();
+
+        // Test writing
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), new Context());
+
+        assertInvalid("/b:root[@b:howdy]", element);
+        assertValid("/b:root/b:bleh[@xsi:nil='true']", element);
+
+        Element types = new Element("types", "xsd", XmlConstants.XSD);
+        Element schema = new Element("schema", "xsd", XmlConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
+        type.writeSchema(schema);
+
+        assertValid("//xsd:complexType[@name='bean']/xsd:attribute[@name='howdy']", schema);
+        assertValid("//xsd:complexType[@name='bean']/xsd:sequence/xsd:element[@name='bleh']", schema);
+    }
+    
+    @Test
+    public void testNillableInt() throws Exception {
+        BeanTypeInfo info = new BeanTypeInfo(IntBean.class, "urn:Bean");
+        info.setTypeMapping(mapping);
+
+        BeanType type = new BeanType(info);
+        type.setTypeClass(IntBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        Element types = new Element("types", "xsd", XmlConstants.XSD);
+        Element schema = new Element("schema", "xsd", XmlConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
+        type.writeSchema(schema);
+
+        assertValid("//xsd:complexType[@name='bean']/xsd:sequence/xsd:element[@name='int1']"
+                    + "[@nillable='true'][@minOccurs='0']",
+                    schema);
+        assertValid("//xsd:complexType[@name='bean']/xsd:sequence/xsd:element[@name='int2'][@minOccurs='0']",
+                    schema);
+        assertInvalid("//xsd:complexType[@name='bean']/xsd:sequence"
+                        + "/xsd:element[@name='int2'][@nillable='true']",
+                      schema);
+    }
+    @Test
+    public void testNillableIntMinOccurs1() throws Exception {
+        reg = new DefaultTypeMappingRegistry();
+
+        Configuration config = reg.getConfiguration();
+        config.setDefaultMinOccurs(1);
+        config.setDefaultNillable(false);
+
+        reg.createDefaultMappings();
+        mapping = reg.createTypeMapping(true);
+
+        BeanType type = (BeanType)mapping.getTypeCreator().createType(IntBean.class);
+        type.setTypeClass(IntBean.class);
+        type.setTypeMapping(mapping);
+
+        Element types = new Element("types", "xsd", XmlConstants.XSD);
+        Element schema = new Element("schema", "xsd", XmlConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
+        type.writeSchema(schema);
+
+        assertValid("//xsd:complexType[@name='IntBean']/xsd:sequence/xsd:element[@name='int1']", schema);
+        assertInvalid(
+                      "//xsd:complexType[@name='IntBean']/xsd:sequence/xsd:element[@name='int1'][@minOccurs]",
+                      schema);
+        assertInvalid("//xsd:complexType[@name='IntBean']/xsd:sequence/xsd:element[@name='int1'][@nillable]",
+                      schema);
+    }
+    @Test
+    public void testNullNonNillableWithDate() throws Exception {
+        BeanTypeInfo info = new BeanTypeInfo(DateBean.class, "urn:Bean");
+        info.setTypeMapping(mapping);
+
+        BeanType type = new BeanType(info);
+        type.setTypeClass(DateBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        DateBean bean = new DateBean();
+
+        // Test writing
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), new Context());
+
+        // Make sure the date doesn't have an element. Its non nillable so it
+        // just
+        // shouldn't be there.
+        assertInvalid("/b:root/b:date", element);
+        assertValid("/b:root", element);
+    }
+    @Test
+    public void testExtendedBean() throws Exception {
+        BeanTypeInfo info = new BeanTypeInfo(ExtendedBean.class, "urn:Bean");
+        info.setTypeMapping(mapping);
+
+        BeanType type = new BeanType(info);
+        type.setTypeClass(ExtendedBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        PropertyDescriptor[] pds = info.getPropertyDescriptors();
+        assertEquals(2, pds.length);
+
+        ExtendedBean bean = new ExtendedBean();
+        bean.setHowdy("howdy");
+
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), new Context());
+
+        assertValid("/b:root/b:howdy[text()='howdy']", element);
+    }
+    @Test
+    public void testByteBean() throws Exception {
+        BeanTypeInfo info = new BeanTypeInfo(ByteBean.class, "urn:Bean");
+        info.setTypeMapping(mapping);
+
+        BeanType type = new BeanType(info);
+        type.setTypeClass(ByteBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        QName name = new QName("urn:Bean", "data");
+        Type dataType = type.getTypeInfo().getType(name);
+        assertNotNull(dataType);
+
+        assertTrue(type.getTypeInfo().isNillable(name));
+
+        ByteBean bean = new ByteBean();
+
+        // Test writing
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), new Context());
+
+        // Make sure the date doesn't have an element. Its non nillable so it
+        // just
+        // shouldn't be there.
+
+        addNamespace("xsi", XmlConstants.XSI_NS);
+        assertValid("/b:root/b:data[@xsi:nil='true']", element);
+
+        bean = (ByteBean)type.readObject(new JDOMReader(element), new Context());
+        assertNotNull(bean);
+        assertNull(bean.getData());
+    }
+    @Test
+    public void testGetSetRequired() throws Exception {
+        BeanType type = new BeanType();
+        type.setTypeClass(GoodBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:foo", "BadBean"));
+
+        assertTrue(type.getTypeInfo().getElements().hasNext());
+
+        type = new BeanType();
+        type.setTypeClass(BadBean.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:foo", "BadBean"));
+
+        assertFalse(type.getTypeInfo().getElements().hasNext());
+
+        type = new BeanType();
+        type.setTypeClass(BadBean2.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:foo", "BadBean2"));
+
+        assertFalse(type.getTypeInfo().getElements().hasNext());
+    }
+
+    public static class DateBean {
+        private Date date;
+
+        public Date getDate() {
+            return date;
+        }
+
+        public void setDate(Date date) {
+            this.date = date;
+        }
+    }
+
+    public static class IntBean {
+        private Integer int1;
+        private int int2;
+
+        public Integer getInt1() {
+            return int1;
+        }
+
+        public void setInt1(Integer int1) {
+            this.int1 = int1;
+        }
+
+        public int getInt2() {
+            return int2;
+        }
+
+        public void setInt2(int int2) {
+            this.int2 = int2;
+        }
+    }
+
+    public static class ByteBean {
+        private byte[] data;
+
+        public byte[] getData() {
+            return data;
+        }
+
+        public void setData(byte[] data) {
+            this.data = data;
+        }
+    }
+
+    // This class only has a read property, no write
+    public static class GoodBean {
+        private String string;
+
+        public String getString() {
+            return string;
+        }
+    }
+
+    public static class BadBean {
+        public String delete() {
+            return null;
+        }
+    }
+
+    public static class BadBean2 {
+        public void setString(String string) {
+        }
+    }
+
+    public static class ExtendedBean extends SimpleBean {
+        private String howdy;
+
+        public String getHowdy() {
+            return howdy;
+        }
+
+        public void setHowdy(String howdy) {
+            this.howdy = howdy;
+        }
+    }
+}

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
------------------------------------------------------------------------------
    svn:executable = *

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java?view=auto&rev=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java Thu Apr 19 21:53:54 2007
@@ -0,0 +1,60 @@
+/**
+ * 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.basic;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.services.DataService;
+import org.apache.cxf.aegis.util.XmlConstants;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ * @since Feb 21, 2004
+ */
+public class ByteDataTest extends AbstractAegisTest {
+    public void setUp() throws Exception {
+        super.setUp();
+        createService(DataService.class, null);
+    }
+
+    @Test
+    public void testBeanService() throws Exception {
+        Node response = invoke("DataService", "GetData.xml");
+
+        addNamespace("s", "http://services.aegis.cxf.apache.org");
+        assertValid("//s:return/s:data", response);
+
+        response = invoke("DataService", "EchoData.xml");
+
+        assertValid("//s:return/s:data", response);
+
+    }
+
+    public void testBeanServiceWSDL() throws Exception {
+        Document doc = getWSDLDocument("DataService");
+        addNamespace("wsdl", XmlConstants.WSDL11_NS);
+        addNamespace("wsdlsoap", XmlConstants.WSDL11_SOAP_NS);
+        addNamespace("xsd", XmlConstants.XSD);
+
+        assertValid("//xsd:element[@name='data'][@type='xsd:base64Binary']", doc);
+    }
+}

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/ByteDataTest.java
------------------------------------------------------------------------------
    svn:executable = *

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java?view=auto&rev=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java Thu Apr 19 21:53:54 2007
@@ -0,0 +1,201 @@
+/**
+ * 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.basic;
+
+import javax.xml.namespace.QName;
+
+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.TypeMapping;
+import org.apache.cxf.aegis.type.TypeMappingRegistry;
+import org.apache.cxf.aegis.xml.stax.ElementReader;
+import org.junit.Test;
+
+public class DynamicProxyTest extends AbstractAegisTest {
+    TypeMapping mapping;
+
+    public void setUp() throws Exception {
+        super.setUp();
+
+        TypeMappingRegistry reg = new DefaultTypeMappingRegistry(true);
+        mapping = reg.createTypeMapping(true);
+    }
+
+
+    @Test
+    public void testDynamicProxy() throws Exception {
+        BeanType type = new BeanType();
+        type.setTypeClass(IMyInterface.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:MyInterface", "data"));
+
+        ElementReader reader = new ElementReader(getResourceAsStream("MyInterface.xml"));
+        IMyInterface data = (IMyInterface)type.readObject(reader, new Context());
+        assertEquals("junk", data.getName());
+        assertEquals(true, data.isUseless());
+        data.setName("bigjunk");
+        data.setUseless(false);
+        assertEquals("bigjunk", data.getName());
+        assertEquals(false, data.isUseless());
+
+        assertTrue(data.hashCode() != 0);
+        assertTrue(data.equals(data));
+        // checkstyle isn't smart enough to know we're testing equals....
+//        assertFalse(data.equals(null));
+//        assertFalse("bigjunk".equals(data));
+        assertNotNull(data.toString());
+
+        assertEquals("foo", data.getFOO());
+
+        assertEquals(0, data.getNonSpecifiedInt());
+    }
+
+    @Test
+    public void testDynamicProxyNonStandardGetter() throws Exception {
+        BeanType type = new BeanType();
+        type.setTypeClass(IMyInterface.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:MyInterface", "data"));
+
+        ElementReader reader = new ElementReader(getResourceAsStream("MyInterface.xml"));
+        IMyInterface data = (IMyInterface)type.readObject(reader, new Context());
+
+        try {
+            data.getNameById(0);
+            fail(IllegalAccessError.class + " should be thrown.");
+        } catch (IllegalAccessError e) {
+//          do nothing
+        }
+
+        try {
+            data.get();
+            fail(IllegalAccessError.class + " should be thrown.");
+        } catch (IllegalAccessError e) {
+//          do nothing
+        }
+    }
+
+    @Test
+    public void testDynamicProxyNonStandardSetter() throws Exception {
+        BeanType type = new BeanType();
+        type.setTypeClass(IMyInterface.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:MyInterface", "data"));
+
+        ElementReader reader = new ElementReader(getResourceAsStream("MyInterface.xml"));
+        IMyInterface data = (IMyInterface)type.readObject(reader, new Context());
+
+        try {
+            data.setNameNoParams();
+            fail(IllegalAccessError.class + " should be thrown.");
+        } catch (IllegalAccessError e) {
+            // do nothing
+        }
+
+        try {
+            data.set();
+            fail(IllegalAccessError.class + " should be thrown.");
+        } catch (IllegalAccessError e) {
+//          do nothing
+        }
+    }
+
+    @Test
+    public void testDynamicProxyNonGetterSetter() throws Exception {
+        BeanType type = new BeanType();
+        type.setTypeClass(IMyInterface.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:MyInterface", "data"));
+
+        ElementReader reader = new ElementReader(getResourceAsStream("MyInterface.xml"));
+        IMyInterface data = (IMyInterface)type.readObject(reader, new Context());
+
+        try {
+            data.doSomething();
+            fail(IllegalAccessError.class + " should be thrown.");
+        } catch (IllegalAccessError e) {
+            // do nothing
+        }
+    }
+
+    @Test
+    public void testDynamicProxyMissingAttribute() throws Exception {
+        BeanType type = new BeanType();
+        type.setTypeClass(IMyInterface.class);
+        type.setTypeMapping(mapping);
+        type.setSchemaType(new QName("urn:MyInterface", "data"));
+
+        ElementReader reader = new ElementReader(getResourceAsStream("MyInterface.xml"));
+        IMyInterface data = (IMyInterface)type.readObject(reader, new Context());
+
+        assertEquals("junk", data.getName());
+        assertNull(data.getType());
+    }
+
+    @Test
+    public void testDynamicProxyNested() throws Exception {
+        BeanType type = new BeanType();
+        type.setTypeClass(IMyInterface.class);
+        type.setSchemaType(new QName("urn:MyInterface", "myInterface"));
+        type.setTypeMapping(mapping);
+        BeanType type2 = new BeanType();
+        type2.setTypeClass(IMyInterface2.class);
+        type2.setSchemaType(new QName("urn:MyInterface2", "myInterface2"));
+        type2.setTypeMapping(mapping);
+        type2.getTypeInfo().mapType(new QName("urn:MyInterface", "myInterface"), type);
+
+        ElementReader reader = new ElementReader(getResourceAsStream("MyInterface2.xml"));
+        IMyInterface2 data = (IMyInterface2)type2.readObject(reader, new Context());
+
+        assertNotNull(data.getMyInterface());
+        assertEquals("junk", data.getMyInterface().getName());
+        assertEquals(true, data.getMyInterface().isUseless());
+    }
+
+    public interface IMyInterface {
+        String getName();
+
+        void setName(String name);
+
+        boolean isUseless();
+
+        void setUseless(boolean useless);
+
+        String getNameById(int id);
+
+        void setNameNoParams();
+
+        void doSomething();
+
+        String get();
+
+        Integer set();
+
+        String getType();
+
+        String getFOO();
+
+        int getNonSpecifiedInt();
+    }
+
+    public interface IMyInterface2 {
+        IMyInterface getMyInterface();
+    }
+}

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/DynamicProxyTest.java
------------------------------------------------------------------------------
    svn:executable = *

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/EchoData.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/EchoData.xml?view=auto&rev=530639
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/EchoData.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/EchoData.xml Thu Apr 19 21:53:54 2007
@@ -0,0 +1,11 @@
+<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
+ <env:Header/>
+ <env:Body>
+  <echoData xmlns="http://services.aegis.cxf.apache.org">
+    <bean>
+      <data></data>
+      <moreData></moreData>
+    </bean>
+  </echoData>
+ </env:Body>
+</env:Envelope>



Mime
View raw message