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 2023/10/11 12:56:06 UTC

[camel] branch main updated: CAMEL-19977: camel-core - Java DSL - Add support for using Java 17 text blocks for long URIs which contains line breaks that need to change URI back into a single line for noramlization in Camel.

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 399e565b4c4 CAMEL-19977: camel-core - Java DSL - Add support for using Java 17 text blocks for long URIs which contains line breaks that need to change URI back into a single line for noramlization in Camel.
399e565b4c4 is described below

commit 399e565b4c4832a2429cec3cfcd24b30ea801425
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Oct 11 14:55:22 2023 +0200

    CAMEL-19977: camel-core - Java DSL - Add support for using Java 17 text blocks for long URIs which contains line breaks that need to change URI back into a single line for noramlization in Camel.
---
 docs/user-manual/modules/ROOT/pages/java-dsl.adoc  | 18 +++++
 .../faq/pages/how-do-i-configure-endpoints.adoc    | 77 ++--------------------
 2 files changed, 23 insertions(+), 72 deletions(-)

diff --git a/docs/user-manual/modules/ROOT/pages/java-dsl.adoc b/docs/user-manual/modules/ROOT/pages/java-dsl.adoc
index 7e732f1d52c..7ba005af15a 100644
--- a/docs/user-manual/modules/ROOT/pages/java-dsl.adoc
+++ b/docs/user-manual/modules/ROOT/pages/java-dsl.adoc
@@ -61,6 +61,24 @@ Then we use the xref:components:eips:choice-eip.adoc[Content Based Router] EIP
         .to("file:target/messages/others");
 -------------------------------------------------------
 
+=== Using Text Blocks for long URIs
+
+If you have very long endpoint xref:uris.adoc[uris], then you can declare those in Java text blocks, instead
+of breaking a String into multiple added elements:
+
+[source,java]
+----
+    from("""
+            debezium-postgres:customerEvents
+            ?databasePassword={{myPassword}}
+            &databaseDbname=myDB
+            &databaseHostname=myHost
+            &pollIntervalMs=2000
+            &queryFetchSize=100
+        """)
+        .to("kafka:cheese");
+----
+
 === Routes using Java lambda style
 
 Camel now supports to define Camel routes in Java DSL using Lambda style. This can be beneficial for microservices or serverless where
diff --git a/docs/user-manual/modules/faq/pages/how-do-i-configure-endpoints.adoc b/docs/user-manual/modules/faq/pages/how-do-i-configure-endpoints.adoc
index c0b468d5ba1..2d244e178b7 100644
--- a/docs/user-manual/modules/faq/pages/how-do-i-configure-endpoints.adoc
+++ b/docs/user-manual/modules/faq/pages/how-do-i-configure-endpoints.adoc
@@ -18,74 +18,13 @@ SomeEndpoint endpoint = camelContext.getEndpoint("someURI", SomeEndpoint.class);
 endpoint.setSomething("aValue");
 ----
 
-[[HowdoIconfigureendpoints-UsingCDI]]
-== Using CDI
-
-You can use CDI as dependency injection framework to configure
-your Component or Endpoint instances.
-
-For example, to configure the SJMS component, you can declare a producer method
-in a CDI bean:
-
-[source,java]
-----
-class MyCdiComponent {
-
-  @PropertyInject("jms.maxConnections")
-  int maxConnections;
-
-  @Produces
-  @Named("sjms")
-  @ApplicationScoped
-    SjmsComponent sjms() {
-        SjmsComponent component = new SjmsComponent();
-        component.setConnectionFactory(new ActiveMQConnectionFactory("vm://broker?broker.persistent=false"));
-        component.setConnectionCount(maxConnections);
-        return component;
-    }
-}
-----
-
-Then, the component is lazily looked-up by Camel CDI whenever it is referenced,
-e.g. from the Camel Java DSL:
-
-[source,java]
-----
-class MyCdiRoute extends RouteBuilder {
-
-    @Override
-    public void configure() {
-        from("sjms:sample.queue")
-            .log("Received message [${body}]");
-    }
-}
-----
-
-Besides, endpoints of that component can be injected in any CDI beans, e.g.:
-
-[source,java]
-----
-class MyCdiBean {
-
-    @Inject
-    @Uri("sjms:sample.queue")
-    Endpoint endpoint;
-}
-----
-
 [[HowdoIconfigureendpoints-UsingSpringXML]]
 == Using Spring XML
 
-You can configure your Component or
-Endpoint instances in your Spring
-XML as follows:
+You can configure your Component or Endpoint instances in your Spring XML as `<bean>` as follows:
 
 [source,xml]
 ----
-<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-    <jmxAgent id="agent" disabled="true"/>
-</camelContext>
-
 <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
   <property name="connectionFactory">
     <bean class="org.apache.activemq.ActiveMQConnectionFactory">
@@ -109,7 +48,7 @@ Another approach is to use the URI syntax. The URI syntax supports the
 query notation. So for example with the xref:components::mail-component.adoc[Mail] component
 you can configure the password property via the URI
 
-[source]
+[source,text]
 ----
 pop3://host:port?password=foo
 ----
@@ -145,7 +84,7 @@ using the `#class:fullyQualifiedName` notation.
 If the parameter value starts with a `#class:` sign then Camel will load the
 class with the given name, and create an instanace of the bean using its _no-arg_ constructor:
 
-[source]
+[source,text]
 ----
 file://inbox?sorter=#class:com.foo.MySpecialSorter
 ----
@@ -153,7 +92,7 @@ file://inbox?sorter=#class:com.foo.MySpecialSorter
 If you need to provide parameters to the constructor, then this is also possible
 (limited to numbers, boolean, literal, and null values)
 
-[source]
+[source,text]
 ----
 file://inbox?sorter=#class:com.foo.MySpecialSorter(10, 'Hello world', true)
 ----
@@ -229,7 +168,7 @@ notation:
 And have a `myftp.properties` file with password. Notice we still define
 the `RAW(value)` style to ensure the password is used _as is_:
 
-[source]
+[source,text]
 ----
 myFtpPassword=RAW(se+re?t&23)
 ----
@@ -256,8 +195,6 @@ key, as discussed in the following section.
 
 === Referring to a property placeholder
 
-*Since Camel 3.4*
-
 When using `{\{key}}` in configuring endpoint URIs then Camel will replace the `{\{key}}` while parsing the endpoint URI.
 This has its pros but also a few cons, such as when using sensitive information such as passwords. As we have seen
 in the previous section you can use RAW() syntax. Instead of using RAW() you can use `#property:key` notation,
@@ -278,8 +215,6 @@ as shown in the example below:
 [[HowdoIconfigureendpoints-Configuringurisusingendpointwithbeanpropertystyle]]
 == Configuring URIs using endpoint with bean property style
 
-*Since Camel 2.15*
-
 Sometimes configuring endpoint URIs may have many options, and therefore
 the URI can become long. In Java DSL you can break the URIs into new
 lines as its just Java code, e.g. just concat the `String`. When using XML
@@ -324,8 +259,6 @@ as:
 [[HowdoIconfigureendpoints-Configuringlongurisusingnewlines]]
 == Configuring long URIs using new lines
 
-*Since Camel 2.15*
-
 Sometimes configuring endpoint URIs may have many options, and therefore
 the URI can become long. In Java DSL you can break the URIs into new
 lines as its just Java code, e.g. just concat the `String`. When using XML