cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6833] Moving Observable providers to rt/rs/extension/providers
Date Wed, 04 May 2016 10:57:45 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 8f9ae274a -> 447f2dac6


[CXF-6833] Moving Observable providers to rt/rs/extension/providers


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

Branch: refs/heads/master
Commit: 447f2dac6e160b5cd495558ca8855ed481396c63
Parents: 8f9ae27
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed May 4 11:57:30 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed May 4 11:57:30 2016 +0100

----------------------------------------------------------------------
 parent/pom.xml                                  |  1 +
 rt/rs/extensions/providers/pom.xml              |  7 ++
 .../cxf/jaxrs/provider/rx/ObservableReader.java | 61 ++++++++++++++
 .../cxf/jaxrs/provider/rx/ObservableWriter.java | 84 ++++++++++++++++++++
 systests/jaxrs/pom.xml                          |  2 +-
 .../jaxrs/reactive/JAXRSReactiveTest.java       |  3 +-
 .../jaxrs/reactive/ObservableReader.java        | 61 --------------
 .../jaxrs/reactive/ObservableWriter.java        | 84 --------------------
 .../systest/jaxrs/reactive/ReactiveServer.java  |  1 +
 9 files changed, 157 insertions(+), 147 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/447f2dac/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 0a17062..339299d 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -97,6 +97,7 @@
         <cxf.log4j.version>1.2.17</cxf.log4j.version>
         <cxf.lucene.version>4.9.0</cxf.lucene.version>
         <cxf.mina.version>2.0.13</cxf.mina.version>
+        <cxf.rx.java.version>1.1.3</cxf.rx.java.version>
         <cxf.javax.annotation-api.version>1.2</cxf.javax.annotation-api.version>
         <cxf.geronimo.jms.version>1.1.1</cxf.geronimo.jms.version>
         <cxf.geronimo.j2ee.management.version>1.0.1</cxf.geronimo.j2ee.management.version>

http://git-wip-us.apache.org/repos/asf/cxf/blob/447f2dac/rt/rs/extensions/providers/pom.xml
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/pom.xml b/rt/rs/extensions/providers/pom.xml
index b379e7c..e37182c 100644
--- a/rt/rs/extensions/providers/pom.xml
+++ b/rt/rs/extensions/providers/pom.xml
@@ -120,6 +120,13 @@
             <optional>true</optional>
         </dependency>     
         <dependency>
+          <groupId>io.reactivex</groupId>
+          <artifactId>rxjava</artifactId>
+          <version>${cxf.rx.java.version}</version>
+          <scope>provided</scope>
+          <optional>true</optional>
+        </dependency>
+        <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-bindings-soap</artifactId>
             <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/cxf/blob/447f2dac/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/rx/ObservableReader.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/rx/ObservableReader.java
