cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1408862 - in /cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type: DefaultTypeMapping.java basic/BigDecimalType.java java5/Java5TypeCreator.java
Date Tue, 13 Nov 2012 18:01:16 GMT
Author: dkulp
Date: Tue Nov 13 18:01:15 2012
New Revision: 1408862

URL: http://svn.apache.org/viewvc?rev=1408862&view=rev
Log:
[CXF-4605] Add a warning message if a generic type could not be mapped due to an erased generic.

Modified:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigDecimalType.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java?rev=1408862&r1=1408861&r2=1408862&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
Tue Nov 13 18:01:15 2012
@@ -256,6 +256,8 @@ public class DefaultTypeMapping implemen
                         new SqlDateType());
         defaultRegister(tm, defaultNillable, java.sql.Date.class, XMLSchemaQNames.XSD_DATE,
                         new SqlDateType());
+        defaultRegister(tm, defaultNillable, Number.class, XMLSchemaQNames.XSD_DECIMAL,
+                        new BigDecimalType());
         
         QName mtomBase64 = XMLSchemaQNames.XSD_BASE64;
         if (enableMtomXmime) {

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigDecimalType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigDecimalType.java?rev=1408862&r1=1408861&r2=1408862&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigDecimalType.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigDecimalType.java
Tue Nov 13 18:01:15 2012
@@ -19,6 +19,9 @@
 package org.apache.cxf.aegis.type.basic;
 
 import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.cxf.aegis.Context;
 import org.apache.cxf.aegis.type.AegisType;
@@ -44,6 +47,26 @@ public class BigDecimalType extends Aegi
 
     @Override
     public void writeObject(final Object object, final MessageWriter writer, final Context
context) {
-        writer.writeValue(((BigDecimal)object).toPlainString());
+        BigDecimal d = null;
+        if (object instanceof BigDecimal) {
+            d = (BigDecimal)object;
+        } else if (object instanceof BigInteger) {
+            d = new BigDecimal((BigInteger)object);
+        } else if (object instanceof AtomicInteger || object instanceof Integer) {
+            d = new BigDecimal(((Number)object).intValue());
+        } else if (object instanceof Long || object instanceof AtomicLong) {
+            d = new BigDecimal(((Number)object).longValue());
+        } else if (object instanceof Double) {
+            d = new BigDecimal(((Number)object).doubleValue());
+        } else if (object instanceof Float) {
+            d = new BigDecimal(((Number)object).floatValue());
+        } else if (object instanceof Short) {
+            d = new BigDecimal(((Number)object).shortValue());
+        } else if (object instanceof Byte) {
+            d = new BigDecimal(((Number)object).byteValue());
+        } else {
+            d = new BigDecimal(((Number)object).doubleValue());
+        }
+        writer.writeValue(d.toPlainString());
     }
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java?rev=1408862&r1=1408861&r2=1408862&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
Tue Nov 13 18:01:15 2012
@@ -28,6 +28,8 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
 
@@ -39,8 +41,11 @@ import org.apache.cxf.aegis.type.TypeUti
 import org.apache.cxf.aegis.type.basic.BeanType;
 import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.apache.cxf.aegis.util.ServiceUtils;
+import org.apache.cxf.common.logging.LogUtils;
 
 public class Java5TypeCreator extends AbstractTypeCreator {
+    private static final Logger LOG = LogUtils.getL7dLogger(Java5TypeCreator.class);
+    
     private AnnotationReader annotationReader;
 
     public Java5TypeCreator() {
@@ -167,6 +172,17 @@ public class Java5TypeCreator extends Ab
             paramType = getComponentType(generic.getType(), index);
         }
 
+        if (paramType instanceof WildcardType) {
+            WildcardType wct = (WildcardType)paramType;
+            paramType = wct.getUpperBounds()[0];
+        }
+        if (paramType instanceof TypeVariable) {
+            TypeVariable<?> v = (TypeVariable<?>)paramType;
+            LOG.log(Level.WARNING,
+                    "Could not map TypeVariable named {0} from {1} with initial mapping {2}
to "
+                    + "a known class.  Using Object.",
+                    new Object[] {v.getName(), generic.getType().toString(), generic.getTypeVars()});
+        }
         if (paramType == null) {
             return createObjectType();
         }



Mime
View raw message