cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r775079 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/main/...
Date Fri, 15 May 2009 10:22:42 GMT
Author: sergeyb
Date: Fri May 15 10:22:42 2009
New Revision: 775079

URL: http://svn.apache.org/viewvc?rev=775079&view=rev
Log:
JAXRS: context injection into super fields, support for type variables

Added:
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/AbstractCustomer.java 
 (with props)
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity.java
  (with props)
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity2.java
  (with props)
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity.java
  (with props)
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity2.java
  (with props)
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntity.java
  (with props)
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntityImpl.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java?rev=775079&r1=775078&r2=775079&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalContextResolver.java
Fri May 15 10:22:42 2009
@@ -26,7 +26,7 @@
 
     @SuppressWarnings("unchecked")
     public Object getContext(Class type) {
-        return get().getContext(type);
+        return get() != null ? get().getContext(type) : null;
     }
 
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=775079&r1=775078&r2=775079&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Fri May 15 10:22:42 2009
@@ -24,6 +24,7 @@
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.text.SimpleDateFormat;
 import java.util.Collections;
 import java.util.Date;
@@ -158,20 +159,24 @@
             return;
         }
         
-        Class<?> targetType = getRawResponseClass(responseObj);
         List<MediaType> availableContentTypes = computeAvailableContentTypes(message,
response);  
         
         Method invoked = null;
         if (firstTry) {
             invoked = ori == null ? null : ori.getMethodToInvoke();
         }
+        Class<?> targetType = getRawResponseClass(responseObj);
+        Type genericType = getGenericResponseType(invoked, responseObj);
+        if (genericType instanceof TypeVariable) {
+            genericType = InjectionUtils.getSuperType(ori.getClassResourceInfo().getServiceClass(),

+                                                       (TypeVariable)genericType);
+        }
         
         MessageBodyWriter writer = null;
         MediaType responseType = null;
         for (MediaType type : availableContentTypes) { 
             writer = ProviderFactory.getInstance(message)
-                .createMessageBodyWriter(targetType, 
-                      getGenericResponseType(invoked, responseObj), 
+                .createMessageBodyWriter(targetType, genericType, 
                       invoked != null ? invoked.getAnnotations() : new Annotation[]{}, 
                       type,
                       message);

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java?rev=775079&r1=775078&r2=775079&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
Fri May 15 10:22:42 2009
@@ -67,9 +67,14 @@
         if (resourceClass == null || !root) {
             return;
         }
-        
-        
-        for (Field f : getServiceClass().getDeclaredFields()) {
+        findContextFields(serviceClass);
+    }
+    
+    private void findContextFields(Class<?> cls) {
+        if (cls == Object.class || cls == null) {
+            return;
+        }
+        for (Field f : cls.getDeclaredFields()) {
             for (Annotation a : f.getAnnotations()) {
                 if (a.annotationType() == Context.class) {
                     if (contextFields == null) {
@@ -93,6 +98,7 @@
                 }
             }
         }
+        findContextFields(cls.getSuperclass());
     }
     
     private void initContextSetterMethods() {

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=775079&r1=775078&r2=775079&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
Fri May 15 10:22:42 2009
@@ -394,16 +394,16 @@
                                                Type genericType,
                                                Annotation[] annotations,
                                                MediaType mediaType) {
-        if (!ep.isReadable(type, genericType, annotations, mediaType)) {
-            return false;
-        }
-        
         List<MediaType> supportedMediaTypes = JAXRSUtils.getProviderConsumeTypes(ep);
         
         List<MediaType> availableMimeTypes = 
             JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType), supportedMediaTypes);
 
-        return availableMimeTypes.size() != 0 ? true : false;
+        if (availableMimeTypes.size() == 0) {
+            return false;
+        }
+        
+        return ep.isReadable(type, genericType, annotations, mediaType);
         
     }
         
@@ -440,18 +440,16 @@
                                                Type genericType,
                                                Annotation[] annotations,
                                                MediaType mediaType) {
-        if (!ep.isWriteable(type, genericType, annotations, mediaType)) {
-            return false;
-        }
-        
         List<MediaType> supportedMediaTypes = JAXRSUtils.getProviderProduceTypes(ep);
         
         List<MediaType> availableMimeTypes = 
             JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType),
                                           supportedMediaTypes);
 
