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 a29a9a6 CAMEL-13870: Fast property configuration of Camel endpoints. Work in progress. a29a9a6 is described below commit a29a9a66c65d9e33850db306f62d5bec286d86f3 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Aug 21 13:31:51 2019 +0200 CAMEL-13870: Fast property configuration of Camel endpoints. Work in progress. --- .../camel-log/src/main/docs/log-component.adoc | 19 +- .../apache/camel/component/log/LogComponent.java | 2 +- .../apache/camel/component/log/LogEndpoint.java | 11 +- .../endpoint/dsl/LogEndpointBuilderFactory.java | 420 +++++++++++++++++++++ 4 files changed, 446 insertions(+), 6 deletions(-) diff --git a/components/camel-log/src/main/docs/log-component.adoc b/components/camel-log/src/main/docs/log-component.adoc index 1826e98..23a7668 100644 --- a/components/camel-log/src/main/docs/log-component.adoc +++ b/components/camel-log/src/main/docs/log-component.adoc @@ -93,7 +93,7 @@ with the following path and query parameters: |=== -=== Query Parameters (10 parameters): +=== Query Parameters (27 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -109,6 +109,23 @@ with the following path and query parameters: | *marker* (producer) | An optional Marker name to use. | | String | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean +| *maxChars* (formatting) | Limits the number of characters logged per line. | 10000 | int +| *multiline* (formatting) | If enabled then each information is outputted on a newline. | false | boolean +| *showAll* (formatting) | Quick option for turning all options on. (multiline, maxChars has to be manually set if to be used) | false | boolean +| *showBody* (formatting) | Show the message body. | true | boolean +| *showBodyType* (formatting) | Show the body Java type. | true | boolean +| *showCaughtException* (formatting) | f the exchange has a caught exception, show the exception message (no stack trace).A caught exception is stored as a property on the exchange (using the key org.apache.camel.Exchange#EXCEPTION_CAUGHT and for instance a doCatch can catch exceptions. | false | boolean +| *showException* (formatting) | If the exchange has an exception, show the exception message (no stacktrace) | false | boolean +| *showExchangeId* (formatting) | Show the unique exchange ID. | false | boolean +| *showExchangePattern* (formatting) | Shows the Message Exchange Pattern (or MEP for short). | true | boolean +| *showFiles* (formatting) | If enabled Camel will output files | false | boolean +| *showFuture* (formatting) | If enabled Camel will on Future objects wait for it to complete to obtain the payload to be logged. | false | boolean +| *showHeaders* (formatting) | Show the message headers. | false | boolean +| *showProperties* (formatting) | Show the exchange properties. | false | boolean +| *showStackTrace* (formatting) | Show the stack trace, if an exchange has an exception. Only effective if one of showAll, showException or showCaughtException are enabled. | false | boolean +| *showStreams* (formatting) | Whether Camel should show stream bodies or not (eg such as java.io.InputStream). Beware if you enable this option then you may not be able later to access the message body as the stream have already been read by this logger. To remedy this you will have to use Stream Caching. | false | boolean +| *skipBodyLineSeparator* (formatting) | Whether to skip line separators when logging the message body.This allows to log the message body in one line, setting this option to false will preserve any line separators from the body, which then will log the body as is. | true | boolean +| *style* (formatting) | Sets the outputs style to use. | Default | OutputStyle |=== // endpoint options: END diff --git a/components/camel-log/src/main/java/org/apache/camel/component/log/LogComponent.java b/components/camel-log/src/main/java/org/apache/camel/component/log/LogComponent.java index 6964cd5d..d9c4a4c 100644 --- a/components/camel-log/src/main/java/org/apache/camel/component/log/LogComponent.java +++ b/components/camel-log/src/main/java/org/apache/camel/component/log/LogComponent.java @@ -71,7 +71,7 @@ public class LogComponent extends DefaultComponent { ExchangeFormatter localFormatter = getCamelContext().getRegistry().lookupByNameAndType("logFormatter", ExchangeFormatter.class); if (localFormatter != null) { setProperties(localFormatter, parameters); - } else if (localFormatter == null && exchangeFormatter != null) { + } else if (exchangeFormatter != null) { // do not set properties, the exchangeFormatter is explicitly set, therefore the // user would have set its properties explicitly too localFormatter = exchangeFormatter; diff --git a/components/camel-log/src/main/java/org/apache/camel/component/log/LogEndpoint.java b/components/camel-log/src/main/java/org/apache/camel/component/log/LogEndpoint.java index b2bb66b..3da4aca 100644 --- a/components/camel-log/src/main/java/org/apache/camel/component/log/LogEndpoint.java +++ b/components/camel-log/src/main/java/org/apache/camel/component/log/LogEndpoint.java @@ -62,12 +62,11 @@ public class LogEndpoint extends ProcessorEndpoint { private Boolean groupActiveOnly; @UriParam private Long groupDelay; - // we want to include the uri options of the DefaultExchangeFormatter - // TODO: Make this correct instead of cheating - //@UriParam(label = "advanced") - //private DefaultExchangeFormatter exchangeFormatter; @UriParam private Boolean logMask; + // we want to include the uri options of the DefaultExchangeFormatter as additional configurations in the docs + @UriParam(label = "advanced") + private final DefaultExchangeFormatter formatter = new DefaultExchangeFormatter(); public LogEndpoint() { } @@ -81,6 +80,10 @@ public class LogEndpoint extends ProcessorEndpoint { setLogger(logger); } + public DefaultExchangeFormatter getFormatter() { + return formatter; + } + @Override protected void doStart() throws Exception { if (logger == null) { diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/LogEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/LogEndpointBuilderFactory.java index 7613db1..9d85afa 100644 --- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/LogEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/LogEndpointBuilderFactory.java @@ -178,6 +178,416 @@ public interface LogEndpointBuilderFactory { setProperty("marker", marker); return this; } + /** + * Limits the number of characters logged per line. + * + * The option is a: <code>int</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder maxChars(int maxChars) { + setProperty("maxChars", maxChars); + return this; + } + /** + * Limits the number of characters logged per line. + * + * The option will be converted to a <code>int</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder maxChars(String maxChars) { + setProperty("maxChars", maxChars); + return this; + } + /** + * If enabled then each information is outputted on a newline. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder multiline(boolean multiline) { + setProperty("multiline", multiline); + return this; + } + /** + * If enabled then each information is outputted on a newline. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder multiline(String multiline) { + setProperty("multiline", multiline); + return this; + } + /** + * Quick option for turning all options on. (multiline, maxChars has to + * be manually set if to be used). + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showAll(boolean showAll) { + setProperty("showAll", showAll); + return this; + } + /** + * Quick option for turning all options on. (multiline, maxChars has to + * be manually set if to be used). + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showAll(String showAll) { + setProperty("showAll", showAll); + return this; + } + /** + * Show the message body. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showBody(boolean showBody) { + setProperty("showBody", showBody); + return this; + } + /** + * Show the message body. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showBody(String showBody) { + setProperty("showBody", showBody); + return this; + } + /** + * Show the body Java type. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showBodyType(boolean showBodyType) { + setProperty("showBodyType", showBodyType); + return this; + } + /** + * Show the body Java type. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showBodyType(String showBodyType) { + setProperty("showBodyType", showBodyType); + return this; + } + /** + * f the exchange has a caught exception, show the exception message (no + * stack trace).A caught exception is stored as a property on the + * exchange (using the key org.apache.camel.Exchange#EXCEPTION_CAUGHT + * and for instance a doCatch can catch exceptions. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showCaughtException( + boolean showCaughtException) { + setProperty("showCaughtException", showCaughtException); + return this; + } + /** + * f the exchange has a caught exception, show the exception message (no + * stack trace).A caught exception is stored as a property on the + * exchange (using the key org.apache.camel.Exchange#EXCEPTION_CAUGHT + * and for instance a doCatch can catch exceptions. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showCaughtException( + String showCaughtException) { + setProperty("showCaughtException", showCaughtException); + return this; + } + /** + * If the exchange has an exception, show the exception message (no + * stacktrace). + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showException(boolean showException) { + setProperty("showException", showException); + return this; + } + /** + * If the exchange has an exception, show the exception message (no + * stacktrace). + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showException(String showException) { + setProperty("showException", showException); + return this; + } + /** + * Show the unique exchange ID. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showExchangeId(boolean showExchangeId) { + setProperty("showExchangeId", showExchangeId); + return this; + } + /** + * Show the unique exchange ID. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showExchangeId(String showExchangeId) { + setProperty("showExchangeId", showExchangeId); + return this; + } + /** + * Shows the Message Exchange Pattern (or MEP for short). + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showExchangePattern( + boolean showExchangePattern) { + setProperty("showExchangePattern", showExchangePattern); + return this; + } + /** + * Shows the Message Exchange Pattern (or MEP for short). + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showExchangePattern( + String showExchangePattern) { + setProperty("showExchangePattern", showExchangePattern); + return this; + } + /** + * If enabled Camel will output files. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showFiles(boolean showFiles) { + setProperty("showFiles", showFiles); + return this; + } + /** + * If enabled Camel will output files. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showFiles(String showFiles) { + setProperty("showFiles", showFiles); + return this; + } + /** + * If enabled Camel will on Future objects wait for it to complete to + * obtain the payload to be logged. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showFuture(boolean showFuture) { + setProperty("showFuture", showFuture); + return this; + } + /** + * If enabled Camel will on Future objects wait for it to complete to + * obtain the payload to be logged. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showFuture(String showFuture) { + setProperty("showFuture", showFuture); + return this; + } + /** + * Show the message headers. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showHeaders(boolean showHeaders) { + setProperty("showHeaders", showHeaders); + return this; + } + /** + * Show the message headers. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showHeaders(String showHeaders) { + setProperty("showHeaders", showHeaders); + return this; + } + /** + * Show the exchange properties. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showProperties(boolean showProperties) { + setProperty("showProperties", showProperties); + return this; + } + /** + * Show the exchange properties. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showProperties(String showProperties) { + setProperty("showProperties", showProperties); + return this; + } + /** + * Show the stack trace, if an exchange has an exception. Only effective + * if one of showAll, showException or showCaughtException are enabled. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showStackTrace(boolean showStackTrace) { + setProperty("showStackTrace", showStackTrace); + return this; + } + /** + * Show the stack trace, if an exchange has an exception. Only effective + * if one of showAll, showException or showCaughtException are enabled. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showStackTrace(String showStackTrace) { + setProperty("showStackTrace", showStackTrace); + return this; + } + /** + * Whether Camel should show stream bodies or not (eg such as + * java.io.InputStream). Beware if you enable this option then you may + * not be able later to access the message body as the stream have + * already been read by this logger. To remedy this you will have to use + * Stream Caching. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showStreams(boolean showStreams) { + setProperty("showStreams", showStreams); + return this; + } + /** + * Whether Camel should show stream bodies or not (eg such as + * java.io.InputStream). Beware if you enable this option then you may + * not be able later to access the message body as the stream have + * already been read by this logger. To remedy this you will have to use + * Stream Caching. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder showStreams(String showStreams) { + setProperty("showStreams", showStreams); + return this; + } + /** + * Whether to skip line separators when logging the message body.This + * allows to log the message body in one line, setting this option to + * false will preserve any line separators from the body, which then + * will log the body as is. + * + * The option is a: <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder skipBodyLineSeparator( + boolean skipBodyLineSeparator) { + setProperty("skipBodyLineSeparator", skipBodyLineSeparator); + return this; + } + /** + * Whether to skip line separators when logging the message body.This + * allows to log the message body in one line, setting this option to + * false will preserve any line separators from the body, which then + * will log the body as is. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder skipBodyLineSeparator( + String skipBodyLineSeparator) { + setProperty("skipBodyLineSeparator", skipBodyLineSeparator); + return this; + } + /** + * Sets the outputs style to use. + * + * The option is a: + * <code>org.apache.camel.support.processor.DefaultExchangeFormatter$OutputStyle</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder style(OutputStyle style) { + setProperty("style", style); + return this; + } + /** + * Sets the outputs style to use. + * + * The option will be converted to a + * <code>org.apache.camel.support.processor.DefaultExchangeFormatter$OutputStyle</code> type. + * + * Group: formatting + */ + default LogEndpointBuilder style(String style) { + setProperty("style", style); + return this; + } } /** @@ -240,6 +650,16 @@ public interface LogEndpointBuilderFactory { return this; } } + + /** + * Proxy enum for + * <code>org.apache.camel.support.processor.DefaultExchangeFormatter$OutputStyle</code> enum. + */ + enum OutputStyle { + Default, + Tab, + Fixed; + } /** * Log (camel-log) * The log component logs message exchanges to the underlying logging