cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5910] Using a more specific name binding for DynamicFeature
Date Wed, 30 Jul 2014 11:55:54 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes d0829ff3d -> 422c8814c


[CXF-5910] Using a more specific name binding for DynamicFeature


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/422c8814
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/422c8814
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/422c8814

Branch: refs/heads/3.0.x-fixes
Commit: 422c8814c715f99d5a663e29030e1f7e66b842c1
Parents: d0829ff
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jul 30 14:53:39 2014 +0300
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jul 30 14:55:23 2014 +0300

----------------------------------------------------------------------
 .../jaxrs/provider/ServerProviderFactory.java   |  2 +-
 .../apache/cxf/systest/jaxrs/BookServer20.java  | 20 ++++++++++++++++++++
 .../org/apache/cxf/systest/jaxrs/BookStore.java |  7 ++++++-
 .../jaxrs/JAXRS20ClientServerBookTest.java      | 18 ++++++++++++++++++
 4 files changed, 45 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/422c8814/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
index d04272a..d9ad37a 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
@@ -374,7 +374,7 @@ public final class ServerProviderFactory extends ProviderFactory {
             nameBinding = DEFAULT_FILTER_NAME_BINDING 
                 + ori.getClassResourceInfo().getServiceClass().getName()
                 + "."
-                + ori.getMethodToInvoke().getName();
+                + ori.getMethodToInvoke().toString();
         }
         
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/422c8814/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
index 03c1cca..15870bf 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
@@ -27,6 +27,7 @@ import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
+import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 import java.net.URI;
 import java.util.ArrayList;
@@ -352,6 +353,18 @@ public class BookServer20 extends AbstractBusTestServerBase {
         }
         
     }
+    public static class PostMatchDynamicEchoBookFilter implements ContainerResponseFilter
{
+        private int supplement;
+        public PostMatchDynamicEchoBookFilter(int supplement) {
+            this.supplement = supplement;
+        }
+        @Override
+        public void filter(ContainerRequestContext requestContext,
+                           ContainerResponseContext responseContext) throws IOException {
+            Book book = (Book)responseContext.getEntity();
+            responseContext.setEntity(new Book(book.getName(), book.getId() + supplement));
+        }
+    }
     
     @Priority(2)
     public static class PostMatchDynamicContainerResponseFilter 
@@ -471,6 +484,13 @@ public class BookServer20 extends AbstractBusTestServerBase {
             contracts.put(ContainerResponseFilter.class, 2);
             configurable.register(new PostMatchDynamicContainerRequestResponseFilter(), 
                                   contracts);
+            Method m = resourceInfo.getResourceMethod();
+            if ("echoBookElement".equals(m.getName())) {
+                Class<?> paramType = m.getParameterTypes()[0];
+                if (paramType == Book.class) {
+                    configurable.register(new PostMatchDynamicEchoBookFilter(2));
+                }
+            }
         }
         
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/422c8814/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
index c724269..e0c5f5e 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
@@ -1016,10 +1016,15 @@ public class BookStore {
     public JAXBElement<Book> echoBookElement(JAXBElement<Book> element) throws
Exception {
         return element;
     }
+    @POST
+    @Path("/books/echo")
+    public Book echoBookElement(Book element) throws Exception {
+        return element;
+    }
     
     @SuppressWarnings("unchecked")
     @POST
-    @Path("/books/element/echo")
+    @Path("/books/element/echo/wildcard")
     public JAXBElement<? super Book> echoBookElementWildcard(JAXBElement<? extends
Book> element) 
         throws Exception {
         return (JAXBElement<? super Book>)element;

http://git-wip-us.apache.org/repos/asf/cxf/blob/422c8814/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
index b19e903..948922a 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
@@ -50,8 +50,11 @@ import javax.ws.rs.ext.ReaderInterceptor;
 import javax.ws.rs.ext.ReaderInterceptorContext;
 import javax.ws.rs.ext.WriterInterceptor;
 import javax.ws.rs.ext.WriterInterceptorContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
 import javax.xml.ws.Holder;
 
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
 import org.apache.cxf.systest.jaxrs.BookStore.BookInfo;
@@ -79,6 +82,21 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
     }
     
     @Test
+    public void testEchoBookElement() throws Exception {
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
+        JAXBElement<Book> element = store.echoBookElement(new JAXBElement<Book>(new
QName("", "Book"),
+                                     Book.class,
+                                     new Book("CXF", 123L)));
+        Book book = element.getValue();
+        assertEquals(123L, book.getId());
+        assertEquals("CXF", book.getName());
+        
+        Book book2 = store.echoBookElement(new Book("CXF3", 128L));
+        assertEquals(130L, book2.getId());
+        assertEquals("CXF3", book2.getName());
+    }
+    
+    @Test
     public void testGetGenericBook() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/genericbooks/123";
         doTestGetGenericBook(address, 124L, false);


Mime
View raw message