cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1442078 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/ext/ main/java/org/apache/cxf/jaxrs/provider/ test/java/org/apache/cxf/jaxrs/ test/java/org/apache/cxf/jaxrs/provider/ test/java/org/apache/cxf/jaxrs/utils/
Date Mon, 04 Feb 2013 11:18:06 GMT
Author: sergeyb
Date: Mon Feb  4 11:18:06 2013
New Revision: 1442078

URL: http://svn.apache.org/viewvc?rev=1442078&view=rev
Log:
[CXF-4804] Removing ParameterHandler

Removed:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ParameterHandler.java
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerParameterHandler.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1442078&r1=1442077&r2=1442078&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Mon Feb  4 11:18:06 2013
@@ -72,7 +72,6 @@ import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
 import org.apache.cxf.jaxrs.ext.ContextProvider;
-import org.apache.cxf.jaxrs.ext.ParameterHandler;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.ext.ResponseHandler;
 import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
@@ -130,7 +129,6 @@ public final class ProviderFactory {
         new ArrayList<ProviderInfo<ContextProvider<?>>>(1);
     
     private ParamConverterProvider newParamConverter;
-    private LegacyParamConverterProvider legacyParamConverter; 
     
     private List<ProviderInfo<MessageBodyReader<?>>> jaxbReaders = 
         new ArrayList<ProviderInfo<MessageBodyReader<?>>>();
@@ -381,8 +379,6 @@ public final class ProviderFactory {
         
         if (newParamConverter != null) {
             return newParamConverter.getConverter(paramType, null, null);
-        } else if (legacyParamConverter != null) {
-            return legacyParamConverter.getConverter(paramType, null, null);
         } else {
             return null;
         }
@@ -796,15 +792,6 @@ public final class ProviderFactory {
             if (ParamConverterProvider.class.isAssignableFrom(oClass)) {
                 newParamConverter = (ParamConverterProvider)o;
             }
-            
-            if (ParameterHandler.class.isAssignableFrom(oClass)) {
-                if (legacyParamConverter == null) {
-                    legacyParamConverter = new LegacyParamConverterProvider();
-                }
-                legacyParamConverter.add(o, bus);
-            }
-            
-            
         }
         sortReaders();
         sortWriters();
@@ -1155,9 +1142,6 @@ public final class ProviderFactory {
         postMatchContainerRequestFilters.clear();
         postMatchContainerResponseFilters.clear();
         preMatchContainerRequestFilters.clear();
-        if (legacyParamConverter != null) {
-            legacyParamConverter.clear();
-        }
         responseExceptionMappers.clear();
         clientRequestFilters.clear();
         clientResponseFilters.clear();
@@ -1664,60 +1648,4 @@ public final class ProviderFactory {
             }
         }
     }
-    
-    private static class LegacyParamConverterProvider implements ParamConverterProvider {
-
-        // ParamConverter and ParamConverterProvider is introduced in JAX-RS 2.0
-        // ParameterHandler will have to be deprecated
-        private List<ProviderInfo<ParameterHandler<?>>> paramHandlers =

-            new ArrayList<ProviderInfo<ParameterHandler<?>>>(1);
-        
-        @SuppressWarnings({
-            "unchecked", "rawtypes"
-        })
-        @Override
-        public <T> ParamConverter<T> getConverter(Class<T> rawType, Type
genericType, Annotation[] annotations) {
-            List<ParameterHandler<?>> candidates = new LinkedList<ParameterHandler<?>>();
-            
-            for (ProviderInfo<ParameterHandler<?>> em : paramHandlers) {
-                handleMapper(candidates, em, rawType, null, ParameterHandler.class, true);
-            }
-            if (candidates.size() == 0) {
-                return null;
-            }
-            Collections.sort(candidates, new ClassComparator());
-            return new LegacyParamConverter((ParameterHandler<T>) candidates.get(0));
-        }
-        
-        public void clear() {
-            paramHandlers.clear();
-        }
-        
-        public void add(Object o, Bus bus) {
-            paramHandlers.add(new ProviderInfo<ParameterHandler<?>>((ParameterHandler<?>)o,
bus));
-        }
-    }
-    
-    static class LegacyParamConverter<T> implements ParamConverter<T> {
-
-        private ParameterHandler<T> handler;
-        public LegacyParamConverter(ParameterHandler<T> handler) {
-            this.handler = handler;
-        }
-        
-        @Override
-        public T fromString(String value) throws IllegalArgumentException {
-            return handler.fromString(value);
-        }
-
-        @Override
-        public String toString(Object value) throws IllegalArgumentException {
-            // TODO Auto-generated method stub
-            return null;
-        }
-        
-        ParameterHandler<T> getHandler() {
-            return handler;
-        }
-    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerParameterHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerParameterHandler.java?rev=1442078&r1=1442077&r2=1442078&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerParameterHandler.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/CustomerParameterHandler.java
Mon Feb  4 11:18:06 2013
@@ -19,11 +19,26 @@
 
 package org.apache.cxf.jaxrs;
 
-import org.apache.cxf.jaxrs.ext.ParameterHandler;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
 
-public class CustomerParameterHandler implements ParameterHandler<Customer> {
+import javax.ws.rs.ext.ParamConverter;
+import javax.ws.rs.ext.ParamConverterProvider;
 
-    public Customer fromString(String s) {
+
+public class CustomerParameterHandler implements ParamConverterProvider, ParamConverter<Customer>
{
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> ParamConverter<T> getConverter(Class<T> cls, Type arg1,
Annotation[] arg2) {
+        if (Customer.class.isAssignableFrom(cls)) {
+            return (ParamConverter<T>)this;
+        } else {
+            return null;
+        }
+    }
+
+    public Customer fromString(String s) throws IllegalArgumentException {
         if ("noName".equals(s)) {
             throw new IllegalArgumentException();
         }
@@ -32,4 +47,8 @@ public class CustomerParameterHandler im
         return c;
     }
 
+    @Override
+    public String toString(Customer arg0) throws IllegalArgumentException {
+        return null;
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=1442078&r1=1442077&r2=1442078&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
Mon Feb  4 11:18:06 2013
@@ -48,6 +48,7 @@ import javax.ws.rs.ext.ExceptionMapper;
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.ParamConverter;
+import javax.ws.rs.ext.ParamConverterProvider;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.validation.Schema;
@@ -59,7 +60,6 @@ import org.apache.cxf.jaxrs.CustomerPara
 import org.apache.cxf.jaxrs.JAXBContextProvider;
 import org.apache.cxf.jaxrs.JAXBContextProvider2;
 import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.apache.cxf.jaxrs.ext.ParameterHandler;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
@@ -67,7 +67,6 @@ import org.apache.cxf.jaxrs.model.Abstra
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
-import org.apache.cxf.jaxrs.provider.ProviderFactory.LegacyParamConverter;
 import org.apache.cxf.jaxrs.resources.Book;
 import org.apache.cxf.jaxrs.resources.SuperBook;
 import org.apache.cxf.message.Exchange;
@@ -416,11 +415,10 @@ public class ProviderFactoryTest extends
     @Test
     public void testParameterHandlerProvider() throws Exception {
         ProviderFactory pf = ProviderFactory.getInstance();
-        ParameterHandler<Customer> h = new CustomerParameterHandler();
+        ParamConverterProvider h = new CustomerParameterHandler();
         pf.registerUserProvider(h);
         ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class);
-        
-        assertSame(((LegacyParamConverter<Customer>)h2).getHandler(), h);
+        assertSame(h2, h);
     }
     
     @Test

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1442078&r1=1442077&r2=1442078&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Mon Feb  4 11:18:06 2013
@@ -21,7 +21,9 @@ package org.apache.cxf.jaxrs.utils;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.lang.reflect.Type;
 import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -46,6 +48,8 @@ import javax.ws.rs.core.Request;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.ParamConverter;
+import javax.ws.rs.ext.ParamConverterProvider;
 import javax.ws.rs.ext.Providers;
 import javax.xml.bind.JAXBContext;
 
@@ -66,7 +70,6 @@ import org.apache.cxf.jaxrs.JAXRSService
 import org.apache.cxf.jaxrs.SimpleFactory;
 import org.apache.cxf.jaxrs.Timezone;
 import org.apache.cxf.jaxrs.ext.ContextProvider;
-import org.apache.cxf.jaxrs.ext.ParameterHandler;
 import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
 import org.apache.cxf.jaxrs.impl.HttpServletResponseFilter;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
@@ -1851,12 +1854,28 @@ public class JAXRSUtilsTest extends Asse
         return m;
     }
     
-    private static class LocaleParameterHandler implements ParameterHandler<Locale>
{
+    private static class LocaleParameterHandler implements ParamConverterProvider, ParamConverter<Locale>
{
 
+        @SuppressWarnings("unchecked")
+        @Override
+        public <T> ParamConverter<T> getConverter(Class<T> cls, Type arg1,
Annotation[] arg2) {
+            if (cls == Locale.class) {
+                return (ParamConverter<T>)this;
+            } else {
+                return null;
+            }
+        }
+        
         public Locale fromString(String s) {
             String[] values = s.split("_");
             return values.length == 2 ? new Locale(values[0], values[1]) : new Locale(s);
         }
+
+        @Override
+        public String toString(Locale arg0) throws IllegalArgumentException {
+            // TODO Auto-generated method stub
+            return null;
+        }
         
     }
 }



Mime
View raw message