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/07/15 11:36:45 UTC
[6/6] camel git commit: Added component docs
Added component docs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f9948173
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f9948173
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f9948173
Branch: refs/heads/master
Commit: f9948173a021cff8ced3de638ce82982ddb3f21e
Parents: 34b93ee
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Jul 15 11:43:14 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jul 15 11:43:14 2015 +0200
----------------------------------------------------------------------
.../component/undertow/UndertowEndpoint.java | 76 +++++++++++---------
.../undertow/UndertowError500Test.java | 2 +
2 files changed, 46 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f9948173/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
index 6bca957..c1b5d54 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
@@ -39,23 +39,26 @@ import org.slf4j.LoggerFactory;
/**
* Represents an Undertow endpoint.
*/
-@UriEndpoint(scheme = "undertow", title = "Undertow", syntax = "undertow:host:port/path",
+@UriEndpoint(scheme = "undertow", title = "Undertow", syntax = "undertow:httpURI",
consumerClass = UndertowConsumer.class, label = "http")
public class UndertowEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware {
private static final Logger LOG = LoggerFactory.getLogger(UndertowEndpoint.class);
- private UndertowHttpBinding undertowHttpBinding;
private UndertowComponent component;
- private HeaderFilterStrategy headerFilterStrategy;
- private SSLContext sslContext;
@UriPath
private URI httpURI;
@UriParam
- private String httpMethodRestrict;
+ private UndertowHttpBinding undertowHttpBinding;
@UriParam
- private Boolean matchOnUriPrefix = true;
+ private HeaderFilterStrategy headerFilterStrategy;
@UriParam
+ private SSLContext sslContext;
+ @UriParam(label = "consumer")
+ private String httpMethodRestrict;
+ @UriParam(label = "consumer", defaultValue = "true")
+ private Boolean matchOnUriPrefix = true;
+ @UriParam(label = "producer")
private Boolean throwExceptionOnFailure;
@UriParam
private Boolean transferException;
@@ -67,22 +70,16 @@ public class UndertowEndpoint extends DefaultEndpoint implements HeaderFilterStr
}
@Override
- public Producer createProducer() throws Exception {
- return new UndertowProducer(this);
+ public UndertowComponent getComponent() {
+ return component;
}
- public Exchange createExchange(HttpServerExchange httpExchange) throws Exception {
- Exchange exchange = createExchange();
-
- Message in = getUndertowHttpBinding().toCamelMessage(httpExchange, exchange);
-
- exchange.setProperty(Exchange.CHARSET_NAME, httpExchange.getRequestCharset());
- in.setHeader(Exchange.HTTP_CHARACTER_ENCODING, httpExchange.getRequestCharset());
-
- exchange.setIn(in);
- return exchange;
+ @Override
+ public Producer createProducer() throws Exception {
+ return new UndertowProducer(this);
}
+ @Override
public Consumer createConsumer(Processor processor) throws Exception {
return new UndertowConsumer(this, processor);
}
@@ -93,28 +90,40 @@ public class UndertowEndpoint extends DefaultEndpoint implements HeaderFilterStr
throw new UnsupportedOperationException("This component does not support polling consumer");
}
+ @Override
public boolean isSingleton() {
return true;
}
+ public Exchange createExchange(HttpServerExchange httpExchange) throws Exception {
+ Exchange exchange = createExchange();
+
+ Message in = getUndertowHttpBinding().toCamelMessage(httpExchange, exchange);
+
+ exchange.setProperty(Exchange.CHARSET_NAME, httpExchange.getRequestCharset());
+ in.setHeader(Exchange.HTTP_CHARACTER_ENCODING, httpExchange.getRequestCharset());
+
+ exchange.setIn(in);
+ return exchange;
+ }
+
public URI getHttpURI() {
return httpURI;
}
/**
- * Set full HTTP URI
+ * The url of the HTTP endpoint to use.
*/
public void setHttpURI(URI httpURI) {
this.httpURI = httpURI;
}
-
public String getHttpMethodRestrict() {
return httpMethodRestrict;
}
/**
- * Configure set of allowed HTTP request method
+ * Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc. Multiple methods can be specified separated by comma.
*/
public void setHttpMethodRestrict(String httpMethodRestrict) {
this.httpMethodRestrict = httpMethodRestrict;
@@ -125,7 +134,7 @@ public class UndertowEndpoint extends DefaultEndpoint implements HeaderFilterStr
}
/**
- * Set if URI should be matched on prefix
+ * Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.
*/
public void setMatchOnUriPrefix(Boolean matchOnUriPrefix) {
this.matchOnUriPrefix = matchOnUriPrefix;
@@ -135,6 +144,9 @@ public class UndertowEndpoint extends DefaultEndpoint implements HeaderFilterStr
return headerFilterStrategy;
}
+ /**
+ * To use a custom HeaderFilterStrategy to filter header to and from Camel message.
+ */
public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {
this.headerFilterStrategy = headerFilterStrategy;
undertowHttpBinding.setHeaderFilterStrategy(headerFilterStrategy);
@@ -144,6 +156,9 @@ public class UndertowEndpoint extends DefaultEndpoint implements HeaderFilterStr
return sslContext;
}
+ /**
+ * To configure security using SSLContextParameters
+ */
public void setSslContext(SSLContext sslContext) {
this.sslContext = sslContext;
}
@@ -153,7 +168,8 @@ public class UndertowEndpoint extends DefaultEndpoint implements HeaderFilterStr
}
/**
- * Configure if exception should be thrown on failure
+ * If the option is true, HttpProducer will ignore the Exchange.HTTP_URI header, and use the endpoint's URI for request.
+ * You may also set the option throwExceptionOnFailure to be false to let the producer send all the fault response back.
*/
public void setThrowExceptionOnFailure(Boolean throwExceptionOnFailure) {
this.throwExceptionOnFailure = throwExceptionOnFailure;
@@ -164,7 +180,8 @@ public class UndertowEndpoint extends DefaultEndpoint implements HeaderFilterStr
}
/**
- * Configure if exception should be transferred to client
+ * Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server.
+ * This allows you to get all responses regardless of the HTTP status code.
*/
public void setTransferException(Boolean transferException) {
this.transferException = transferException;
@@ -174,16 +191,11 @@ public class UndertowEndpoint extends DefaultEndpoint implements HeaderFilterStr
return undertowHttpBinding;
}
+ /**
+ * To use a custom UndertowHttpBinding to control the mapping between Camel message and undertow.
+ */
public void setUndertowHttpBinding(UndertowHttpBinding undertowHttpBinding) {
this.undertowHttpBinding = undertowHttpBinding;
}
- @Override
- public UndertowComponent getComponent() {
- return component;
- }
-
- public void setComponent(UndertowComponent component) {
- this.component = component;
- }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/f9948173/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowError500Test.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowError500Test.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowError500Test.java
index 93fc3ba..41c7e16 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowError500Test.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowError500Test.java
@@ -24,6 +24,8 @@ import org.junit.Test;
public class UndertowError500Test extends CamelTestSupport {
+ // TODO: add unit test should use dynamic port number, see camel-jetty9 for example
+
@Test
public void testHttp500Error() throws Exception {
getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");