incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r1292069 - in /incubator/wink/trunk/wink-common: ./ src/main/java/org/apache/wink/common/internal/providers/entity/xml/
Date Tue, 21 Feb 2012 22:48:01 GMT
Author: rfeng
Date: Tue Feb 21 22:48:01 2012
New Revision: 1292069

URL: http://svn.apache.org/viewvc?rev=1292069&view=rev
Log:
Add generics support for collections

Modified:
    incubator/wink/trunk/wink-common/pom.xml
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBCollectionProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java

Modified: incubator/wink/trunk/wink-common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/pom.xml?rev=1292069&r1=1292068&r2=1292069&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/pom.xml (original)
+++ incubator/wink/trunk/wink-common/pom.xml Tue Feb 21 22:48:01 2012
@@ -82,6 +82,12 @@
             <groupId>org.codehaus.woodstox</groupId>
             <artifactId>wstx-asl</artifactId>
             <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>stax</groupId>
+                    <artifactId>stax-api</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         
         <dependency>

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBCollectionProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBCollectionProvider.java?rev=1292069&r1=1292068&r2=1292069&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBCollectionProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBCollectionProvider.java
Tue Feb 21 22:48:01 2012
@@ -90,7 +90,7 @@ public abstract class AbstractJAXBCollec
                             elementList.add(unmarshaller.unmarshal(xsr, theType));
                         } else if (theType.isAnnotationPresent(XmlRootElement.class)) {
                             Object o = unmarshaller.unmarshal(xsr);
-                            o = unmarshalWithXmlAdapter(o, getParameterizedTypeClassForRead(type,
genericType, false), annotations);
+                            o = unmarshalWithXmlAdapter(o, type, getParameterizedTypeClassForRead(type,
genericType, false), annotations);
                             if (o instanceof JAXBElement) {
                                 o = ((JAXBElement)o).getValue();
                             }
@@ -163,7 +163,7 @@ public abstract class AbstractJAXBCollec
             Marshaller marshaller = null;
             JAXBContext context = null;
             for (Object o : elementArray) {
-                o = marshalWithXmlAdapter(o, getParameterizedTypeClassForWrite(type, genericType,
false), annotations);
+                o = marshalWithXmlAdapter(o, type, getParameterizedTypeClassForWrite(type,
genericType, false), annotations);
                 if(marshaller == null) {
                     Class<?> oType =
                         isJAXBElement ? ((JAXBElement<?>)o).getDeclaredType() : o.getClass();

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java?rev=1292069&r1=1292068&r2=1292069&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
Tue Feb 21 22:48:01 2012
@@ -490,7 +490,7 @@ public abstract class AbstractJAXBProvid
     }
 
     private Class<?> getConcreteTypeFromAdapter(Class<?> type, Annotation[] annotations)
{
-        XmlJavaTypeAdapter adapter = getXmlJavaTypeAdapter(type, annotations);
+        XmlJavaTypeAdapter adapter = getXmlJavaTypeAdapter(type, type, annotations);
         if (adapter != null) {
             Class<?> adapterClass = adapter.value();
             try {
@@ -509,9 +509,9 @@ public abstract class AbstractJAXBProvid
         if (ret == null) {
             XmlElement xmlElement = getXmlElementAnno(type, annotations);
             if (xmlElement != null) {
-                Type xmlElementType = xmlElement.type();
+                Class<?> xmlElementType = xmlElement.type();
                 if (xmlElementType != null) {
-                    ret = (Class<?>)xmlElementType;
+                    ret = xmlElementType;
                 }
             }
             if (ret == null)
@@ -535,11 +535,11 @@ public abstract class AbstractJAXBProvid
     }
 
     @SuppressWarnings("unchecked")
-    protected Object marshalWithXmlAdapter(Object obj, Type type, Annotation[] annotations)
{
+    protected Object marshalWithXmlAdapter(Object obj, Class<?> cls, Type type, Annotation[]
annotations) {
         if ((type == null) || (annotations == null)) {
             return obj;
         }
-        XmlJavaTypeAdapter xmlJavaTypeAdapter = getXmlJavaTypeAdapter(type, annotations);
+        XmlJavaTypeAdapter xmlJavaTypeAdapter = getXmlJavaTypeAdapter(cls, type, annotations);
         if (xmlJavaTypeAdapter != null) {
             try {
                 XmlAdapter xmlAdapter = xmlJavaTypeAdapter.value().newInstance();
@@ -559,21 +559,21 @@ public abstract class AbstractJAXBProvid
      * @param annotations
      * @return
      */
-    private XmlJavaTypeAdapter getXmlJavaTypeAdapter(Type type, Annotation[] annotations)
{
+    private XmlJavaTypeAdapter getXmlJavaTypeAdapter(Class<?> cls, Type type, Annotation[]
annotations) {
         Boolean present = xmlJavaTypeAdapterPresentCache.get(type);
         if (Boolean.FALSE.equals(present)) {
             return null;
         }
         XmlJavaTypeAdapter xmlJavaTypeAdapter = xmlJavaTypeAdapterCache.get(type);
         if(xmlJavaTypeAdapter == null) {
-            xmlJavaTypeAdapter = findXmlJavaTypeAdapter(type, annotations);
+            xmlJavaTypeAdapter = findXmlJavaTypeAdapter(cls, type, annotations);
             xmlJavaTypeAdapterCache.put(type, xmlJavaTypeAdapter);
             xmlJavaTypeAdapterPresentCache.put(type, xmlJavaTypeAdapter != null);
         }
         return xmlJavaTypeAdapter;
     }
 
-    private XmlJavaTypeAdapter findXmlJavaTypeAdapter(Type type, Annotation[] annotations)
{
+    private XmlJavaTypeAdapter findXmlJavaTypeAdapter(Class<?> cls, Type type, Annotation[]
annotations) {
         XmlJavaTypeAdapter xmlJavaTypeAdapter = null;
         for (int i = 0; (annotations != null) && i < annotations.length; i++)
{
             if (annotations[i].annotationType() == XmlJavaTypeAdapter.class) {
@@ -581,9 +581,9 @@ public abstract class AbstractJAXBProvid
                 break;
             }
         }
-        if ((xmlJavaTypeAdapter == null) && (type != null)) {
+        if ((xmlJavaTypeAdapter == null) && (cls != null)) {
             // check the type itself
-            xmlJavaTypeAdapter = ((Class<?>)type).getAnnotation(XmlJavaTypeAdapter.class);
+            xmlJavaTypeAdapter = cls.getAnnotation(XmlJavaTypeAdapter.class);
         }
         return xmlJavaTypeAdapter;
     }
@@ -605,11 +605,11 @@ public abstract class AbstractJAXBProvid
     }
 
     @SuppressWarnings("unchecked")
-    protected Object unmarshalWithXmlAdapter(Object obj, Type type, Annotation[] annotations)
{
+    protected Object unmarshalWithXmlAdapter(Object obj, Class<?> cls, Type type, Annotation[]
annotations) {
         if ((type == null) || (annotations == null)) {
             return obj;
         }
-        XmlJavaTypeAdapter xmlJavaTypeAdapter = getXmlJavaTypeAdapter(type, annotations);
+        XmlJavaTypeAdapter xmlJavaTypeAdapter = getXmlJavaTypeAdapter(cls, type, annotations);
         if (xmlJavaTypeAdapter != null) {
             try {
                 XmlAdapter xmlAdapter = xmlJavaTypeAdapter.value().newInstance();

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java?rev=1292069&r1=1292068&r2=1292069&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
Tue Feb 21 22:48:01 2012
@@ -147,7 +147,7 @@ public class JAXBXmlProvider extends Abs
             closeXMLStreamReader(xmlStreamReader);
             throw e;
         }
-        return unmarshalWithXmlAdapter(unmarshaledResource, type, annotations);
+        return unmarshalWithXmlAdapter(unmarshaledResource, type, type, annotations);
     }
 
     public long getSize(Object t,
@@ -173,7 +173,7 @@ public class JAXBXmlProvider extends Abs
                         MultivaluedMap<String, Object> httpHeaders,
                         OutputStream entityStream) throws IOException, WebApplicationException
{
 
-        t = marshalWithXmlAdapter(t, genericType, annotations);
+        t = marshalWithXmlAdapter(t, type, genericType, annotations);
         Class<?> concreteType = getConcreteTypeFromTypeMap(type, annotations);
         mediaType = MediaTypeUtils.setDefaultCharsetOnMediaTypeHeader(httpHeaders, mediaType);
 



Mime
View raw message