camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/8] camel git commit: Use interface instead of abstract class
Date Thu, 17 Dec 2015 07:37:54 GMT
Use interface instead of abstract class


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

Branch: refs/heads/master
Commit: 7294efba4b6be2b0ec5b531619c28a4a2de2c77b
Parents: f412a01
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Dec 17 08:12:01 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Dec 17 08:12:21 2015 +0100

----------------------------------------------------------------------
 .../camel/component/spark/ConvertingRddCallback.java  | 10 +++++-----
 .../org/apache/camel/component/spark/RddCallback.java |  4 ++--
 .../camel/component/spark/RddSparkProducer.java       |  6 +++---
 .../apache/camel/component/spark/SparkComponent.java  |  8 ++++----
 .../apache/camel/component/spark/SparkEndpoint.java   |  8 ++++----
 .../apache/camel/component/spark/VoidRddCallback.java |  6 +++---
 .../spark/annotations/AnnotatedRddCallbackProxy.java  |  7 +++----
 .../camel/component/spark/SparkProducerTest.java      | 14 +++++++-------
 8 files changed, 31 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7294efba/components/camel-spark/src/main/java/org/apache/camel/component/spark/ConvertingRddCallback.java
----------------------------------------------------------------------
diff --git a/components/camel-spark/src/main/java/org/apache/camel/component/spark/ConvertingRddCallback.java
b/components/camel-spark/src/main/java/org/apache/camel/component/spark/ConvertingRddCallback.java
index ac75f38..4d149d0 100644
--- a/components/camel-spark/src/main/java/org/apache/camel/component/spark/ConvertingRddCallback.java
+++ b/components/camel-spark/src/main/java/org/apache/camel/component/spark/ConvertingRddCallback.java
@@ -16,10 +16,10 @@
  */
 package org.apache.camel.component.spark;
 
-import static java.lang.String.format;
-
 import org.apache.camel.CamelContext;
