You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2017/01/19 10:32:57 UTC

cxf git commit: [CXF-6881] Upgrading to a 2.1-m02 tag, to be cleaned up later

Repository: cxf
Updated Branches:
  refs/heads/master dbe536f78 -> c6d4592a8


[CXF-6881] Upgrading to a 2.1-m02 tag, to be cleaned up later


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

Branch: refs/heads/master
Commit: c6d4592a8a5d31429333c0e539ae56f517c2523f
Parents: dbe536f
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu Jan 19 10:32:39 2017 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Jan 19 10:32:39 2017 +0000

----------------------------------------------------------------------
 parent/pom.xml                                  |  2 +-
 .../org/apache/cxf/jaxrs/client/WebClient.java  | 29 +++++-----------
 .../client/spec/InvocationBuilderImpl.java      | 30 ++++++++++++++---
 .../rx/client/ObservableRxInvokerProvider.java  | 35 ++++++++++++++++++++
 .../jaxrs/reactive/JAXRSReactiveTest.java       | 10 +++---
 5 files changed, 76 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c6d4592a/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index f6efcf9..9f61f38 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -109,7 +109,7 @@
         <cxf.geronimo.transaction.version>1.1.1</cxf.geronimo.transaction.version>
         <cxf.jasypt.bundle.version>1.9.0_1</cxf.jasypt.bundle.version>
         <cxf.javassist.version>3.19.0-GA</cxf.javassist.version>
-        <cxf.javax.ws.rs.version>2.1-m01</cxf.javax.ws.rs.version>
+        <cxf.javax.ws.rs.version>2.1-m02</cxf.javax.ws.rs.version>
         <cxf.jaxb.version>2.2.11</cxf.jaxb.version>
         <cxf.jaxb.impl.version>${cxf.jaxb.version}</cxf.jaxb.impl.version>
         <cxf.jaxb.core.version>${cxf.jaxb.version}</cxf.jaxb.core.version>

http://git-wip-us.apache.org/repos/asf/cxf/blob/c6d4592a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
index 3654072..f7ed1f2 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
@@ -20,7 +20,6 @@ package org.apache.cxf.jaxrs.client;
 
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
 import java.lang.reflect.Type;
 import java.net.URI;
 import java.util.Arrays;
@@ -41,6 +40,7 @@ import javax.ws.rs.client.CompletionStageRxInvoker;
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.client.InvocationCallback;
 import javax.ws.rs.client.RxInvoker;
+import javax.ws.rs.client.RxInvokerProvider;
 import javax.ws.rs.client.SyncInvoker;
 import javax.ws.rs.core.Cookie;
 import javax.ws.rs.core.EntityTag;
@@ -1277,26 +1277,13 @@ public class WebClient extends AbstractClient implements AsyncClient {
     }
     // Link to JAX-RS 2.1 RxInvoker extensions
     @SuppressWarnings("rawtypes")
