[1/2] camel git commit: CAMEL-10074: ServiceCall EIP : Support caching ServerCallServerListStrategy

2016-06-20 Thread lburgazzoli
Repository: camel
Updated Branches:
  refs/heads/master ad114f957 -> 615bc2355


CAMEL-10074: ServiceCall EIP : Support caching ServerCallServerListStrategy


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

Branch: refs/heads/master
Commit: 181e8f8bf1cc4a87b96e349f5ff375e6d26a2408
Parents: ad114f9
Author: lburgazzoli 
Authored: Mon Jun 20 12:28:45 2016 +0200
Committer: lburgazzoli 
Committed: Mon Jun 20 15:57:30 2016 +0200

--
 .../CachingServiceCallServiceListStrategy.java  | 105 +++
 ...chingServiceCallServiceListStrategyTest.java |  56 ++
 2 files changed, 161 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/181e8f8b/camel-core/src/main/java/org/apache/camel/impl/remote/CachingServiceCallServiceListStrategy.java
--
diff --git 
a/camel-core/src/main/java/org/apache/camel/impl/remote/CachingServiceCallServiceListStrategy.java
 
b/camel-core/src/main/java/org/apache/camel/impl/remote/CachingServiceCallServiceListStrategy.java
new file mode 100644
index 000..1ad9b74
--- /dev/null
+++ 
b/camel-core/src/main/java/org/apache/camel/impl/remote/CachingServiceCallServiceListStrategy.java
@@ -0,0 +1,105 @@
+/**
+ * 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.camel.impl.remote;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.spi.ServiceCallServer;
+import org.apache.camel.spi.ServiceCallServerListStrategy;
+import org.apache.camel.util.ObjectHelper;
+
+public class CachingServiceCallServiceListStrategy implements ServiceCallServerListStrategy {
+private final ServiceCallServerListStrategy delegate;
+private List servers;
+private long lastUpdate;
+private long timeout;
+
+public 
CachingServiceCallServiceListStrategy(ServiceCallServerListStrategy 
delegate) {
+this.delegate = ObjectHelper.notNull(delegate, "delegate");
+this.lastUpdate = 0;
+this.servers = Collections.emptyList();
+this.timeout = 60 * 1000; // 1 min;
+}
+
+public void setTimeout(long timeout) {
+this.timeout = timeout;
+}
+
+public void setTimeout(long timeout, TimeUnit unit) {
+this.timeout = unit.toMillis(timeout);
+}
+
+public long getTimeout() {
+return timeout;
+}
+
+public CachingServiceCallServiceListStrategy timeout(long timeout) {
+setTimeout(timeout);
+return this;
+}
+
+public CachingServiceCallServiceListStrategy timeout(long timeout, 
TimeUnit unit) {
+setTimeout(timeout, unit);
+return this;
+}
+
+@Override
+public List getInitialListOfServers(String name) {
+return delegate.getInitialListOfServers(name);
+}
+
+@Override
+public List getUpdatedListOfServers(String name) {
+long now = System.currentTimeMillis();
+
+if (lastUpdate == 0 || now > lastUpdate + timeout) {
+List updatedList = delegate.getUpdatedListOfServers(name);
+if (updatedList.isEmpty()) {
+servers = Collections.emptyList();
+} else {
+// List is copied as the delegated 
ServiceCallServerListStrategy
+// may update the list
+servers = Collections.unmodifiableList(new 
ArrayList<>(updatedList));
+}
+
+lastUpdate = now;
+}
+
+return servers;
+}
+
+// **
+// Helpers
+// **
+
+public static  
CachingServiceCallServiceListStrategy wrap(ServiceCallServerListStrategy 
delegate) {
+return new CachingServiceCallServiceListStrategy<>(delegate);
+}
+
+public static  

[3/5] camel git commit: fix another non-cs style check

2016-06-20 Thread ay
fix another non-cs style check


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

Branch: refs/heads/camel-2.17.x
Commit: 37ea74f9411ea82dfb2c8c25879c8d9364107132
Parents: 6b1557e
Author: Akitoshi Yoshida 
Authored: Sat Jun 18 19:48:17 2016 +0200
Committer: Akitoshi Yoshida 
Committed: Mon Jun 20 09:51:38 2016 +0200

--
 .../java/org/apache/camel/converter/jaxp/StaxConverterTest.java | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/37ea74f9/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
--
diff --git 
a/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
 
b/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
index 10e916e..e34a3dc 100644
--- 
a/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
@@ -16,7 +16,10 @@
  */
 package org.apache.camel.converter.jaxp;
 
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Reader;
+import java.io.StringReader;
 import java.nio.charset.Charset;
 import java.util.Arrays;
 



[4/5] camel git commit: fix the previos style check

2016-06-20 Thread ay
fix the previos style check


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

Branch: refs/heads/camel-2.17.x
Commit: 04c2bf318078d9da0b362d407ff87b225b44268d
Parents: 37ea74f
Author: Akitoshi Yoshida 
Authored: Sat Jun 18 20:09:33 2016 +0200
Committer: Akitoshi Yoshida 
Committed: Mon Jun 20 09:52:11 2016 +0200