b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/rx/ObservableReader.java
new file mode 100644
index 0000000..8a63311
--- /dev/null
+++ b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/rx/ObservableReader.java
@@ -0,0 +1,61 @@
+/**
+ * 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.provider.rx;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.ProcessingException;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Providers;
+
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
+
+import rx.Observable;
+
+public class ObservableReader<T> implements MessageBodyReader<Observable<T>>
{
+    
+    @Context
+    private Providers providers;
+    
+    @Override
+    public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType
arg3) {
+        return true;
+    }
+
+    @Override
+    public Observable<T> readFrom(Class<Observable<T>> cls, Type t, Annotation[]
anns, MediaType mt,
+                                  MultivaluedMap<String, String> headers, InputStream
is)
+                                      throws IOException, WebApplicationException {
+        @SuppressWarnings("unchecked")
+        Class<T> actualCls = (Class<T>)InjectionUtils.getActualType(t);
+        final MessageBodyReader<T> mbr = 
+            (MessageBodyReader<T>)providers.getMessageBodyReader(actualCls, actualCls,
anns, mt);
+        if (mbr == null) {
+            throw new ProcessingException("MBR is null");
+        }
+        return Observable.just(mbr.readFrom(actualCls, actualCls, anns, mt, headers, is));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/447f2dac/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/rx/ObservableWriter.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/rx/ObservableWriter.java
b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/rx/ObservableWriter.java
new file mode 100644
index 0000000..929709b
--- /dev/null
+++ b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/rx/ObservableWriter.java
@@ -0,0 +1,84 @@
+/**
+ * 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.provider.rx;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Providers;
+
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
+
+import rx.Observable;
+
+public class ObservableWriter<T> implements MessageBodyWriter<Observable<T>>
{
+    
+    @Context
+    private Providers providers;
+    
+    @Override
+    public long getSize(Observable<T> arg0, Class<?> arg1, Type arg2, Annotation[]
arg3, MediaType arg4) {
+        // TODO Auto-generated method stub
+        return -1;
+    }
+
+    @Override
+    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType
arg3) {
+        return true;
+    }
+
+    @Override
+    public void writeTo(Observable<T> obs, Class<?> cls, Type t, Annotation[]
anns, MediaType mt,
+                        MultivaluedMap<String, Object> headers, OutputStream os)
+                            throws IOException, WebApplicationException {
+        obs.subscribe(value -> writeToOutputStream(value, anns, mt, headers, os),
+            throwable -> throwError(throwable));   
+    }
+
+    private void writeToOutputStream(T value,
+                                     Annotation[] anns,
+                                     MediaType mt,
+                                     MultivaluedMap<String, Object> headers, 
+                                     OutputStream os) {
+        @SuppressWarnings("unchecked")
+        MessageBodyWriter<T> writer = 
+            (MessageBodyWriter<T>)providers.getMessageBodyWriter(value.getClass(),
value.getClass(), anns, mt);
+        if (writer == null) {
+            throwError(null);
+        }
+    
+        try {
+            writer.writeTo(value, value.getClass(), value.getClass(), anns, mt, headers,
os);    
+        } catch (IOException ex) {
+            throwError(ex);
+        }
+    }
+    
+    private static void throwError(Throwable cause) {
+        throw ExceptionUtils.toInternalServerErrorException(cause, null);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/447f2dac/systests/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/pom.xml b/systests/jaxrs/pom.xml
index 034b5f3..c15ec56 100644
--- a/systests/jaxrs/pom.xml
+++ b/systests/jaxrs/pom.xml
@@ -85,7 +85,7 @@
         <dependency>
           <groupId>io.reactivex</groupId>
           <artifactId>rxjava</artifactId>
-          <version>1.1.3</version>
+          <version>${cxf.rx.java.version}</version>
         </dependency>
         <!--
           <dependency>

http://git-wip-us.apache.org/repos/asf/cxf/blob/447f2dac/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 4a0e708..535831d 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
@@ -19,18 +19,19 @@
 
 package org.apache.cxf.systest.jaxrs.reactive;
 
+import java.util.Collections;
 import java.util.concurrent.Future;
 
 import javax.ws.rs.core.GenericType;
 
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
+import org.apache.cxf.jaxrs.provider.rx.ObservableReader;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import edu.emory.mathcs.backport.java.util.Collections;
 import rx.Observable;
 
 public class JAXRSReactiveTest extends AbstractBusClientServerTestBase {

http://git-wip-us.apache.org/repos/asf/cxf/blob/447f2dac/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ObservableReader.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ObservableReader.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ObservableReader.java
deleted file mode 100644
index fada83f..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ObservableReader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.systest.jaxrs.reactive;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyReader;
-import javax.ws.rs.ext.Providers;
-
-import org.apache.cxf.jaxrs.utils.InjectionUtils;
-
-import rx.Observable;
-
-public class ObservableReader<T> implements MessageBodyReader<Observable<T>>
{
-    
-    @Context
-    private Providers providers;
-    
-    @Override
-    public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType
arg3) {
-        return true;
-    }
-
-    @Override
-    public Observable<T> readFrom(Class<Observable<T>> cls, Type t, Annotation[]
anns, MediaType mt,
-                                  MultivaluedMap<String, String> headers, InputStream
is)
-                                      throws IOException, WebApplicationException {
-        @SuppressWarnings("unchecked")
-        Class<T> actualCls = (Class<T>)InjectionUtils.getActualType(t);
-        final MessageBodyReader<T> mbr = 
-            (MessageBodyReader<T>)providers.getMessageBodyReader(actualCls, actualCls,
anns, mt);
-        if (mbr == null) {
-            throw new ProcessingException("MBR is null");
-        }
-        return Observable.just(mbr.readFrom(actualCls, actualCls, anns, mt, headers, is));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/447f2dac/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ObservableWriter.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ObservableWriter.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ObservableWriter.java
deleted file mode 100644
index b6fc869..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ObservableWriter.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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.systest.jaxrs.reactive;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.Providers;
-
-import org.apache.cxf.jaxrs.utils.ExceptionUtils;
-
-import rx.Observable;
-
-public class ObservableWriter<T> implements MessageBodyWriter<Observable<T>>
{
-    
-    @Context
-    private Providers providers;
-    
-    @Override
-    public long getSize(Observable<T> arg0, Class<?> arg1, Type arg2, Annotation[]
arg3, MediaType arg4) {
-        // TODO Auto-generated method stub
-        return -1;
-    }
-
-    @Override
-    public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType
arg3) {
-        return true;
-    }
-
-    @Override
-    public void writeTo(Observable<T> obs, Class<?> cls, Type t, Annotation[]
anns, MediaType mt,
-                        MultivaluedMap<String, Object> headers, OutputStream os)
-                            throws IOException, WebApplicationException {
-        obs.subscribe(value -> writeToOutputStream(value, anns, mt, headers, os),
-            throwable -> throwError(throwable));   
-    }
-
-    private void writeToOutputStream(T value,
-                                     Annotation[] anns,
-                                     MediaType mt,
-                                     MultivaluedMap<String, Object> headers, 
-                                     OutputStream os) {
-        @SuppressWarnings("unchecked")
-        MessageBodyWriter<T> writer = 
-            (MessageBodyWriter<T>)providers.getMessageBodyWriter(value.getClass(),
value.getClass(), anns, mt);
-        if (writer == null) {
-            throwError(null);
-        }
-    
-        try {
-            writer.writeTo(value, value.getClass(), value.getClass(), anns, mt, headers,
os);    
-        } catch (IOException ex) {
-            throwError(ex);
-        }
-    }
-    
-    private static void throwError(Throwable cause) {
-        throw ExceptionUtils.toInternalServerErrorException(cause, null);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/447f2dac/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveServer.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveServer.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveServer.java
index aee7e1b..09cbecc 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveServer.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveServer.java
@@ -25,6 +25,7 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.jaxrs.provider.rx.ObservableWriter;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
     
 public class ReactiveServer extends AbstractBusTestServerBase {


Mime
View raw message