-import org.apache.spark.api.java.AbstractJavaRDDLike;
+import org.apache.spark.api.java.JavaRDDLike;
+
+import static java.lang.String.format;
 
 public abstract class ConvertingRddCallback<T> implements RddCallback<T> {
 
@@ -33,7 +33,7 @@ public abstract class ConvertingRddCallback<T> implements RddCallback<T>
{
     }
 
     @Override
-    public T onRdd(AbstractJavaRDDLike rdd, Object... payloads) {
+    public T onRdd(JavaRDDLike rdd, Object... payloads) {
         if (payloads.length != payloadsTypes.length) {
             String message = format("Received %d payloads, but expected %d.", payloads.length,
payloadsTypes.length);
             throw new IllegalArgumentException(message);
@@ -44,6 +44,6 @@ public abstract class ConvertingRddCallback<T> implements RddCallback<T>
{
         return doOnRdd(rdd, payloads);
     }
 
-    public abstract T doOnRdd(AbstractJavaRDDLike rdd, Object... payloads);
+    public abstract T doOnRdd(JavaRDDLike rdd, Object... payloads);
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7294efba/components/camel-spark/src/main/java/org/apache/camel/component/spark/RddCallback.java
----------------------------------------------------------------------
diff --git a/components/camel-spark/src/main/java/org/apache/camel/component/spark/RddCallback.java
b/components/camel-spark/src/main/java/org/apache/camel/component/spark/RddCallback.java
index ed514b6..919956b 100644
--- a/components/camel-spark/src/main/java/org/apache/camel/component/spark/RddCallback.java
+++ b/components/camel-spark/src/main/java/org/apache/camel/component/spark/RddCallback.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.component.spark;
 
-import org.apache.spark.api.java.AbstractJavaRDDLike;
+import org.apache.spark.api.java.JavaRDDLike;
 
 /**
  * Generic block of code with parameters which can be executed against RDD and return results.
@@ -25,6 +25,6 @@ import org.apache.spark.api.java.AbstractJavaRDDLike;
  */
 public interface RddCallback<T> {
 
-    T onRdd(AbstractJavaRDDLike rdd, Object... payloads);
+    T onRdd(JavaRDDLike rdd, Object... payloads);
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7294efba/components/camel-spark/src/main/java/org/apache/camel/component/spark/RddSparkProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-spark/src/main/java/org/apache/camel/component/spark/RddSparkProducer.java
b/components/camel-spark/src/main/java/org/apache/camel/component/spark/RddSparkProducer.java
index 1977bed..9827d6f 100644
--- a/components/camel-spark/src/main/java/org/apache/camel/component/spark/RddSparkProducer.java
+++ b/components/camel-spark/src/main/java/org/apache/camel/component/spark/RddSparkProducer.java
@@ -20,8 +20,8 @@ import java.util.List;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
-import org.apache.spark.api.java.AbstractJavaRDDLike;
 import org.apache.spark.api.java.JavaRDD;
+import org.apache.spark.api.java.JavaRDDLike;
 
 import static org.apache.camel.component.spark.SparkConstants.SPARK_RDD_CALLBACK_HEADER;
 import static org.apache.camel.component.spark.SparkConstants.SPARK_RDD_HEADER;
@@ -34,7 +34,7 @@ public class RddSparkProducer extends DefaultProducer {
 
     @Override
     public void process(Exchange exchange) throws Exception {
-        AbstractJavaRDDLike rdd = resolveRdd(exchange);
+        JavaRDDLike rdd = resolveRdd(exchange);
         RddCallback rddCallback = resolveRddCallback(exchange);
         Object body = exchange.getIn().getBody();
         Object result = body instanceof List ? rddCallback.onRdd(rdd, ((List) body).toArray(new
Object[0])) : rddCallback.onRdd(rdd, body);
@@ -62,7 +62,7 @@ public class RddSparkProducer extends DefaultProducer {
         }
     }
 
-    protected AbstractJavaRDDLike resolveRdd(Exchange exchange) {
+    protected JavaRDDLike resolveRdd(Exchange exchange) {
         if (exchange.getIn().getHeader(SPARK_RDD_HEADER) != null) {
             return (JavaRDD) exchange.getIn().getHeader(SPARK_RDD_HEADER);
         } else if (getEndpoint().getRdd() != null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/7294efba/components/camel-spark/src/main/java/org/apache/camel/component/spark/SparkComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-spark/src/main/java/org/apache/camel/component/spark/SparkComponent.java
b/components/camel-spark/src/main/java/org/apache/camel/component/spark/SparkComponent.java
index b8e925e..5ea539e 100644
--- a/components/camel-spark/src/main/java/org/apache/camel/component/spark/SparkComponent.java
+++ b/components/camel-spark/src/main/java/org/apache/camel/component/spark/SparkComponent.java
@@ -20,11 +20,11 @@ import java.util.Map;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.UriEndpointComponent;
-import org.apache.spark.api.java.AbstractJavaRDDLike;
+import org.apache.spark.api.java.JavaRDDLike;
 
 public class SparkComponent extends UriEndpointComponent {
 
-    private AbstractJavaRDDLike rdd;
+    private JavaRDDLike rdd;
     private RddCallback rddCallback;
 
     public SparkComponent() {
@@ -37,14 +37,14 @@ public class SparkComponent extends UriEndpointComponent {
         return new SparkEndpoint(uri, this, type);
     }
 
-    public AbstractJavaRDDLike getRdd() {
+    public JavaRDDLike getRdd() {
         return rdd;
     }
 
     /**
      * RDD to compute against.
      */
-    public void setRdd(AbstractJavaRDDLike rdd) {
+    public void setRdd(JavaRDDLike rdd) {
         this.rdd = rdd;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7294efba/components/camel-spark/src/main/java/org/apache/camel/component/spark/SparkEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-spark/src/main/java/org/apache/camel/component/spark/SparkEndpoint.java
b/components/camel-spark/src/main/java/org/apache/camel/component/spark/SparkEndpoint.java
index 8bdb062..914bb9b 100644
--- a/components/camel-spark/src/main/java/org/apache/camel/component/spark/SparkEndpoint.java
+++ b/components/camel-spark/src/main/java/org/apache/camel/component/spark/SparkEndpoint.java
@@ -24,7 +24,7 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
-import org.apache.spark.api.java.AbstractJavaRDDLike;
+import org.apache.spark.api.java.JavaRDDLike;
 import org.apache.spark.sql.DataFrame;
 import org.slf4j.Logger;
 
@@ -46,7 +46,7 @@ public class SparkEndpoint extends DefaultEndpoint {
     @UriPath @Metadata(required = "true")
     private EndpointType endpointType;
     @UriParam
-    private AbstractJavaRDDLike rdd;
+    private JavaRDDLike rdd;
     @UriParam
     private RddCallback rddCallback;
     @UriParam
@@ -125,14 +125,14 @@ public class SparkEndpoint extends DefaultEndpoint {
         this.endpointType = endpointType;
     }
 
-    public AbstractJavaRDDLike getRdd() {
+    public JavaRDDLike getRdd() {
         return rdd;
     }
 
     /**
      * RDD to compute against.
      */
-    public void setRdd(AbstractJavaRDDLike rdd) {
+    public void setRdd(JavaRDDLike rdd) {
         this.rdd = rdd;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7294efba/components/camel-spark/src/main/java/org/apache/camel/component/spark/VoidRddCallback.java
----------------------------------------------------------------------
diff --git a/components/camel-spark/src/main/java/org/apache/camel/component/spark/VoidRddCallback.java
b/components/camel-spark/src/main/java/org/apache/camel/component/spark/VoidRddCallback.java
index 24e62bd..931c6ed 100644
--- a/components/camel-spark/src/main/java/org/apache/camel/component/spark/VoidRddCallback.java
+++ b/components/camel-spark/src/main/java/org/apache/camel/component/spark/VoidRddCallback.java
@@ -16,14 +16,14 @@
  */
 package org.apache.camel.component.spark;
 
-import org.apache.spark.api.java.AbstractJavaRDDLike;
+import org.apache.spark.api.java.JavaRDDLike;
 
 public abstract class VoidRddCallback implements RddCallback<Void> {
 
-    public abstract void doOnRdd(AbstractJavaRDDLike rdd, Object... payloads);
+    public abstract void doOnRdd(JavaRDDLike rdd, Object... payloads);
 
     @Override
-    public Void onRdd(AbstractJavaRDDLike rdd, Object... payloads) {
+    public Void onRdd(JavaRDDLike rdd, Object... payloads) {
         doOnRdd(rdd, payloads);
         return null;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/7294efba/components/camel-spark/src/main/java/org/apache/camel/component/spark/annotations/AnnotatedRddCallbackProxy.java
----------------------------------------------------------------------
diff --git a/components/camel-spark/src/main/java/org/apache/camel/component/spark/annotations/AnnotatedRddCallbackProxy.java
b/components/camel-spark/src/main/java/org/apache/camel/component/spark/annotations/AnnotatedRddCallbackProxy.java
index 5d2e9c9..66540ab 100644
--- a/components/camel-spark/src/main/java/org/apache/camel/component/spark/annotations/AnnotatedRddCallbackProxy.java
+++ b/components/camel-spark/src/main/java/org/apache/camel/component/spark/annotations/AnnotatedRddCallbackProxy.java
@@ -21,12 +21,11 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 
-import static java.util.Arrays.asList;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.component.spark.RddCallback;
-import org.apache.spark.api.java.AbstractJavaRDDLike;
+import org.apache.spark.api.java.JavaRDDLike;
 
+import static java.util.Arrays.asList;
 import static org.apache.camel.util.ObjectHelper.findMethodsWithAnnotation;
 
 class AnnotatedRddCallbackProxy implements RddCallback {
@@ -51,7 +50,7 @@ class AnnotatedRddCallbackProxy implements RddCallback {
     }
 
     @Override
-    public Object onRdd(AbstractJavaRDDLike rdd, Object... payloads) {
+    public Object onRdd(JavaRDDLike rdd, Object... payloads) {
         try {
             List<Object> arguments = new ArrayList<>(payloads.length + 1);
             arguments.add(rdd);

http://git-wip-us.apache.org/repos/asf/camel/blob/7294efba/components/camel-spark/src/test/java/org/apache/camel/component/spark/SparkProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spark/src/test/java/org/apache/camel/component/spark/SparkProducerTest.java
b/components/camel-spark/src/test/java/org/apache/camel/component/spark/SparkProducerTest.java
index 11b6451..2cf548c 100644
--- a/components/camel-spark/src/test/java/org/apache/camel/component/spark/SparkProducerTest.java
+++ b/components/camel-spark/src/test/java/org/apache/camel/component/spark/SparkProducerTest.java
@@ -27,8 +27,8 @@ import com.google.common.truth.Truth;
 import org.apache.camel.component.spark.annotations.RddCallback;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.spark.api.java.AbstractJavaRDDLike;
 import org.apache.spark.api.java.JavaRDD;
+import org.apache.spark.api.java.JavaRDDLike;
 import org.apache.spark.api.java.JavaSparkContext;
 import org.apache.spark.sql.DataFrame;
 import org.apache.spark.sql.Row;
@@ -84,7 +84,7 @@ public class SparkProducerTest extends CamelTestSupport {
 
         registry.bind("countLinesTransformation", new org.apache.camel.component.spark.RddCallback()
{
             @Override
-            public Object onRdd(AbstractJavaRDDLike rdd, Object... payloads) {
+            public Object onRdd(JavaRDDLike rdd, Object... payloads) {
                 return rdd.count();
             }
         });
@@ -97,7 +97,7 @@ public class SparkProducerTest extends CamelTestSupport {
     public void shouldExecuteRddCallback() {
         long linesCount = template.requestBodyAndHeader(sparkUri, null, SPARK_RDD_CALLBACK_HEADER,
new org.apache.camel.component.spark.RddCallback() {
             @Override
-            public Long onRdd(AbstractJavaRDDLike rdd, Object... payloads) {
+            public Long onRdd(JavaRDDLike rdd, Object... payloads) {
                 return rdd.count();
             }
         }, Long.class);
@@ -108,7 +108,7 @@ public class SparkProducerTest extends CamelTestSupport {
     public void shouldExecuteRddCallbackWithSinglePayload() {
         long linesCount = template.requestBodyAndHeader(sparkUri, 10, SPARK_RDD_CALLBACK_HEADER,
new org.apache.camel.component.spark.RddCallback() {
             @Override
-            public Long onRdd(AbstractJavaRDDLike rdd, Object... payloads) {
+            public Long onRdd(JavaRDDLike rdd, Object... payloads) {
                 return rdd.count() * (int) payloads[0];
             }
         }, Long.class);
@@ -119,7 +119,7 @@ public class SparkProducerTest extends CamelTestSupport {
     public void shouldExecuteRddCallbackWithPayloads() {
         long linesCount = template.requestBodyAndHeader(sparkUri, asList(10, 10), SPARK_RDD_CALLBACK_HEADER,
new org.apache.camel.component.spark.RddCallback() {
             @Override
-            public Long onRdd(AbstractJavaRDDLike rdd, Object... payloads) {
+            public Long onRdd(JavaRDDLike rdd, Object... payloads) {
                 return rdd.count() * (int) payloads[0] * (int) payloads[1];
             }
         }, Long.class);
@@ -130,7 +130,7 @@ public class SparkProducerTest extends CamelTestSupport {
     public void shouldExecuteRddCallbackWithTypedPayloads() {
         ConvertingRddCallback rddCallback = new ConvertingRddCallback<Long>(context,
int.class, int.class) {
             @Override
-            public Long doOnRdd(AbstractJavaRDDLike rdd, Object... payloads) {
+            public Long doOnRdd(JavaRDDLike rdd, Object... payloads) {
                 return rdd.count() * (int) payloads[0] * (int) payloads[1];
             }
         };
@@ -153,7 +153,7 @@ public class SparkProducerTest extends CamelTestSupport {
         // When
         template.sendBodyAndHeader(sparkUri, null, SPARK_RDD_CALLBACK_HEADER, new VoidRddCallback()
{
             @Override
-            public void doOnRdd(AbstractJavaRDDLike rdd, Object... payloads) {
+            public void doOnRdd(JavaRDDLike rdd, Object... payloads) {
                 rdd.saveAsTextFile(output.getAbsolutePath());
             }
         });


Mime
View raw message