This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch CAMEL-13870
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/CAMEL-13870 by this push:
new 9bcb1ba CAMEL-13870: Fast property configuration of Camel endpoints.
Work in progress.
9bcb1ba is described below
commit 9bcb1ba5d4861fd28bd2a138586bf2bd7cae7eb0
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Aug 21 11:56:48 2019 +0200
CAMEL-13870: Fast property configuration of Camel endpoints. Work in
progress.
---
.../src/main/docs/spring-ws-component.adoc | 10 +--
.../spring/ws/SpringWebserviceComponent.java | 4 +-
.../spring/ws/SpringWebserviceConfiguration.java | 84 ++++++++++++++++------
.../spring/ws/type/EndpointMappingKey.java | 40 +----------
.../SpringWebserviceEndpointBuilderFactory.java | 25 +++----
5 files changed, 83 insertions(+), 80 deletions(-)
diff --git a/components/camel-spring-ws/src/main/docs/spring-ws-component.adoc
b/components/camel-spring-ws/src/main/docs/spring-ws-component.adoc
index 6831aed..1b88ba8 100644
--- a/components/camel-spring-ws/src/main/docs/spring-ws-component.adoc
+++ b/components/camel-spring-ws/src/main/docs/spring-ws-component.adoc
@@ -107,19 +107,20 @@ spring-ws:type:lookupKey:webServiceEndpointUri
with the following path and query parameters:
-=== Path Parameters (3 parameters):
+=== Path Parameters (4 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
-| *type* | Endpoint mapping type if endpoint mapping is used. rootqname -
Offers the option to map web service requests based on the qualified name of
the root element contained in the message. soapaction - Used to map web service
requests based on the SOAP action specified in the header of the message. uri -
In order to map web service requests that target a specific URI. xpathresult -
Used to map web service requests based on the evaluation of an XPath expression
against the incoming m [...]
-| *lookupKey* | Endpoint mapping key if endpoint mapping is used | | String
| *webServiceEndpointUri* | The default Web Service endpoint uri to use for
the producer. | | String
+| *endpointMappingType* | Endpoint mapping type if endpoint mapping is used.
rootqname - Offers the option to map web service requests based on the
qualified name of the root element contained in the message. soapaction - Used
to map web service requests based on the SOAP action specified in the header of
the message. uri - In order to map web service requests that target a specific
URI. xpathresult - Used to map web service requests based on the evaluation of
an XPath expression against [...]
+| *endpointMappingLookupKey* | Endpoint mapping key if endpoint mapping is
used | | String
+| *expression* | The XPath expression to use when option type=xpathresult.
Then this option is required to be configured. | | String
|===
-=== Query Parameters (24 parameters):
+=== Query Parameters (23 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
@@ -129,7 +130,6 @@ with the following path and query parameters:
| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the
Camel routing Error Handler, which mean any exceptions occurred while the
consumer is trying to pickup incoming messages, or the likes, will now be
processed as a message and handled by the routing Error Handler. By default the
consumer will use the org.apache.camel.spi.ExceptionHandler to deal with
exceptions, that will be logged at WARN or ERROR level and ignored. | false |
boolean
| *endpointDispatcher* (consumer) | Spring
org.springframework.ws.server.endpoint.MessageEndpoint for dispatching messages
received by Spring-WS to a Camel endpoint, to integrate with existing (legacy)
endpoint mappings like PayloadRootQNameEndpointMapping,
SoapActionEndpointMapping, etc. | | CamelEndpointDispatcher
| *endpointMapping* (consumer) | Reference to an instance of
org.apache.camel.component.spring.ws.bean.CamelEndpointMapping in the
Registry/ApplicationContext. Only one bean is required in the registry to serve
all Camel/Spring-WS endpoints. This bean is auto-discovered by the
MessageDispatcher and used to map requests to Camel endpoints based on
characteristics specified on the endpoint (like root QName, SOAP action, etc) |
| CamelSpringWSEndpoint Mapping
-| *expression* (consumer) | The XPath expression to use when option
type=xpathresult. Then this option is required to be configured. | | String
| *exceptionHandler* (consumer) | To let the consumer use a custom
ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this
option is not in use. By default the consumer will deal with exceptions, that
will be logged at WARN or ERROR level and ignored. | | ExceptionHandler
| *exchangePattern* (consumer) | Sets the exchange pattern when the consumer
creates an exchange. | | ExchangePattern
| *allowResponseAttachment Override* (producer) | Option to override soap
response attachments in in/out exchange with attachments from the actual
service layer. If the invoked service appends or rewrites the soap attachments
this option when set to true, allows the modified soap attachments to be
overwritten in in/out message attachments | false | boolean
diff --git
a/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java
b/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java
index 6826522..b41a5ae 100644
---
a/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java
+++
b/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java
@@ -93,8 +93,10 @@ public class SpringWebserviceComponent extends
DefaultComponent implements SSLCo
String expression = getAndRemoveParameter(parameters,
"expression", String.class);
configuration.setExpression(expression);
xPathExpression = createXPathExpression(expression);
+ configuration.setxPathExpression(xPathExpression);
}
- configuration.setEndpointMappingKey(new EndpointMappingKey(type,
lookupKey, xPathExpression));
+ configuration.setEndpointMappingType(type);
+ configuration.setEndpointMappingLookupKey(lookupKey);
}
}
diff --git
a/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
b/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
index 09f1e74..bc727d7 100644
---
a/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
+++
b/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
@@ -23,6 +23,7 @@ import
org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher;
import org.apache.camel.component.spring.ws.bean.CamelSpringWSEndpointMapping;
import org.apache.camel.component.spring.ws.filter.MessageFilter;
import org.apache.camel.component.spring.ws.type.EndpointMappingKey;
+import org.apache.camel.component.spring.ws.type.EndpointMappingType;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
@@ -33,6 +34,7 @@ import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.soap.addressing.messageid.MessageIdStrategy;
import org.springframework.ws.soap.addressing.server.annotation.Action;
import org.springframework.ws.transport.WebServiceMessageSender;
+import org.springframework.xml.xpath.XPathExpression;
@UriParams
public class SpringWebserviceConfiguration {
@@ -75,14 +77,17 @@ public class SpringWebserviceConfiguration {
private boolean allowResponseAttachmentOverride;
/* Consumer configuration */
- @UriParam(label = "consumer")
- private EndpointMappingKey endpointMappingKey;
+ @UriPath(label = "consumer")
+ private EndpointMappingType endpointMappingType;
+ @UriPath(label = "consumer")
+ private String endpointMappingLookupKey;
+ @UriPath(label = "consumer")
+ private String expression;
+ private transient XPathExpression xPathExpression;
@UriParam(label = "consumer")
private CamelSpringWSEndpointMapping endpointMapping;
@UriParam(label = "consumer")
private CamelEndpointDispatcher endpointDispatcher;
- @UriParam(label = "consumer")
- private String expression;
public WebServiceTemplate getWebServiceTemplate() {
return webServiceTemplate;
@@ -119,17 +124,6 @@ public class SpringWebserviceConfiguration {
this.webServiceEndpointUri = webServiceEndpointUri;
}
- public String getExpression() {
- return expression;
- }
-
- /**
- * The XPath expression to use when option type=xpathresult. Then this
option is required to be configured.
- */
- public void setExpression(String expression) {
- this.expression = expression;
- }
-
public String getSoapAction() {
return soapAction;
}
@@ -142,9 +136,9 @@ public class SpringWebserviceConfiguration {
}
public String getEndpointUri() {
- if (endpointMappingKey != null) {
+ if (getEndpointMappingKey() != null) {
// only for consumers, use lookup key as endpoint uri/key
- return encode(endpointMappingKey.getLookupKey());
+ return encode(getEndpointMappingKey().getLookupKey());
} else if (webServiceTemplate != null) {
return webServiceTemplate.getDefaultUri();
}
@@ -203,11 +197,61 @@ public class SpringWebserviceConfiguration {
}
public EndpointMappingKey getEndpointMappingKey() {
- return endpointMappingKey;
+ if (endpointMappingType != null && endpointMappingLookupKey != null) {
+ return new EndpointMappingKey(endpointMappingType,
endpointMappingLookupKey, xPathExpression);
+ } else {
+ return null;
+ }
+ }
+
+ public EndpointMappingType getEndpointMappingType() {
+ return endpointMappingType;
+ }
+
+ /**
+ * Endpoint mapping type if endpoint mapping is used.
+ * <ul>
+ * <li>rootqname - Offers the option to map web service requests based
on the qualified name of the root element contained in the message.</li>
+ * <li>soapaction - Used to map web service requests based on the SOAP
action specified in the header of the message.</li>
+ * <li>uri - In order to map web service requests that target a
specific URI.</li>
+ * <li>xpathresult - Used to map web service requests based on the
evaluation of an XPath expression against the incoming message.
+ * The result of the evaluation should match the
XPath result specified in the endpoint URI.</li>
+ * <li>beanname - Allows you to reference an
org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher object in
order to integrate with
+ * existing (legacy) endpoint mappings like
PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc</li>
+ * </ul>
+ */
+ public void setEndpointMappingType(EndpointMappingType
endpointMappingType) {
+ this.endpointMappingType = endpointMappingType;
+ }
+
+ public String getEndpointMappingLookupKey() {
+ return endpointMappingLookupKey;
+ }
+
+ /**
+ * Endpoint mapping key if endpoint mapping is used
+ */
+ public void setEndpointMappingLookupKey(String endpointMappingLookupKey) {
+ this.endpointMappingLookupKey = endpointMappingLookupKey;
+ }
+
+ public String getExpression() {
+ return expression;
+ }
+
+ /**
+ * The XPath expression to use when option type=xpathresult. Then this
option is required to be configured.
+ */
+ public void setExpression(String expression) {
+ this.expression = expression;
+ }
+
+ public XPathExpression getxPathExpression() {
+ return xPathExpression;
}
- public void setEndpointMappingKey(EndpointMappingKey endpointMappingKey) {
- this.endpointMappingKey = endpointMappingKey;
+ public void setxPathExpression(XPathExpression xPathExpression) {
+ this.xPathExpression = xPathExpression;
}
public SSLContextParameters getSslContextParameters() {
diff --git
a/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java
b/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java
index 6ef8e79..a8e548f 100644
---
a/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java
+++
b/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java
@@ -16,19 +16,12 @@
*/
package org.apache.camel.component.spring.ws.type;
-import org.apache.camel.spi.UriParams;
-import org.apache.camel.spi.UriPath;
import org.springframework.xml.xpath.XPathExpression;
-@UriParams
public class EndpointMappingKey {
- @UriPath(label = "consumer")
- private EndpointMappingType type;
- @UriPath(label = "consumer")
- private String lookupKey;
-
- /* expression in case type is 'xpath' */
- private XPathExpression expression;
+ private final EndpointMappingType type;
+ private final String lookupKey;
+ private final XPathExpression expression;
public EndpointMappingKey(EndpointMappingType type, String lookupKey,
XPathExpression expression) {
this.type = type;
@@ -40,41 +33,14 @@ public class EndpointMappingKey {
return type;
}
- /**
- * Endpoint mapping type if endpoint mapping is used.
- * <ul>
- * <li>rootqname - Offers the option to map web service requests based
on the qualified name of the root element contained in the message.</li>
- * <li>soapaction - Used to map web service requests based on the SOAP
action specified in the header of the message.</li>
- * <li>uri - In order to map web service requests that target a
specific URI.</li>
- * <li>xpathresult - Used to map web service requests based on the
evaluation of an XPath expression against the incoming message.
- * The result of the evaluation should match the
XPath result specified in the endpoint URI.</li>
- * <li>beanname - Allows you to reference an
org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher object in
order to integrate with
- * existing (legacy) endpoint mappings like
PayloadRootQNameEndpointMapping, SoapActionEndpointMapping, etc</li>
- * </ul>
- */
- public void setType(EndpointMappingType type) {
- this.type = type;
- }
-
public String getLookupKey() {
return lookupKey;
}
- /**
- * Endpoint mapping key if endpoint mapping is used
- */
- public void setLookupKey(String lookupKey) {
- this.lookupKey = lookupKey;
- }
-
public XPathExpression getExpression() {
return expression;
}
- public void setExpression(XPathExpression expression) {
- this.expression = expression;
- }
-
@Override
public int hashCode() {
final int prime = 31;
diff --git
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SpringWebserviceEndpointBuilderFactory.java
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SpringWebserviceEndpointBuilderFactory.java
index d119ebe..cefc3d0 100644
---
a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SpringWebserviceEndpointBuilderFactory.java
+++
b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/SpringWebserviceEndpointBuilderFactory.java
@@ -178,19 +178,6 @@ public interface SpringWebserviceEndpointBuilderFactory {
return this;
}
/**
- * The XPath expression to use when option type=xpathresult. Then this
- * option is required to be configured.
- *
- * The option is a: <code>java.lang.String</code> type.
- *
- * Group: consumer
- */
- default SpringWebserviceEndpointConsumerBuilder expression(
- String expression) {
- setProperty("expression", expression);
- return this;
- }
- /**
* To configure security using SSLContextParameters.
*
* The option is a:
@@ -1015,7 +1002,10 @@ public interface SpringWebserviceEndpointBuilderFactory {
*
* Syntax: <code>spring-ws:type:lookupKey:webServiceEndpointUri</code>
*
- * Path parameter: type
+ * Path parameter: webServiceEndpointUri
+ * The default Web Service endpoint uri to use for the producer.
+ *
+ * Path parameter: endpointMappingType
* Endpoint mapping type if endpoint mapping is used. rootqname - Offers
the
* option to map web service requests based on the qualified name of the
* root element contained in the message. soapaction - Used to map web
@@ -1031,11 +1021,12 @@ public interface SpringWebserviceEndpointBuilderFactory
{
* The value can be one of: ROOT_QNAME, ACTION, TO, SOAP_ACTION,
* XPATHRESULT, URI, URI_PATH, BEANNAME
*
- * Path parameter: lookupKey
+ * Path parameter: endpointMappingLookupKey
* Endpoint mapping key if endpoint mapping is used
*
- * Path parameter: webServiceEndpointUri
- * The default Web Service endpoint uri to use for the producer.
+ * Path parameter: expression
+ * The XPath expression to use when option type=xpathresult. Then this
+ * option is required to be configured.
*/
default SpringWebserviceEndpointBuilder springWebservice(String path) {
class SpringWebserviceEndpointBuilderImpl extends
AbstractEndpointBuilder implements SpringWebserviceEndpointBuilder,
AdvancedSpringWebserviceEndpointBuilder {