--
 .../java/org/apache/camel/converter/jaxp/StaxConverterTest.java| 2 ++
 1 file changed, 2 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/04c2bf31/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
--
diff --git 
a/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
 
b/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
index e34a3dc..632494d 100644
--- 
a/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
@@ -18,6 +18,8 @@ package org.apache.camel.converter.jaxp;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.Reader;
 import java.io.StringReader;
 import java.nio.charset.Charset;



[2/5] camel git commit: fix CS for CAMEL-10070

2016-06-20 Thread ay
fix CS for CAMEL-10070


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

Branch: refs/heads/camel-2.17.x
Commit: 6b1557ef1208bdefeeb3bc46041ab9d60b070fb2
Parents: 47c3f90
Author: Akitoshi Yoshida 
Authored: Sat Jun 18 19:35:54 2016 +0200
Committer: Akitoshi Yoshida 
Committed: Mon Jun 20 09:51:09 2016 +0200

--
 .../apache/camel/converter/jaxp/XMLStreamReaderInputStream.java  | 4 ++--
 .../org/apache/camel/converter/jaxp/XMLStreamReaderReader.java   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/6b1557ef/camel-core/src/main/java/org/apache/camel/converter/jaxp/XMLStreamReaderInputStream.java
--
diff --git 
a/camel-core/src/main/java/org/apache/camel/converter/jaxp/XMLStreamReaderInputStream.java
 
b/camel-core/src/main/java/org/apache/camel/converter/jaxp/XMLStreamReaderInputStream.java
index 1e3158f..96783d4 100644
--- 
a/camel-core/src/main/java/org/apache/camel/converter/jaxp/XMLStreamReaderInputStream.java
+++ 
b/camel-core/src/main/java/org/apache/camel/converter/jaxp/XMLStreamReaderInputStream.java
@@ -39,7 +39,7 @@ class XMLStreamReaderInputStream extends InputStream {
 private String charset;
 private int bpos;
 
-public XMLStreamReaderInputStream(XMLStreamReader reader, String charset, 
XMLOutputFactory outfactory) {
+XMLStreamReaderInputStream(XMLStreamReader reader, String charset, 
XMLOutputFactory outfactory) {
 this.reader = reader;
 this.buffer = new byte[BUFFER_SIZE];
 this.chunk = new TrimmableByteArrayOutputStream();
@@ -51,7 +51,7 @@ class XMLStreamReaderInputStream extends InputStream {
 }
 }
 
-public XMLStreamReaderInputStream(XMLStreamReader reader, XMLOutputFactory 
outfactory) {
+XMLStreamReaderInputStream(XMLStreamReader reader, XMLOutputFactory 
outfactory) {
 this(reader, "utf-8", outfactory);
 }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/6b1557ef/camel-core/src/main/java/org/apache/camel/converter/jaxp/XMLStreamReaderReader.java
--
diff --git 
a/camel-core/src/main/java/org/apache/camel/converter/jaxp/XMLStreamReaderReader.java
 
b/camel-core/src/main/java/org/apache/camel/converter/jaxp/XMLStreamReaderReader.java
index 571c21b..207f273 100644
--- 
a/camel-core/src/main/java/org/apache/camel/converter/jaxp/XMLStreamReaderReader.java
+++ 
b/camel-core/src/main/java/org/apache/camel/converter/jaxp/XMLStreamReaderReader.java
@@ -38,7 +38,7 @@ class XMLStreamReaderReader extends Reader {
 private char[] buffer;
 private int bpos;
 
-public XMLStreamReaderReader(XMLStreamReader reader, XMLOutputFactory 
outfactory) {
+XMLStreamReaderReader(XMLStreamReader reader, XMLOutputFactory outfactory) 
{
 this.reader = reader;
 this.buffer = new char[BUFFER_SIZE];
 this.chunk = new TrimmableCharArrayWriter();



[5/5] camel git commit: adjust CAMEL-10070's test to use the matching quote character

2016-06-20 Thread ay
adjust CAMEL-10070's test to use the matching quote character


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

Branch: refs/heads/camel-2.17.x
Commit: 33048a86afc6fda76d9103759cea1cb8f66c3040
Parents: 04c2bf3
Author: Akitoshi Yoshida 
Authored: Sat Jun 18 20:57:40 2016 +0200
Committer: Akitoshi Yoshida 
Committed: Mon Jun 20 09:52:37 2016 +0200

--
 .../java/org/apache/camel/converter/jaxp/StaxConverterTest.java   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/33048a86/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
--
diff --git 
a/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
 
b/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
index 632494d..9a71bc1 100644
--- 
a/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/converter/jaxp/StaxConverterTest.java
@@ -54,7 +54,8 @@ public class StaxConverterTest extends ContextTestSupport {
 
 static {
 StringBuilder sb = new StringBuilder(7000);
-sb.append("").append("");
+// using quote character to make the plain characters comparison work 
with the generated xml
+sb.append("").append("");
 int n = 6963 - TEST_XML.length();
 while (n > 0) {
 sb.append(TEST_XML);