You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/09/26 09:04:38 UTC
git commit: CAMEL-7856 Added igoreDeleteMethodMessageBody option to
CxfRsEndpoint
Repository: camel
Updated Branches:
refs/heads/master 62f08f081 -> 53792cc1c
CAMEL-7856 Added igoreDeleteMethodMessageBody option to CxfRsEndpoint
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/53792cc1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/53792cc1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/53792cc1
Branch: refs/heads/master
Commit: 53792cc1cf4c45f3fae6d8cc84a3b15fb12cc05a
Parents: 62f08f0
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Sep 26 15:02:27 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Sep 26 15:02:27 2014 +0800
----------------------------------------------------------------------
.../camel/component/cxf/jaxrs/CxfRsEndpoint.java | 10 ++++++++++
.../camel/component/cxf/jaxrs/CxfRsProducer.java | 17 ++++++++++++-----
.../component/cxf/jaxrs/CxfRsSpringRouter.xml | 7 ++-----
3 files changed, 24 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/53792cc1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
index 12da6c3..1a04617 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
@@ -91,6 +91,8 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate
@UriParam
private boolean httpClientAPI = true;
@UriParam
+ private boolean ignoreDeleteMethodMessageBody;
+ @UriParam
private String address;
@UriParam
private boolean throwExceptionOnFailure = true;
@@ -400,6 +402,14 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate
return isSetDefaultBus;
}
+ public boolean isIgnoreDeleteMethodMessageBody() {
+ return ignoreDeleteMethodMessageBody;
+ }
+
+ public void setIgnoreDELETEMethodMessageBody(boolean ignoreDELETEMethodMessageBody) {
+ this.ignoreDeleteMethodMessageBody = ignoreDELETEMethodMessageBody;
+ }
+
public BindingStyle getBindingStyle() {
return bindingStyle;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/53792cc1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
index b023a8f..f22ca8b 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
@@ -58,12 +58,15 @@ public class CxfRsProducer extends DefaultProducer {
private boolean throwException;
+ private CxfRsEndpoint cxfRsEndpoint;
+
// using a cache of factory beans instead of setting the address of a single cfb
// to avoid concurrent issues
private ClientFactoryBeanCache clientFactoryBeanCache;
public CxfRsProducer(CxfRsEndpoint endpoint) {
super(endpoint);
+ cxfRsEndpoint = endpoint;
this.throwException = endpoint.isThrowExceptionOnFailure();
clientFactoryBeanCache = new ClientFactoryBeanCache(endpoint.getMaxClientCacheSize());
}
@@ -164,11 +167,15 @@ public class CxfRsProducer extends DefaultProducer {
// set the body
Object body = null;
- if (!"GET".equals(httpMethod) && !"DELETE".equals(httpMethod)) {
- // need to check the request object if the http Method is not GET or DELETE
- body = binding.bindCamelMessageBodyToRequestBody(inMessage, exchange);
- if (LOG.isTraceEnabled()) {
- LOG.trace("Request body = " + body);
+ if (!"GET".equals(httpMethod)) {
+ // need to check the request object if the http Method is not GET
+ if ("DELETE".equals(httpMethod) && cxfRsEndpoint.isIgnoreDeleteMethodMessageBody()) {
+ // just ignore the message body if the ignoreDeleteMethodMessageBody is true
+ } else {
+ body = binding.bindCamelMessageBodyToRequestBody(inMessage, exchange);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Request body = " + body);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/53792cc1/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml
index 9f51dd6..172aac1 100644
--- a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml
@@ -63,12 +63,9 @@
<!-- The camel route context -->
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
- <from uri="cxfrs://bean://rsServer"/>
+ <!-- Just need to ignoreDeleteMethodMessageBody -->
+ <from uri="cxfrs://bean://rsServer?ignoreDeleteMethodMessageBody=true"/>
<to uri="log:body?level=INFO"/>
- <!-- We can remove this configure as the CXFRS producer is using the HttpAPI by default -->
- <setHeader headerName="CamelCxfRsUsingHttpAPI">
- <constant>True</constant>
- </setHeader>
<to uri="cxfrs://bean://rsClient"/>
</route>
</camelContext>