-    public <T extends RxInvoker> T rx(Class<T> clazz) {
-        return rx(clazz, (ExecutorService)null);
-    }
-    @SuppressWarnings({
-     "rawtypes", "unchecked"
-    })
-    public <T extends RxInvoker> T rx(Class<T> clazz, ExecutorService executorService) {
-        if (clazz == CompletionStageRxInvoker.class) {
-            return (T)rx(executorService);
-        } else {
-            String implClassName = clazz.getName() + "Impl";
-            try {
-                Constructor c = ClassLoaderUtils.loadClass(implClassName, WebClient.class)
-                    .getConstructor(AsyncClient.class, ExecutorService.class);
-                return (T)c.newInstance(this, executorService);
-            } catch (Throwable t) {
-                throw new ProcessingException(t);
-            }
-        }
-        
+    public <T extends RxInvoker> T rx(RxInvokerProvider<T> p) {
+        return rx(p, (ExecutorService)null);
+    }
+
+    @SuppressWarnings("rawtypes")
+    public <T extends RxInvoker> T rx(RxInvokerProvider<T> p, ExecutorService execService) {
+        return p.getRxInvoker(new InvocationBuilderImpl(this), execService);
     }
     
     private void setEntityHeaders(Entity<?> entity) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/c6d4592a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
index 75c9b85..ea84b46 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
@@ -26,6 +26,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 
 import javax.ws.rs.HttpMethod;
+import javax.ws.rs.ProcessingException;
 import javax.ws.rs.client.AsyncInvoker;
 import javax.ws.rs.client.CompletionStageRxInvoker;
 import javax.ws.rs.client.Entity;
@@ -34,6 +35,7 @@ import javax.ws.rs.client.Invocation.Builder;
 import javax.ws.rs.client.InvocationCallback;
 import javax.ws.rs.client.NioInvoker;
 import javax.ws.rs.client.RxInvoker;
+import javax.ws.rs.client.RxInvokerProvider;
 import javax.ws.rs.client.SyncInvoker;
 import javax.ws.rs.core.CacheControl;
 import javax.ws.rs.core.Cookie;
@@ -385,18 +387,38 @@ public class InvocationBuilderImpl implements Invocation.Builder {
         return webClient.rx(executorService);
     }
 
+    
     @SuppressWarnings("rawtypes")
     @Override
-    public <T extends RxInvoker> T rx(Class<T> clazz) {
-        return rx(clazz, (ExecutorService)null);
+    public <T extends RxInvoker> T rx(Class<? extends RxInvokerProvider<T>> pClass) {
+        return rx(pClass, (ExecutorService)null);
     }
 
     @SuppressWarnings("rawtypes")
     @Override
-    public <T extends RxInvoker> T rx(Class<T> clazz, ExecutorService executorService) {
-        return webClient.rx(clazz, executorService);
+    public <T extends RxInvoker> T rx(Class<? extends RxInvokerProvider<T>> pClass, ExecutorService execService) {
+        RxInvokerProvider<T> p = null;
+        try {
+            p = pClass.newInstance();
+        } catch (Throwable t) {
+            throw new ProcessingException(t);
+        }
+        return rx(p, execService);
+    }
+    
+    @SuppressWarnings("rawtypes")
+    @Override
+    public <T extends RxInvoker> T rx(RxInvokerProvider<T> p) {
+        return rx(p, (ExecutorService)null);
     }
 
+    @SuppressWarnings("rawtypes")
+    @Override
+    public <T extends RxInvoker> T rx(RxInvokerProvider<T> p, ExecutorService execService) {
+        return p.getRxInvoker(this, execService);
+    }
+    
+    
     @Override
     public NioInvoker nio() {
         // TODO: Implementation required (JAX-RS 2.1)

http://git-wip-us.apache.org/repos/asf/cxf/blob/c6d4592a/rt/rs/extensions/rx/src/main/java/org/apache/cxf/jaxrs/rx/client/ObservableRxInvokerProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/rx/src/main/java/org/apache/cxf/jaxrs/rx/client/ObservableRxInvokerProvider.java b/rt/rs/extensions/rx/src/main/java/org/apache/cxf/jaxrs/rx/client/ObservableRxInvokerProvider.java
new file mode 100644
index 0000000..100fca2
--- /dev/null
+++ b/rt/rs/extensions/rx/src/main/java/org/apache/cxf/jaxrs/rx/client/ObservableRxInvokerProvider.java
@@ -0,0 +1,35 @@
+/**
+ * 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.rx.client;
+
+import java.util.concurrent.ExecutorService;
+
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.RxInvokerProvider;
+
+import org.apache.cxf.jaxrs.client.spec.InvocationBuilderImpl;
+
+public class ObservableRxInvokerProvider implements RxInvokerProvider<ObservableRxInvoker> {
+
+    @Override
+    public ObservableRxInvoker getRxInvoker(Invocation.Builder builder, ExecutorService execService) {
+        return new ObservableRxInvokerImpl(((InvocationBuilderImpl)builder).getWebClient(), execService);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/c6d4592a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSReactiveTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSReactiveTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSReactiveTest.java
index d581bbe..ec25b17 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSReactiveTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSReactiveTest.java
@@ -24,13 +24,15 @@ import java.util.List;
 import java.util.concurrent.ExecutionException;
 
 import javax.ws.rs.NotFoundException;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
 import javax.ws.rs.core.GenericType;
 
 import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
 
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
-import org.apache.cxf.jaxrs.rx.client.ObservableRxInvoker;
+import org.apache.cxf.jaxrs.rx.client.ObservableRxInvokerProvider;
 import org.apache.cxf.jaxrs.rx.provider.ObservableReader;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
@@ -127,7 +129,7 @@ public class JAXRSReactiveTest extends AbstractBusClientServerTestBase {
         String address = "http://localhost:" + PORT + "/reactive/textAsync";
         WebClient wc = WebClient.create(address);
         Observable<String> obs = wc.accept("text/plain")
-            .rx(ObservableRxInvoker.class)
+            .rx(new ObservableRxInvokerProvider())
             .get(String.class);
         obs.map(s -> { 
             return s + s; 
@@ -140,8 +142,8 @@ public class JAXRSReactiveTest extends AbstractBusClientServerTestBase {
     @Test
     public void testGetHelloWorldAsyncObservable404() throws Exception {
         String address = "http://localhost:" + PORT + "/reactive/textAsync404";
-        WebClient wc = WebClient.create(address);
-        wc.rx(ObservableRxInvoker.class).get(String.class).subscribe(
+        Invocation.Builder b = ClientBuilder.newClient().target(address).request();
+        b.rx(ObservableRxInvokerProvider.class).get(String.class).subscribe(
             s -> {
                 fail("Exception expected");
             },