Repository: camel Updated Branches: refs/heads/master 1e9700b05 -> 8739eafec
Component docs Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8739eafe Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8739eafe Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8739eafe Branch: refs/heads/master Commit: 8739eafec2d21a129e33c3e7d8a9040e2118c5d4 Parents: 1e9700b Author: Claus Ibsen <davscl...@apache.org> Authored: Sun Jun 14 17:03:18 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun Jun 14 17:03:18 2015 +0200 ---------------------------------------------------------------------- .../netty4/http/NettyHttpComponent.java | 9 +++ .../netty4/http/NettyHttpConfiguration.java | 68 ++++++++++++++++---- .../netty4/http/NettyHttpEndpoint.java | 22 +++++++ 3 files changed, 87 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/8739eafe/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java index 901ff14..bb77cbf 100644 --- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java +++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java @@ -171,6 +171,9 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt return nettyHttpBinding; } + /** + * To use a custom org.apache.camel.component.netty4.http.NettyHttpBinding for binding to/from Netty and Camel Message API. + */ public void setNettyHttpBinding(NettyHttpBinding nettyHttpBinding) { this.nettyHttpBinding = nettyHttpBinding; } @@ -179,6 +182,9 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt return headerFilterStrategy; } + /** + * To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter headers. + */ public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) { this.headerFilterStrategy = headerFilterStrategy; } @@ -187,6 +193,9 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt return securityConfiguration; } + /** + * Refers to a org.apache.camel.component.netty4.http.NettyHttpSecurityConfiguration for configuring secure web resources. + */ public void setSecurityConfiguration(NettyHttpSecurityConfiguration securityConfiguration) { this.securityConfiguration = securityConfiguration; } http://git-wip-us.apache.org/repos/asf/camel/blob/8739eafe/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java index 50a4ffb..468d6f8 100644 --- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java +++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java @@ -22,6 +22,7 @@ import java.util.List; import io.netty.channel.ChannelHandler; import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.netty4.NettyConfiguration; +import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; import org.apache.camel.spi.UriPath; @@ -32,7 +33,7 @@ import org.apache.camel.spi.UriPath; @UriParams public class NettyHttpConfiguration extends NettyConfiguration { - @UriPath + @UriPath @Metadata(required = "true") private String path; @UriParam private boolean urlDecodeHeaders; @@ -50,12 +51,10 @@ public class NettyHttpConfiguration extends NettyConfiguration { private boolean bridgeEndpoint; @UriParam private boolean disableStreamCache; - @UriParam(defaultValue = "true") + @UriParam(label = "consumer", defaultValue = "true") private boolean send503whenSuspended = true; @UriParam(defaultValue = "" + 1024 * 1024) private int chunkedMaxContentLength = 1024 * 1024; - @UriParam(defaultValue = "true") - private boolean chunked = true; public NettyHttpConfiguration() { // we need sync=true as http is request/reply by nature @@ -85,6 +84,9 @@ public class NettyHttpConfiguration extends NettyConfiguration { return compression; } + /** + * Allow using gzip/deflate for compression on the Netty HTTP server if the client supports it from the HTTP headers. + */ public void setCompression(boolean compression) { this.compression = compression; } @@ -93,6 +95,10 @@ public class NettyHttpConfiguration extends NettyConfiguration { return throwExceptionOnFailure; } + /** + * 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 setThrowExceptionOnFailure(boolean throwExceptionOnFailure) { this.throwExceptionOnFailure = throwExceptionOnFailure; } @@ -101,6 +107,12 @@ public class NettyHttpConfiguration extends NettyConfiguration { return transferException; } + /** + * If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back serialized + * in the response as a application/x-java-serialized-object content type. + * On the producer side the exception will be deserialized and thrown as is, instead of the HttpOperationFailedException. + * The caused exception is required to be serialized. + */ public void setTransferException(boolean transferException) { this.transferException = transferException; } @@ -109,6 +121,12 @@ public class NettyHttpConfiguration extends NettyConfiguration { return urlDecodeHeaders; } + /** + * If this option is enabled, then during binding from Netty to Camel Message then the header values will be URL decoded + * (eg %20 will be a space character. Notice this option is used by the default org.apache.camel.component.netty.http.NettyHttpBinding + * and therefore if you implement a custom org.apache.camel.component.netty4.http.NettyHttpBinding then you would + * need to decode the headers accordingly to this option. + */ public void setUrlDecodeHeaders(boolean urlDecodeHeaders) { this.urlDecodeHeaders = urlDecodeHeaders; } @@ -117,6 +135,12 @@ public class NettyHttpConfiguration extends NettyConfiguration { return mapHeaders; } + /** + * If this option is enabled, then during binding from Netty to Camel Message then the headers will be mapped as well + * (eg added as header to the Camel Message as well). You can turn off this option to disable this. + * The headers can still be accessed from the org.apache.camel.component.netty.http.NettyHttpMessage message with + * the method getHttpRequest() that returns the Netty HTTP request io.netty.handler.codec.http.HttpRequest instance. + */ public void setMapHeaders(boolean mapHeaders) { this.mapHeaders = mapHeaders; } @@ -125,6 +149,9 @@ public class NettyHttpConfiguration extends NettyConfiguration { return matchOnUriPrefix; } + /** + * Whether or not Camel 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; } @@ -133,6 +160,12 @@ public class NettyHttpConfiguration extends NettyConfiguration { return bridgeEndpoint; } + /** + * If the option is true, the producer will ignore the Exchange.HTTP_URI header, and use the endpoint's URI for request. + * You may also set the throwExceptionOnFailure to be false to let the producer send all the fault response back. + * The consumer working in the bridge mode will skip the gzip compression and WWW URL form encoding (by adding the Exchange.SKIP_GZIP_ENCODING + * and Exchange.SKIP_WWW_FORM_URLENCODED headers to the consumed exchange). + */ public void setBridgeEndpoint(boolean bridgeEndpoint) { this.bridgeEndpoint = bridgeEndpoint; } @@ -141,6 +174,9 @@ public class NettyHttpConfiguration extends NettyConfiguration { return path; } + /** + * Resource path + */ public void setPath(String path) { this.path = path; } @@ -149,6 +185,15 @@ public class NettyHttpConfiguration extends NettyConfiguration { return disableStreamCache; } + /** + * Determines whether or not the raw input stream from Netty HttpRequest#getContent() is cached or not + * (Camel will read the stream into a in light-weight memory based Stream caching) cache. + * By default Camel will cache the Netty input stream to support reading it multiple times to ensure it Camel + * can retrieve all data from the stream. However you can set this option to true when you for example need to + * access the raw stream, such as streaming it directly to a file or other persistent store. Mind that + * if you enable this option, then you cannot read the Netty stream multiple times out of the box, and you would + * need manually to reset the reader index on the Netty raw stream. + */ public void setDisableStreamCache(boolean disableStreamCache) { this.disableStreamCache = disableStreamCache; } @@ -157,22 +202,21 @@ public class NettyHttpConfiguration extends NettyConfiguration { return send503whenSuspended; } + /** + * Whether to send back HTTP status code 503 when the consumer has been suspended. + * If the option is false then the Netty Acceptor is unbound when the consumer is suspended, so clients cannot connect anymore. + */ public void setSend503whenSuspended(boolean send503whenSuspended) { this.send503whenSuspended = send503whenSuspended; } - public boolean isChunked() { - return chunked; - } - - public void setChunked(boolean chunked) { - this.chunked = chunked; - } - public int getChunkedMaxContentLength() { return chunkedMaxContentLength; } + /** + * Value in bytes the max content length per chunked frame received on the Netty HTTP server. + */ public void setChunkedMaxContentLength(int chunkedMaxContentLength) { this.chunkedMaxContentLength = chunkedMaxContentLength; } http://git-wip-us.apache.org/repos/asf/camel/blob/8739eafe/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpEndpoint.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpEndpoint.java index ac43fdd..736ced4 100644 --- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpEndpoint.java +++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpEndpoint.java @@ -43,7 +43,9 @@ import org.slf4j.LoggerFactory; public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStrategyAware { private static final Logger LOG = LoggerFactory.getLogger(NettyHttpEndpoint.class); + @UriParam private NettyHttpBinding nettyHttpBinding; + @UriParam private HeaderFilterStrategy headerFilterStrategy; @UriParam private NettyHttpConfiguration configuration; @@ -51,7 +53,9 @@ public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStra private boolean traceEnabled; @UriParam private String httpMethodRestrict; + @UriParam private NettySharedHttpServer nettySharedHttpServer; + @UriParam private NettyHttpSecurityConfiguration securityConfiguration; public NettyHttpEndpoint(String endpointUri, NettyHttpComponent component, NettyConfiguration configuration) { @@ -139,6 +143,9 @@ public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStra return nettyHttpBinding; } + /** + * To use a custom org.apache.camel.component.netty4.http.NettyHttpBinding for binding to/from Netty and Camel Message API. + */ public void setNettyHttpBinding(NettyHttpBinding nettyHttpBinding) { this.nettyHttpBinding = nettyHttpBinding; } @@ -147,6 +154,9 @@ public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStra return headerFilterStrategy; } + /** + * To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter headers. + */ public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) { this.headerFilterStrategy = headerFilterStrategy; getNettyHttpBinding().setHeaderFilterStrategy(headerFilterStrategy); @@ -156,6 +166,9 @@ public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStra return traceEnabled; } + /** + * Specifies whether to enable HTTP TRACE for this Netty HTTP consumer. By default TRACE is turned off. + */ public void setTraceEnabled(boolean traceEnabled) { this.traceEnabled = traceEnabled; } @@ -164,6 +177,9 @@ public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStra return httpMethodRestrict; } + /** + * To disable HTTP methods on the Netty HTTP consumer. You can specify multiple separated by comma. + */ public void setHttpMethodRestrict(String httpMethodRestrict) { this.httpMethodRestrict = httpMethodRestrict; } @@ -172,6 +188,9 @@ public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStra return nettySharedHttpServer; } + /** + * To use a shared Netty HTTP server. See Netty HTTP Server Example for more details. + */ public void setNettySharedHttpServer(NettySharedHttpServer nettySharedHttpServer) { this.nettySharedHttpServer = nettySharedHttpServer; } @@ -180,6 +199,9 @@ public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStra return securityConfiguration; } + /** + * Refers to a org.apache.camel.component.netty4.http.NettyHttpSecurityConfiguration for configuring secure web resources. + */ public void setSecurityConfiguration(NettyHttpSecurityConfiguration securityConfiguration) { this.securityConfiguration = securityConfiguration; }