-        return availableMimeTypes.size() != 0 ? true : false;
-        
+        if (availableMimeTypes.size() == 0) {
+            return false;
+        }
+        return ep.isWriteable(type, genericType, annotations, mediaType); 
     }
     
     List<ProviderInfo<MessageBodyReader>> getMessageReaders() {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=775079&r1=775078&r2=775079&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Fri May 15 10:22:42 2009
@@ -28,6 +28,7 @@
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Proxy;
 import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -93,6 +94,28 @@
         
     }
 
+    public static Type getSuperType(Class<?> serviceClass, TypeVariable var) {
+        
+        int pos = 0;
+        TypeVariable[] vars = var.getGenericDeclaration().getTypeParameters();
+        for (; pos < vars.length; pos++) {
+            if (vars[pos].getName().equals(var.getName())) {
+                break;
+            }
+        }
+        
+        Type genericSubtype = serviceClass.getGenericSuperclass();
+        if (genericSubtype == Object.class) {
+            Type[] genInterfaces = serviceClass.getGenericInterfaces();
+            for (Type t : genInterfaces) {
+                genericSubtype = t;
+                break;
+            }
+        }
+        return genericSubtype != Object.class ? InjectionUtils.getActualType(genericSubtype,
pos)
+                                              : genericSubtype;
+    }
+    
     public static boolean invokeBooleanGetter(Object o, String name) {
         try {
             Method method = o.getClass().getMethod(name, new Class[]{});
@@ -158,6 +181,11 @@
     
     public static Class<?> getActualType(Type genericType) {
         
+        return getActualType(genericType, 0);
+    }
+    
+    public static Class<?> getActualType(Type genericType, int pos) {
+        
         if (genericType == null) {
             return null;
         }
@@ -166,7 +194,11 @@
             return cls.isArray() ? cls.getComponentType() : null;
         }
         ParameterizedType paramType = (ParameterizedType)genericType;
-        Type t = paramType.getActualTypeArguments()[0];
+        Type[] types = paramType.getActualTypeArguments();
+        if (pos >= types.length) {
+            throw new RuntimeException("No type can be found at position " + pos);
+        }
+        Type t = types[pos];
         // we don't recurse at this stage, otherwise GenericEntity won't be handled properly
         return t instanceof Class ? (Class<?>)t : null;
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=775079&r1=775078&r2=775079&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Fri
May 15 10:22:42 2009
@@ -26,6 +26,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -424,13 +425,21 @@
         List<Object> params = new ArrayList<Object>(parameterTypes.length);
 
         for (int i = 0; i < parameterTypes.length; i++) {
-            Object param = processParameter(parameterTypes[i], 
-                                            genericParameterTypes[i],
-                                            parameterAnnotations[i], 
-                                            values, 
-                                            message,
-                                            ori);
-            params.add(param);
+            Class<?> param = parameterTypes[i]; 
+            Type genericParam = genericParameterTypes[i];
+            if (param == Object.class && genericParam instanceof TypeVariable) {
+                genericParam = InjectionUtils.getSuperType(ori.getClassResourceInfo().getServiceClass(),

+                                                           (TypeVariable)genericParam);
+                param = (Class)genericParam; 
+            }
+            
+            Object paramValue = processParameter(param, 
+                                                 genericParam,
+                                                 parameterAnnotations[i], 
+                                                 values, 
+                                                 message,
+                                                 ori);
+            params.add(paramValue);
         }
 
         return params;
@@ -442,6 +451,7 @@
                                            MultivaluedMap<String, String> values,
                                            Message message,
                                            OperationResourceInfo ori) {
+        
         InputStream is = message.getContent(InputStream.class);
 
         if (parameterAnns == null 

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/AbstractCustomer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/AbstractCustomer.java?rev=775079&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/AbstractCustomer.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/AbstractCustomer.java Fri
May 15 10:22:42 2009
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.Context;
+
+public class AbstractCustomer {
+    @Context 
+    private ServletContext sContext;
+    
+    public ServletContext getSuperServletContext() {
+        return sContext;
+    }
+};

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/AbstractCustomer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/AbstractCustomer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=775079&r1=775078&r2=775079&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java Fri May 15
10:22:42 2009
@@ -51,7 +51,7 @@
 
 import org.apache.cxf.jaxrs.impl.PathSegmentImpl;
 
-public class Customer implements CustomerInfo {
+public class Customer extends AbstractCustomer implements CustomerInfo {
     
     @XmlRootElement(name = "CustomerBean")
     public static class CustomerBean {

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java?rev=775079&r1=775078&r2=775079&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
Fri May 15 10:22:42 2009
@@ -19,16 +19,30 @@
 
 package org.apache.cxf.jaxrs;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.util.Collections;
 import java.util.List;
 
 import javax.ws.rs.core.MediaType;
 
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.jaxrs.fortest.BookEntity;
+import org.apache.cxf.jaxrs.fortest.BookEntity2;
+import org.apache.cxf.jaxrs.fortest.GenericEntityImpl;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.URITemplate;
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.resources.Book;
+import org.apache.cxf.jaxrs.resources.Chapter;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.easymock.classextension.EasyMock;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -36,6 +50,98 @@
 public class SelectMethodCandidatesTest extends Assert {
     
     @Test
+    public void testFindFromAbstractGenericClass() throws Exception {
+        doTestGenericSuperType(BookEntity.class, "POST");
+    }
+    
+    @Test
+    public void testFindFromAbstractGenericClass2() throws Exception {
+        doTestGenericSuperType(BookEntity2.class, "POST");
+    }
+    
+    @Test
+    public void testFindFromAbstractGenericInterface() throws Exception {
+        doTestGenericSuperType(GenericEntityImpl.class, "POST");
+    }
+    
+    @Test
+    public void testFindFromAbstractGenericClass3() throws Exception {
+        JAXRSServiceFactoryBean sf = new JAXRSServiceFactoryBean();
+        sf.setResourceClasses(BookEntity.class);
+        sf.create();
+        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)sf.getService()).getClassResourceInfos();
+        String contentTypes = "text/xml";
+        String acceptContentTypes = "text/xml";
+        
+        MetadataMap<String, String> values = new MetadataMap<String, String>();
+        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/books",
values);
+        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource, 
+                                    values.getFirst(URITemplate.FINAL_MATCH_GROUP), 
+                                    "PUT", values, contentTypes, 
+                                    JAXRSUtils.sortMediaTypes(acceptContentTypes));
+        assertNotNull(ori);
+        assertEquals("resourceMethod needs to be selected", "putEntity",
+                     ori.getMethodToInvoke().getName());
+        
+        Message m = new MessageImpl();
+        m.put(Message.CONTENT_TYPE, "text/xml");
+        Exchange ex = new ExchangeImpl();
+        m.setExchange(ex);
+        Endpoint e = EasyMock.createMock(Endpoint.class);
+        e.get(ProviderFactory.class.getName());
+        EasyMock.expectLastCall().andReturn(ProviderFactory.getInstance());
+        EasyMock.replay(e);
+        ex.put(Endpoint.class, e);
+        
+        String value = "<Chapter><title>The Book</title><id>2</id></Chapter>";
+        m.setContent(InputStream.class, new ByteArrayInputStream(value.getBytes()));
+        List<Object> params = JAXRSUtils.processParameters(ori, values, m);
+        assertEquals(1, params.size());
+        Chapter c = (Chapter)params.get(0);
+        assertNotNull(c);
+        assertEquals(2L, c.getId());
+        assertEquals("The Book", c.getTitle());
+    }
+    
+    private void doTestGenericSuperType(Class<?> serviceClass, String methodName) {
+        JAXRSServiceFactoryBean sf = new JAXRSServiceFactoryBean();
+        sf.setResourceClasses(serviceClass);
+        sf.create();
+        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)sf.getService()).getClassResourceInfos();
+        String contentTypes = "text/xml";
+        String acceptContentTypes = "text/xml";
+        
+        MetadataMap<String, String> values = new MetadataMap<String, String>();
+        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/books",
values);
+        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource, 
+                                    values.getFirst(URITemplate.FINAL_MATCH_GROUP), 
+                                    methodName, values, contentTypes, 
+                                    JAXRSUtils.sortMediaTypes(acceptContentTypes));
+        assertNotNull(ori);
+        assertEquals("resourceMethod needs to be selected", methodName.toLowerCase() + "Entity",
+                     ori.getMethodToInvoke().getName());
+        
+        Message m = new MessageImpl();
+        m.put(Message.CONTENT_TYPE, "text/xml");
+        Exchange ex = new ExchangeImpl();
+        m.setExchange(ex);
+        Endpoint e = EasyMock.createMock(Endpoint.class);
+        e.get(ProviderFactory.class.getName());
+        EasyMock.expectLastCall().andReturn(ProviderFactory.getInstance());
+        EasyMock.replay(e);
+        ex.put(Endpoint.class, e);
+        
+        String value = "<Book><name>The Book</name><id>2</id></Book>";
+        m.setContent(InputStream.class, new ByteArrayInputStream(value.getBytes()));
+        List<Object> params = JAXRSUtils.processParameters(ori, values, m);
+        assertEquals(1, params.size());
+        Book book = (Book)params.get(0);
+        assertNotNull(book);
+        assertEquals(2L, book.getId());
+        assertEquals("The Book", book.getName());
+    }
+    
+    @Test
     public void testFindTargetSubResource() throws Exception {
         JAXRSServiceFactoryBean sf = new JAXRSServiceFactoryBean();
         sf.setResourceClasses(org.apache.cxf.jaxrs.resources.TestResource.class);

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity.java?rev=775079&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity.java
Fri May 15 10:22:42 2009
@@ -0,0 +1,49 @@
+/**
+ * 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.jaxrs.fortest;
+
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+
+
+public class AbstractEntity<T, E> {
+    
+    private T entity1;
+    private E entity2;
+    
+    @POST
+    public void postEntity(T object) {
+        entity1 = object;   
+    }
+    
+    @PUT
+    public void putEntity(E object) {
+        entity2 = object;   
+    }
+    
+    public T getEntity1() {
+        return entity1;
+    }
+    
+    public E getEntity2() {
+        return entity2;
+    }
+    
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity2.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity2.java?rev=775079&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity2.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity2.java
Fri May 15 10:22:42 2009
@@ -0,0 +1,25 @@
+/**
+ * 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.jaxrs.fortest;
+
+
+
+public class AbstractEntity2<T, E> extends AbstractEntity {
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/AbstractEntity2.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity.java?rev=775079&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity.java
Fri May 15 10:22:42 2009
@@ -0,0 +1,28 @@
+/**
+ * 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.jaxrs.fortest;
+
+import javax.ws.rs.Path;
+
+import org.apache.cxf.jaxrs.resources.Book;
+import org.apache.cxf.jaxrs.resources.Chapter;
+
+@Path("/books")
+public class BookEntity extends AbstractEntity<Book, Chapter> {
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity2.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity2.java?rev=775079&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity2.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity2.java
Fri May 15 10:22:42 2009
@@ -0,0 +1,28 @@
+/**
+ * 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.jaxrs.fortest;
+
+import javax.ws.rs.Path;
+
+import org.apache.cxf.jaxrs.resources.Book;
+import org.apache.cxf.jaxrs.resources.Chapter;
+
+@Path("/books")
+public class BookEntity2 extends AbstractEntity2<Book, Chapter> {
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/BookEntity2.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntity.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntity.java?rev=775079&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntity.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntity.java
Fri May 15 10:22:42 2009
@@ -0,0 +1,30 @@
+/**
+ * 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.jaxrs.fortest;
+
+import javax.ws.rs.POST;
+
+
+public interface GenericEntity<T> {
+    
+    @POST
+    void postEntity(T object);
+    
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntity.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntityImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntityImpl.java?rev=775079&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntityImpl.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntityImpl.java
Fri May 15 10:22:42 2009
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.fortest;
+
+import javax.ws.rs.Path;
+
+import org.apache.cxf.jaxrs.resources.Book;
+
+@Path("/books")
+public class GenericEntityImpl implements GenericEntity<Book> {
+
+    private Book book;
+    
+    public void postEntity(Book object) {
+        book = object;
+    }
+    
+    public Book getEntity() {
+        return book;
+    }
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntityImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/fortest/GenericEntityImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=775079&r1=775078&r2=775079&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
Fri May 15 10:22:42 2009
@@ -1137,7 +1137,8 @@
                    ((ThreadLocalProxy)c.getThreadLocalServletContext()).get());
         assertSame(servletContextMock, 
                    ((ThreadLocalProxy)c.getServletContext()).get());
-        
+        assertSame(servletContextMock, 
+                   ((ThreadLocalProxy)c.getSuperServletContext()).get());
         assertSame(httpRequest, 
                    ((ThreadLocalProxy)c.getServletRequest()).get());
         HttpServletResponseFilter filter = (

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=775079&r1=775078&r2=775079&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
Fri May 15 10:22:42 2009
@@ -48,7 +48,7 @@
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerSpring.class, true));
+                   launchServer(BookServerSpring.class));
     }
     
     @Test

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=775079&r1=775078&r2=775079&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java Fri
May 15 10:22:42 2009
@@ -58,7 +58,7 @@
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerRestSoap.class, true));
+                   launchServer(BookServerRestSoap.class));
     }
     
     @Test



Mime
View raw message