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 2016/02/24 18:02:37 UTC
[1/4] camel git commit: CAMEL-9635 - read configuration for using
continuation or not from the httpconsumer on each request
Repository: camel
Updated Branches:
refs/heads/camel-2.16.x 0363a7274 -> ed5790bd9
refs/heads/master 9a6e6d8a9 -> f3671b48a
CAMEL-9635 - read configuration for using continuation or not from the
httpconsumer on each request
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2bf791b9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2bf791b9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2bf791b9
Branch: refs/heads/master
Commit: 2bf791b98aee3e327feaf2736c89260f06daf1c2
Parents: 9a6e6d8
Author: laeubi <la...@laeubi-soft.de>
Authored: Tue Feb 23 12:20:15 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Feb 24 17:34:00 2016 +0100
----------------------------------------------------------------------
.../jetty/CamelContinuationServlet.java | 39 ++++++++++++++------
.../component/jetty/JettyHttpComponent.java | 25 +------------
2 files changed, 30 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2bf791b9/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
index 68e7b48..0038a98 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
@@ -28,6 +28,7 @@ import org.apache.camel.AsyncCallback;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.http.common.CamelServlet;
+import org.apache.camel.http.common.HttpCommonEndpoint;
import org.apache.camel.http.common.HttpConstants;
import org.apache.camel.http.common.HttpConsumer;
import org.apache.camel.http.common.HttpHelper;
@@ -48,8 +49,6 @@ public class CamelContinuationServlet extends CamelServlet {
static final String EXCHANGE_ATTRIBUTE_ID = "CamelExchangeId";
private static final long serialVersionUID = 1L;
- // jetty will by default use 30000 millis as default timeout
- private Long continuationTimeout;
// we must remember expired exchanges as Jetty will initiate a new continuation when we send
// back the error when timeout occurred, and thus in the async callback we cannot check the
// continuation if it was previously expired. So that's why we have our own map for that
@@ -65,9 +64,35 @@ public class CamelContinuationServlet extends CamelServlet {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
+ boolean useContinuation = false;
+ Long continuationTimeout = null;
+ HttpCommonEndpoint endpoint = consumer.getEndpoint();
+ if (endpoint instanceof JettyHttpEndpoint) {
+ JettyHttpEndpoint jettyEndpoint = (JettyHttpEndpoint) endpoint;
+ Boolean epUseContinuation = jettyEndpoint.getUseContinuation();
+ Long epContinuationTimeout = jettyEndpoint.getContinuationTimeout();
+ if (epUseContinuation != null) {
+ useContinuation = epUseContinuation.booleanValue();
+ } else {
+ useContinuation = jettyEndpoint.getComponent().isUseContinuation();
+ }
+ if(epContinuationTimeout != null) {
+ continuationTimeout = epContinuationTimeout;
+ } else {
+ continuationTimeout = jettyEndpoint.getComponent().getContinuationTimeout();
+ }
+ }
+ if (useContinuation) {
+ log.trace("Start request with continuation timeout of {}", continuationTimeout!= null?continuationTimeout:"jetty default");
+ } else {
+ log.trace("Usage of continuation is disabled, either by component or endpoint configuration, fall back to normal servlet processing instead");
+ super.service(request, response);
+ return;
+ }
+
if (consumer.getEndpoint().getHttpMethodRestrict() != null) {
- Iterator it = ObjectHelper.createIterable(consumer.getEndpoint().getHttpMethodRestrict()).iterator();
+ Iterator<?> it = ObjectHelper.createIterable(consumer.getEndpoint().getHttpMethodRestrict()).iterator();
boolean match = false;
while (it.hasNext()) {
String method = it.next().toString();
@@ -215,14 +240,6 @@ public class CamelContinuationServlet extends CamelServlet {
}
}
- public Long getContinuationTimeout() {
- return continuationTimeout;
- }
-
- public void setContinuationTimeout(Long continuationTimeout) {
- this.continuationTimeout = continuationTimeout;
- }
-
@Override
public void destroy() {
expiredExchanges.clear();
http://git-wip-us.apache.org/repos/asf/camel/blob/2bf791b9/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 5e39a14..e3621a4 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -1103,28 +1103,7 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements
addJettyHandlers(server, handlers);
- CamelServlet camelServlet;
- boolean jetty = endpoint.getUseContinuation() != null ? endpoint.getUseContinuation() : isUseContinuation();
- if (jetty) {
- // use Jetty continuations
- CamelContinuationServlet jettyServlet = new CamelContinuationServlet();
- // configure timeout and log it so end user know what we are using
- Long timeout = endpoint.getContinuationTimeout() != null ? endpoint.getContinuationTimeout() : getContinuationTimeout();
- if (timeout != null) {
- LOG.info("Using Jetty continuation timeout: " + timeout + " millis for: " + endpoint);
- jettyServlet.setContinuationTimeout(timeout);
- } else {
- LOG.info("Using default Jetty continuation timeout for: " + endpoint);
- }
-
- // use the jetty servlet
- camelServlet = jettyServlet;
- } else {
- // do not use jetty so use a plain servlet
- camelServlet = new CamelServlet();
- LOG.info("Jetty continuation is disabled for: " + endpoint);
- }
-
+ CamelServlet camelServlet = new CamelContinuationServlet();
ServletHolder holder = new ServletHolder();
holder.setServlet(camelServlet);
context.addServlet(holder, "/*");
@@ -1239,7 +1218,7 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements
&& Server.getVersion().startsWith("8")) {
//JETTY8 only
try {
- boolean b = (boolean)mbContainer.getClass().getMethod("isStarted").invoke(mbContainer);
+ boolean b = (Boolean)mbContainer.getClass().getMethod("isStarted").invoke(mbContainer);
if (b) {
mbContainer.getClass().getMethod("start").invoke(mbContainer);
// Publish the container itself for consistency with
[2/4] camel git commit: CAMEL-9635: Fixed CS. This closes #857.
Posted by da...@apache.org.
CAMEL-9635: Fixed CS. This closes #857.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f3671b48
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f3671b48
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f3671b48
Branch: refs/heads/master
Commit: f3671b48acaa00a3def0089083369ed137cda30a
Parents: 2bf791b
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Feb 24 17:39:26 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Feb 24 17:39:26 2016 +0100
----------------------------------------------------------------------
.../camel/component/jetty/CamelContinuationServlet.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f3671b48/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
index 0038a98..a6a2e9c 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
@@ -64,6 +64,8 @@ public class CamelContinuationServlet extends CamelServlet {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
+
+ // figure out if continuation is enabled and what timeout to use
boolean useContinuation = false;
Long continuationTimeout = null;
HttpCommonEndpoint endpoint = consumer.getEndpoint();
@@ -72,24 +74,23 @@ public class CamelContinuationServlet extends CamelServlet {
Boolean epUseContinuation = jettyEndpoint.getUseContinuation();
Long epContinuationTimeout = jettyEndpoint.getContinuationTimeout();
if (epUseContinuation != null) {
- useContinuation = epUseContinuation.booleanValue();
+ useContinuation = epUseContinuation;
} else {
useContinuation = jettyEndpoint.getComponent().isUseContinuation();
}
- if(epContinuationTimeout != null) {
+ if (epContinuationTimeout != null) {
continuationTimeout = epContinuationTimeout;
} else {
continuationTimeout = jettyEndpoint.getComponent().getContinuationTimeout();
}
}
if (useContinuation) {
- log.trace("Start request with continuation timeout of {}", continuationTimeout!= null?continuationTimeout:"jetty default");
+ log.trace("Start request with continuation timeout of {}", continuationTimeout != null ? continuationTimeout : "jetty default");
} else {
- log.trace("Usage of continuation is disabled, either by component or endpoint configuration, fall back to normal servlet processing instead");
+ log.trace("Usage of continuation is disabled, either by component or endpoint configuration, fallback to normal servlet processing instead");
super.service(request, response);
return;
}
-
if (consumer.getEndpoint().getHttpMethodRestrict() != null) {
Iterator<?> it = ObjectHelper.createIterable(consumer.getEndpoint().getHttpMethodRestrict()).iterator();
[4/4] camel git commit: CAMEL-9635: Fixed CS. This closes #857.
Posted by da...@apache.org.
CAMEL-9635: Fixed CS. This closes #857.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ed5790bd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ed5790bd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ed5790bd
Branch: refs/heads/camel-2.16.x
Commit: ed5790bd92ea6a3735d19924ba3d17c85fcaf6ed
Parents: a904004
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Feb 24 17:39:26 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Feb 24 18:02:25 2016 +0100
----------------------------------------------------------------------
.../camel/component/jetty/CamelContinuationServlet.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ed5790bd/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
index 0038a98..a6a2e9c 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
@@ -64,6 +64,8 @@ public class CamelContinuationServlet extends CamelServlet {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
+
+ // figure out if continuation is enabled and what timeout to use
boolean useContinuation = false;
Long continuationTimeout = null;
HttpCommonEndpoint endpoint = consumer.getEndpoint();
@@ -72,24 +74,23 @@ public class CamelContinuationServlet extends CamelServlet {
Boolean epUseContinuation = jettyEndpoint.getUseContinuation();
Long epContinuationTimeout = jettyEndpoint.getContinuationTimeout();
if (epUseContinuation != null) {
- useContinuation = epUseContinuation.booleanValue();
+ useContinuation = epUseContinuation;
} else {
useContinuation = jettyEndpoint.getComponent().isUseContinuation();
}
- if(epContinuationTimeout != null) {
+ if (epContinuationTimeout != null) {
continuationTimeout = epContinuationTimeout;
} else {
continuationTimeout = jettyEndpoint.getComponent().getContinuationTimeout();
}
}
if (useContinuation) {
- log.trace("Start request with continuation timeout of {}", continuationTimeout!= null?continuationTimeout:"jetty default");
+ log.trace("Start request with continuation timeout of {}", continuationTimeout != null ? continuationTimeout : "jetty default");
} else {
- log.trace("Usage of continuation is disabled, either by component or endpoint configuration, fall back to normal servlet processing instead");
+ log.trace("Usage of continuation is disabled, either by component or endpoint configuration, fallback to normal servlet processing instead");
super.service(request, response);
return;
}
-
if (consumer.getEndpoint().getHttpMethodRestrict() != null) {
Iterator<?> it = ObjectHelper.createIterable(consumer.getEndpoint().getHttpMethodRestrict()).iterator();
[3/4] camel git commit: CAMEL-9635 - read configuration for using
continuation or not from the httpconsumer on each request
Posted by da...@apache.org.
CAMEL-9635 - read configuration for using continuation or not from the
httpconsumer on each request
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a9040041
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a9040041
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a9040041
Branch: refs/heads/camel-2.16.x
Commit: a90400419852a45aed8d66b5c0691fe3e12b70fc
Parents: 0363a72
Author: laeubi <la...@laeubi-soft.de>
Authored: Tue Feb 23 12:20:15 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Feb 24 18:02:19 2016 +0100
----------------------------------------------------------------------
.../jetty/CamelContinuationServlet.java | 39 ++++++++++++++------
.../component/jetty/JettyHttpComponent.java | 25 +------------
2 files changed, 30 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/a9040041/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
index 68e7b48..0038a98 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
@@ -28,6 +28,7 @@ import org.apache.camel.AsyncCallback;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.http.common.CamelServlet;
+import org.apache.camel.http.common.HttpCommonEndpoint;
import org.apache.camel.http.common.HttpConstants;
import org.apache.camel.http.common.HttpConsumer;
import org.apache.camel.http.common.HttpHelper;
@@ -48,8 +49,6 @@ public class CamelContinuationServlet extends CamelServlet {
static final String EXCHANGE_ATTRIBUTE_ID = "CamelExchangeId";
private static final long serialVersionUID = 1L;
- // jetty will by default use 30000 millis as default timeout
- private Long continuationTimeout;
// we must remember expired exchanges as Jetty will initiate a new continuation when we send
// back the error when timeout occurred, and thus in the async callback we cannot check the
// continuation if it was previously expired. So that's why we have our own map for that
@@ -65,9 +64,35 @@ public class CamelContinuationServlet extends CamelServlet {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
+ boolean useContinuation = false;
+ Long continuationTimeout = null;
+ HttpCommonEndpoint endpoint = consumer.getEndpoint();
+ if (endpoint instanceof JettyHttpEndpoint) {
+ JettyHttpEndpoint jettyEndpoint = (JettyHttpEndpoint) endpoint;
+ Boolean epUseContinuation = jettyEndpoint.getUseContinuation();
+ Long epContinuationTimeout = jettyEndpoint.getContinuationTimeout();
+ if (epUseContinuation != null) {
+ useContinuation = epUseContinuation.booleanValue();
+ } else {
+ useContinuation = jettyEndpoint.getComponent().isUseContinuation();
+ }
+ if(epContinuationTimeout != null) {
+ continuationTimeout = epContinuationTimeout;
+ } else {
+ continuationTimeout = jettyEndpoint.getComponent().getContinuationTimeout();
+ }
+ }
+ if (useContinuation) {
+ log.trace("Start request with continuation timeout of {}", continuationTimeout!= null?continuationTimeout:"jetty default");
+ } else {
+ log.trace("Usage of continuation is disabled, either by component or endpoint configuration, fall back to normal servlet processing instead");
+ super.service(request, response);
+ return;
+ }
+
if (consumer.getEndpoint().getHttpMethodRestrict() != null) {
- Iterator it = ObjectHelper.createIterable(consumer.getEndpoint().getHttpMethodRestrict()).iterator();
+ Iterator<?> it = ObjectHelper.createIterable(consumer.getEndpoint().getHttpMethodRestrict()).iterator();
boolean match = false;
while (it.hasNext()) {
String method = it.next().toString();
@@ -215,14 +240,6 @@ public class CamelContinuationServlet extends CamelServlet {
}
}
- public Long getContinuationTimeout() {
- return continuationTimeout;
- }
-
- public void setContinuationTimeout(Long continuationTimeout) {
- this.continuationTimeout = continuationTimeout;
- }
-
@Override
public void destroy() {
expiredExchanges.clear();
http://git-wip-us.apache.org/repos/asf/camel/blob/a9040041/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index c64513e..8e8c3ce 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -1095,28 +1095,7 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements
addJettyHandlers(server, handlers);
- CamelServlet camelServlet;
- boolean jetty = endpoint.getUseContinuation() != null ? endpoint.getUseContinuation() : isUseContinuation();
- if (jetty) {
- // use Jetty continuations
- CamelContinuationServlet jettyServlet = new CamelContinuationServlet();
- // configure timeout and log it so end user know what we are using
- Long timeout = endpoint.getContinuationTimeout() != null ? endpoint.getContinuationTimeout() : getContinuationTimeout();
- if (timeout != null) {
- LOG.info("Using Jetty continuation timeout: " + timeout + " millis for: " + endpoint);
- jettyServlet.setContinuationTimeout(timeout);
- } else {
- LOG.info("Using default Jetty continuation timeout for: " + endpoint);
- }
-
- // use the jetty servlet
- camelServlet = jettyServlet;
- } else {
- // do not use jetty so use a plain servlet
- camelServlet = new CamelServlet();
- LOG.info("Jetty continuation is disabled for: " + endpoint);
- }
-
+ CamelServlet camelServlet = new CamelContinuationServlet();
ServletHolder holder = new ServletHolder();
holder.setServlet(camelServlet);
context.addServlet(holder, "/*");
@@ -1231,7 +1210,7 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements
&& Server.getVersion().startsWith("8")) {
//JETTY8 only
try {
- boolean b = (boolean)mbContainer.getClass().getMethod("isStarted").invoke(mbContainer);
+ boolean b = (Boolean)mbContainer.getClass().getMethod("isStarted").invoke(mbContainer);
if (b) {
mbContainer.getClass().getMethod("start").invoke(mbContainer);
// Publish the container itself for consistency with