You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/03/19 08:28:48 UTC
[1/3] camel git commit: CAMEL-8512: Simple - Add exchange as function
to access the exchange easily
Repository: camel
Updated Branches:
refs/heads/camel-2.15.x 2eaeaee25 -> b8ecc4abc
refs/heads/master c6b570e9a -> 897c4167a
CAMEL-8512: Simple - Add exchange as function to access the exchange easily
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6d23c13c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6d23c13c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6d23c13c
Branch: refs/heads/master
Commit: 6d23c13c5d01d6d314c94a0d015a884507c52e16
Parents: c6b570e
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Mar 19 08:01:41 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Mar 19 08:29:57 2015 +0100
----------------------------------------------------------------------
.../apache/camel/builder/ExpressionBuilder.java | 21 +++++++++++++++++++-
.../simple/ast/SimpleFunctionExpression.java | 12 +++++++++++
.../camel/language/simple/SimpleTest.java | 17 ++++++++++++++++
3 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6d23c13c/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index c22ad80..98b6087 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -877,7 +877,7 @@ public final class ExpressionBuilder {
* Returns the expression for the exchanges camelContext invoking methods defined
* in a simple OGNL notation
*
- * @param ognl methods to invoke on the body in a simple OGNL syntax
+ * @param ognl methods to invoke on the context in a simple OGNL syntax
*/
public static Expression camelContextOgnlExpression(final String ognl) {
return new ExpressionAdapter() {
@@ -897,6 +897,25 @@ public final class ExpressionBuilder {
}
/**
+ * Returns the expression for the exchange invoking methods defined
+ * in a simple OGNL notation
+ *
+ * @param ognl methods to invoke on the exchange in a simple OGNL syntax
+ */
+ public static Expression exchangeOgnlExpression(final String ognl) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return new MethodCallExpression(exchange, ognl).evaluate(exchange);
+ }
+
+ @Override
+ public String toString() {
+ return "exchangeOgnl(" + ognl + ")";
+ }
+ };
+ }
+
+ /**
* Returns the expression for the exchanges inbound message body converted
* to the given type
*/
http://git-wip-us.apache.org/repos/asf/camel/blob/6d23c13c/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java b/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
index d05356d..8d10ca7 100644
--- a/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
+++ b/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
@@ -128,6 +128,16 @@ public class SimpleFunctionExpression extends LiteralExpression {
return ExpressionBuilder.systemEnvironmentExpression(remainder);
}
+ // exchange OGNL
+ remainder = ifStartsWithReturnRemainder("exchange", function);
+ if (remainder != null) {
+ boolean invalid = OgnlHelper.isInvalidValidOgnlExpression(remainder);
+ if (invalid) {
+ throw new SimpleParserException("Valid syntax: ${exchange.OGNL} was: " + function, token.getIndex());
+ }
+ return ExpressionBuilder.exchangeOgnlExpression(remainder);
+ }
+
// file: prefix
remainder = ifStartsWithReturnRemainder("file:", function);
if (remainder != null) {
@@ -324,6 +334,8 @@ public class SimpleFunctionExpression extends LiteralExpression {
return ExpressionBuilder.messageIdExpression();
} else if (ObjectHelper.equal(expression, "exchangeId")) {
return ExpressionBuilder.exchangeIdExpression();
+ } else if (ObjectHelper.equal(expression, "exchange")) {
+ return ExpressionBuilder.exchangeExpression();
} else if (ObjectHelper.equal(expression, "exception")) {
return ExpressionBuilder.exchangeExceptionExpression();
} else if (ObjectHelper.equal(expression, "exception.message")) {
http://git-wip-us.apache.org/repos/asf/camel/blob/6d23c13c/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index cce849d..351efec 100644
--- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -125,6 +125,23 @@ public class SimpleTest extends LanguageTestSupport {
}
}
+ public void testExchangeExpression() throws Exception {
+ Expression exp = SimpleLanguage.simple("${exchange}");
+ assertNotNull(exp);
+ assertEquals(exchange, exp.evaluate(exchange, Object.class));
+
+ assertExpression("exchange", exchange);
+ }
+
+ public void testExchangeOgnlExpression() throws Exception {
+ Expression exp = SimpleLanguage.simple("${exchange.exchangeId}");
+ assertNotNull(exp);
+ assertEquals(exchange.getExchangeId(), exp.evaluate(exchange, Object.class));
+
+ assertExpression("exchange.exchangeId", exchange.getExchangeId());
+ assertExpression("exchange.class.name", "org.apache.camel.impl.DefaultExchange");
+ }
+
public void testBodyExpression() throws Exception {
Expression exp = SimpleLanguage.simple("${body}");
assertNotNull(exp);
[3/3] camel git commit: CAMEL-8513: Add option to use a larger buffer
size so download is faster
Posted by da...@apache.org.
CAMEL-8513: Add option to use a larger buffer size so download is faster
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b8ecc4ab
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b8ecc4ab
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b8ecc4ab
Branch: refs/heads/camel-2.15.x
Commit: b8ecc4abc678e63bbcc5bef5ee473612efb43ce8
Parents: 2eaeaee
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Mar 19 08:28:27 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Mar 19 08:30:41 2015 +0100
----------------------------------------------------------------------
.../camel/component/file/remote/FtpEndpoint.java | 10 ++++++++--
.../camel/component/file/remote/FtpsEndpoint.java | 12 +++++++++---
.../file/remote/RemoteFileConfiguration.java | 15 +++++++++++++++
3 files changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b8ecc4ab/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
index f3961b4..b650f3a 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
@@ -87,6 +87,10 @@ public class FtpEndpoint<T extends FTPFile> extends RemoteFileEndpoint<FTPFile>
client = createFtpClient();
}
+ // use configured buffer size which is larger and therefore faster (as the default is no buffer)
+ if (getConfiguration().getReceiveBufferSize() > 0) {
+ client.setBufferSize(getConfiguration().getReceiveBufferSize());
+ }
// set any endpoint configured timeouts
if (getConfiguration().getConnectTimeout() > -1) {
client.setConnectTimeout(getConfiguration().getConnectTimeout());
@@ -126,8 +130,10 @@ public class FtpEndpoint<T extends FTPFile> extends RemoteFileEndpoint<FTPFile>
}
if (log.isDebugEnabled()) {
- log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}]: {}",
- new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client});
+ log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}, bufferSize: {}"
+ + ", receiveDataSocketBufferSize: {}, sendDataSocketBufferSize: {}]: {}",
+ new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client.getBufferSize(),
+ client.getReceiveDataSocketBufferSize(), client.getSendDataSocketBufferSize(), client});
}
FtpOperations operations = new FtpOperations(client, getFtpClientConfig());
http://git-wip-us.apache.org/repos/asf/camel/blob/b8ecc4ab/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
index 53f7bc7..471eaee 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
@@ -136,7 +136,7 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
client.setTrustManager(trustMgrFactory.getTrustManagers()[0]);
}
}
-
+
return client;
}
@@ -150,6 +150,10 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
client = (FTPSClient) createFtpClient();
}
+ // use configured buffer size which is larger and therefore faster (as the default is no buffer)
+ if (getConfiguration().getReceiveBufferSize() > 0) {
+ client.setBufferSize(getConfiguration().getReceiveBufferSize());
+ }
// set any endpoint configured timeouts
if (getConfiguration().getConnectTimeout() > -1) {
client.setConnectTimeout(getConfiguration().getConnectTimeout());
@@ -188,8 +192,10 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
}
if (log.isDebugEnabled()) {
- log.debug("Created FTPSClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}]: {}",
- new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client});
+ log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}, bufferSize: {}"
+ + ", receiveDataSocketBufferSize: {}, sendDataSocketBufferSize: {}]: {}",
+ new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client.getBufferSize(),
+ client.getReceiveDataSocketBufferSize(), client.getSendDataSocketBufferSize(), client});
}
FtpsOperations operations = new FtpsOperations(client, getFtpClientConfig());
http://git-wip-us.apache.org/repos/asf/camel/blob/b8ecc4ab/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
index bc8f89b..b2a9958 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
@@ -60,6 +60,8 @@ public abstract class RemoteFileConfiguration extends GenericFileConfiguration {
private int timeout = 30000;
@UriParam
private int soTimeout;
+ @UriParam(defaultValue = "32768")
+ private int receiveBufferSize = 32 * 1024;
@UriParam
private boolean throwExceptionOnConnectFailed;
@UriParam
@@ -253,6 +255,19 @@ public abstract class RemoteFileConfiguration extends GenericFileConfiguration {
this.soTimeout = soTimeout;
}
+ public int getReceiveBufferSize() {
+ return receiveBufferSize;
+ }
+
+ /**
+ * The receive (download) buffer size
+ * <p/>
+ * Used only by FTPClient
+ */
+ public void setReceiveBufferSize(int receiveBufferSize) {
+ this.receiveBufferSize = receiveBufferSize;
+ }
+
public boolean isThrowExceptionOnConnectFailed() {
return throwExceptionOnConnectFailed;
}
[2/3] camel git commit: CAMEL-8513: Add option to use a larger buffer
size so download is faster
Posted by da...@apache.org.
CAMEL-8513: Add option to use a larger buffer size so download is faster
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/897c4167
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/897c4167
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/897c4167
Branch: refs/heads/master
Commit: 897c4167a0c26cceea469e5117ccb38f4c652694
Parents: 6d23c13
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Mar 19 08:28:27 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Mar 19 08:29:58 2015 +0100
----------------------------------------------------------------------
.../camel/component/file/remote/FtpEndpoint.java | 10 ++++++++--
.../camel/component/file/remote/FtpsEndpoint.java | 12 +++++++++---
.../file/remote/RemoteFileConfiguration.java | 15 +++++++++++++++
3 files changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/897c4167/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
index f3961b4..b650f3a 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
@@ -87,6 +87,10 @@ public class FtpEndpoint<T extends FTPFile> extends RemoteFileEndpoint<FTPFile>
client = createFtpClient();
}
+ // use configured buffer size which is larger and therefore faster (as the default is no buffer)
+ if (getConfiguration().getReceiveBufferSize() > 0) {
+ client.setBufferSize(getConfiguration().getReceiveBufferSize());
+ }
// set any endpoint configured timeouts
if (getConfiguration().getConnectTimeout() > -1) {
client.setConnectTimeout(getConfiguration().getConnectTimeout());
@@ -126,8 +130,10 @@ public class FtpEndpoint<T extends FTPFile> extends RemoteFileEndpoint<FTPFile>
}
if (log.isDebugEnabled()) {
- log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}]: {}",
- new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client});
+ log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}, bufferSize: {}"
+ + ", receiveDataSocketBufferSize: {}, sendDataSocketBufferSize: {}]: {}",
+ new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client.getBufferSize(),
+ client.getReceiveDataSocketBufferSize(), client.getSendDataSocketBufferSize(), client});
}
FtpOperations operations = new FtpOperations(client, getFtpClientConfig());
http://git-wip-us.apache.org/repos/asf/camel/blob/897c4167/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
index 53f7bc7..471eaee 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
@@ -136,7 +136,7 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
client.setTrustManager(trustMgrFactory.getTrustManagers()[0]);
}
}
-
+
return client;
}
@@ -150,6 +150,10 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
client = (FTPSClient) createFtpClient();
}
+ // use configured buffer size which is larger and therefore faster (as the default is no buffer)
+ if (getConfiguration().getReceiveBufferSize() > 0) {
+ client.setBufferSize(getConfiguration().getReceiveBufferSize());
+ }
// set any endpoint configured timeouts
if (getConfiguration().getConnectTimeout() > -1) {
client.setConnectTimeout(getConfiguration().getConnectTimeout());
@@ -188,8 +192,10 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
}
if (log.isDebugEnabled()) {
- log.debug("Created FTPSClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}]: {}",
- new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client});
+ log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}, bufferSize: {}"
+ + ", receiveDataSocketBufferSize: {}, sendDataSocketBufferSize: {}]: {}",
+ new Object[]{client.getConnectTimeout(), getSoTimeout(), dataTimeout, client.getBufferSize(),
+ client.getReceiveDataSocketBufferSize(), client.getSendDataSocketBufferSize(), client});
}
FtpsOperations operations = new FtpsOperations(client, getFtpClientConfig());
http://git-wip-us.apache.org/repos/asf/camel/blob/897c4167/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
index bc8f89b..b2a9958 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
@@ -60,6 +60,8 @@ public abstract class RemoteFileConfiguration extends GenericFileConfiguration {
private int timeout = 30000;
@UriParam
private int soTimeout;
+ @UriParam(defaultValue = "32768")
+ private int receiveBufferSize = 32 * 1024;
@UriParam
private boolean throwExceptionOnConnectFailed;
@UriParam
@@ -253,6 +255,19 @@ public abstract class RemoteFileConfiguration extends GenericFileConfiguration {
this.soTimeout = soTimeout;
}
+ public int getReceiveBufferSize() {
+ return receiveBufferSize;
+ }
+
+ /**
+ * The receive (download) buffer size
+ * <p/>
+ * Used only by FTPClient
+ */
+ public void setReceiveBufferSize(int receiveBufferSize) {
+ this.receiveBufferSize = receiveBufferSize;
+ }
+
public boolean isThrowExceptionOnConnectFailed() {
return throwExceptionOnConnectFailed;
}