This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch worktree-camel-23789-routebuilder-cleanup in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6acd66dfe67b232b29a473ac39c3d1e98c14e705 Author: Claus Ibsen <[email protected]> AuthorDate: Thu Jun 18 22:19:54 2026 +0200 CAMEL-23789: Remove RouteBuilder boilerplate and toF() from component docs Strip RouteBuilder class definitions, configure() methods, and context.addRoutes() wrappers from doc examples, leaving just the route DSL. Replace toF() format strings with property placeholders or inlined URIs. This removes Java-specific noise and makes examples easier to translate to XML/YAML DSL tabs. Co-Authored-By: Claude <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../camel-grok/src/main/docs/grok-dataformat.adoc | 16 ++--- .../camel-jt400/src/main/docs/jt400-component.adoc | 53 +++++--------- .../src/main/docs/kubernetes-job-component.adoc | 2 +- .../src/main/docs/kubernetes-summary.adoc | 8 +-- .../camel-ldap/src/main/docs/ldap-component.adoc | 26 +------ .../src/main/docs/lucene-component.adoc | 84 ++++++---------------- .../camel-netty/src/main/docs/netty-component.adoc | 62 +++------------- .../src/main/docs/openapi-java.adoc | 48 +++++-------- .../src/main/docs/platform-http-vertx.adoc | 29 ++------ .../camel-pqc/src/main/docs/pqc-component.adoc | 56 ++++++--------- .../camel-ref/src/main/docs/ref-component.adoc | 11 +-- .../camel-rss/src/main/docs/rss-component.adoc | 13 ++-- .../src/main/docs/sap-netweaver-component.adoc | 18 +---- components/camel-shiro/src/main/docs/shiro.adoc | 72 +++++++------------ .../src/main/docs/thymeleaf-component.adoc | 13 +--- .../src/main/docs/velocity-component.adoc | 13 +--- .../camel-wasm/src/main/docs/wasm-language.adoc | 27 +------ .../src/main/docs/xmlSecurity-dataformat.adoc | 12 ++-- .../src/main/docs/xslt-saxon-component.adoc | 10 +-- 19 files changed, 152 insertions(+), 421 deletions(-) diff --git a/components/camel-grok/src/main/docs/grok-dataformat.adoc b/components/camel-grok/src/main/docs/grok-dataformat.adoc index f1b7f4237822..58425d730bdd 100644 --- a/components/camel-grok/src/main/docs/grok-dataformat.adoc +++ b/components/camel-grok/src/main/docs/grok-dataformat.adoc @@ -132,20 +132,14 @@ All https://github.com/thekrakken/java-grok/tree/master/src/main/resources/patte Camel Grok DataFormat supports plugable patterns, which are auto loaded from Camel Registry. You can register patterns with Java DSL and Spring DSL: -._Java-only: registering a custom Grok pattern in a `RouteBuilder`_ +._Java-only: registering a custom Grok pattern_ [source,java] ---- -public class MyRouteBuilder extends RouteBuilder { +bindToRegistry("myCustomPatternBean", new GrokPattern("FOOBAR", "foo|bar")); - @Override - public void configure() throws Exception { - bindToRegistry("myCustomPatternBean", new GrokPattern("FOOBAR", "foo|bar")); - - from("direct:in") - .unmarshal().grok("%{FOOBAR:fooBar}") - .to("log:out"); - } -} +from("direct:in") + .unmarshal().grok("%{FOOBAR:fooBar}") + .to("log:out"); ---- In Spring XML, you register the custom pattern as a bean: diff --git a/components/camel-jt400/src/main/docs/jt400-component.adoc b/components/camel-jt400/src/main/docs/jt400-component.adoc index f0cc078d47ab..3f2dac7b51c3 100644 --- a/components/camel-jt400/src/main/docs/jt400-component.adoc +++ b/components/camel-jt400/src/main/docs/jt400-component.adoc @@ -107,16 +107,10 @@ library `BEATLES` on a system named `LIVERPOOL`. + Another user connects to the same data queue to receive the information from the data queue and forward it to the `mock:ringo` endpoint. -._Java-only: RouteBuilder class definition_ [source,java] ---- -public class Jt400RouteBuilder extends RouteBuilder { - @Override - public void configure() throws Exception { - from(“direct:george”).to(“jt400://GEORGE:EGROEG@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.DTAQ”); - from(“jt400://RINGO:OGNIR@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.DTAQ”).to(“mock:ringo”); - } -} +from(“direct:george”).to(“jt400://GEORGE:EGROEG@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.DTAQ”); +from(“jt400://RINGO:OGNIR@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.DTAQ”).to(“mock:ringo”); ---- === Program call examples @@ -127,42 +121,31 @@ program “compute” in the library “assets”. This program will write the output values in the second and third parameters. All the parameters will be sent to the direct:play endpoint. -._Java-only: RouteBuilder class definition_ [source,java] ---- -public class Jt400RouteBuilder extends RouteBuilder { - @Override - public void configure() throws Exception { - from(“direct:work”).to(“jt400://GRUPO:ATWORK@server/QSYS.LIB/assets.LIB/compute.PGM?fieldsLength=10,10,512&ouputFieldsIdx=2,3”).to(“direct:play”); - } -} +from(“direct:work”).to(“jt400://GRUPO:ATWORK@server/QSYS.LIB/assets.LIB/compute.PGM?fieldsLength=10,10,512&ouputFieldsIdx=2,3”).to(“direct:play”); ---- In this example, the camel route will call the QUSRTVUS API to retrieve 16 bytes from data area “MYUSRSPACE” in the “MYLIB” library. -._Java-only: RouteBuilder class definition with lambda expression_ +._Java-only: uses lambda Processor to set program call parameters_ [source,java] ---- -public class Jt400RouteBuilder extends RouteBuilder { - @Override - public void configure() throws Exception { - from(“timer://foo?period=60000”) - .process( exchange -> { - String usrSpc = “MYUSRSPACEMYLIB “; - Object[] parms = new Object[] { - usrSpc, // Qualified user space name - 1, // starting position - 16, // length of data - “” // output - }; - exchange.getIn().setBody(parms); - }) - .to(“jt400://*CURRENT:*CURRENt@localhost/qsys.lib/QUSRTVUS.PGM?fieldsLength=20,4,4,16&outputFieldsIdx=3”) - .setBody(simple(“${body[3]}”)) - .to(“direct:foo”); - } -} +from(“timer://foo?period=60000”) + .process( exchange -> { + String usrSpc = “MYUSRSPACEMYLIB “; + Object[] parms = new Object[] { + usrSpc, // Qualified user space name + 1, // starting position + 16, // length of data + “” // output + }; + exchange.getIn().setBody(parms); + }) + .to(“jt400://*CURRENT:*CURRENt@localhost/qsys.lib/QUSRTVUS.PGM?fieldsLength=20,4,4,16&outputFieldsIdx=3”) + .setBody(simple(“${body[3]}”)) + .to(“direct:foo”); ---- === Writing to keyed data queues diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-job-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-job-component.adoc index d302afcfe3ed..cb9f79ab8f50 100644 --- a/components/camel-kubernetes/src/main/docs/kubernetes-job-component.adoc +++ b/components/camel-kubernetes/src/main/docs/kubernetes-job-component.adoc @@ -123,7 +123,7 @@ public class KubernetesCreateJob extends RouteBuilder { exchange.getIn().setHeader("CamelKubernetesJobSpec", generateJobSpec()); }) - .toF("kubernetes-job:///{{kubernetes-master-url}}?oauthToken={{kubernetes-oauth-token:}}&operation=" + "createJob") + .to("kubernetes-job:///{{kubernetes-master-url}}?oauthToken={{kubernetes-oauth-token:}}&operation=createJob") .log("Job created:") .process(exchange -> { System.out.println(exchange.getIn().getBody()); diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-summary.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-summary.adoc index 1785aa4b43ae..e305624c9a94 100644 --- a/components/camel-kubernetes/src/main/docs/kubernetes-summary.adoc +++ b/components/camel-kubernetes/src/main/docs/kubernetes-summary.adoc @@ -39,22 +39,20 @@ Here we show some examples of producer using camel-kubernetes. === Create a pod -._Java-only: uses toF() with runtime variables for host and auth token_ [source,java] ---- from("direct:createPod") - .toF("kubernetes-pods://%s?oauthToken=%s&operation=createPod", host, authToken); + .to("kubernetes-pods://{{kubernetes-host}}?oauthToken={{kubernetes-token}}&operation=createPod"); ---- By using the `CamelKubernetesPodSpec` header, you can specify your PodSpec and pass it to this operation. === Delete a pod -._Java-only: uses toF() with runtime variables for host and auth token_ [source,java] ---- -from("direct:createPod") - .toF("kubernetes-pods://%s?oauthToken=%s&operation=deletePod", host, authToken); +from("direct:deletePod") + .to("kubernetes-pods://{{kubernetes-host}}?oauthToken={{kubernetes-token}}&operation=deletePod"); ---- By using the `CamelKubernetesPodName` header, you can specify your Pod name and pass it to this operation. diff --git a/components/camel-ldap/src/main/docs/ldap-component.adoc b/components/camel-ldap/src/main/docs/ldap-component.adoc index fe08778461f2..be59021d6242 100644 --- a/components/camel-ldap/src/main/docs/ldap-component.adoc +++ b/components/camel-ldap/src/main/docs/ldap-component.adoc @@ -175,31 +175,7 @@ props.setProperty(Context.SECURITY_CREDENTIALS, "secret"); DefaultRegistry reg = new DefaultRegistry(); reg.bind("myldap", new InitialLdapContext(props, null)); -CamelContext context = new DefaultCamelContext(reg); -context.addRoutes( - new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start").to("ldap:myldap?base=ou=test"); - } - } -); -context.start(); - -ProducerTemplate template = context.createProducerTemplate(); - -Endpoint endpoint = context.getEndpoint("direct:start"); -Exchange exchange = endpoint.createExchange(); -exchange.getIn().setBody("(uid=test)"); -Exchange out = template.send(endpoint, exchange); - -Collection<SearchResult> data = out.getMessage().getBody(Collection.class); -assert data != null; -assert !data.isEmpty(); - -System.out.println(out.getMessage().getBody()); - -context.stop(); +from("direct:start").to("ldap:myldap?base=ou=test"); ---- == Configuring SSL diff --git a/components/camel-lucene/src/main/docs/lucene-component.adoc b/components/camel-lucene/src/main/docs/lucene-component.adoc index 58ec7c69c6a7..a7d1c07cc84f 100644 --- a/components/camel-lucene/src/main/docs/lucene-component.adoc +++ b/components/camel-lucene/src/main/docs/lucene-component.adoc @@ -83,17 +83,11 @@ Lucene usage samples. === Example 1: Creating a Lucene index -._Java-only: RouteBuilder class definition_ [source,java] ---- -RouteBuilder builder = new RouteBuilder() { - public void configure() { - from("direct:start"). - to("lucene:whitespaceQuotesIndex:insert? - analyzer=#whitespaceAnalyzer&indexDir=#whitespace&srcDir=#load_dir"). - to("mock:result"); - } -}; +from("direct:start") + .to("lucene:whitespaceQuotesIndex:insert?analyzer=#whitespaceAnalyzer&indexDir=#whitespace&srcDir=#load_dir") + .to("mock:result"); ---- === Example 2: Loading properties into the JNDI registry in the Camel Context @@ -110,69 +104,31 @@ registry.bind("whitespaceAnalyzer", new WhitespaceAnalyzer()); === Example 2: Performing searches using a Query Producer -._Java-only: RouteBuilder with inline Processor and Java constants_ [source,java] ---- -RouteBuilder builder = new RouteBuilder() { - public void configure() { - from("direct:start"). - setHeader("CamelLuceneQuery", constant("Seinfeld")). - to("lucene:searchIndex:query? - analyzer=#whitespaceAnalyzer&indexDir=#whitespace&maxHits=20"). - to("direct:next"); - - from("direct:next").process(new Processor() { - public void process(Exchange exchange) throws Exception { - Hits hits = exchange.getIn().getBody(Hits.class); - printResults(hits); - } - - private void printResults(Hits hits) { - LOG.debug("Number of hits: " + hits.getNumberOfHits()); - for (int i = 0; i < hits.getNumberOfHits(); i++) { - LOG.debug("Hit " + i + " Index Location:" + hits.getHit().get(i).getHitLocation()); - LOG.debug("Hit " + i + " Score:" + hits.getHit().get(i).getScore()); - LOG.debug("Hit " + i + " Data:" + hits.getHit().get(i).getData()); - } - } - }).to("mock:searchResult"); - } -}; +from("direct:start") + .setHeader("CamelLuceneQuery", constant("Seinfeld")) + .to("lucene:searchIndex:query?analyzer=#whitespaceAnalyzer&indexDir=#whitespace&maxHits=20") + .to("direct:next"); + +from("direct:next") + .to("bean:searchResultProcessor") + .to("mock:searchResult"); ---- === Example 3: Performing searches using a Query Processor -._Java-only: RouteBuilder with LuceneQueryProcessor and inline Processor_ +._Java-only: uses LuceneQueryProcessor_ [source,java] ---- -RouteBuilder builder = new RouteBuilder() { - public void configure() { - try { - from("direct:start"). - setHeader("CamelLuceneQuery", constant("Rodney Dangerfield")). - process(new LuceneQueryProcessor("target/stdindexDir", analyzer, null, 20)). - to("direct:next"); - } catch (Exception e) { - e.printStackTrace(); - } - - from("direct:next").process(new Processor() { - public void process(Exchange exchange) throws Exception { - Hits hits = exchange.getIn().getBody(Hits.class); - printResults(hits); - } - - private void printResults(Hits hits) { - LOG.debug("Number of hits: " + hits.getNumberOfHits()); - for (int i = 0; i < hits.getNumberOfHits(); i++) { - LOG.debug("Hit " + i + " Index Location:" + hits.getHit().get(i).getHitLocation()); - LOG.debug("Hit " + i + " Score:" + hits.getHit().get(i).getScore()); - LOG.debug("Hit " + i + " Data:" + hits.getHit().get(i).getData()); - } - } - }).to("mock:searchResult"); - } -}; +from("direct:start") + .setHeader("CamelLuceneQuery", constant("Rodney Dangerfield")) + .process(new LuceneQueryProcessor("target/stdindexDir", analyzer, null, 20)) + .to("direct:next"); + +from("direct:next") + .to("bean:searchResultProcessor") + .to("mock:searchResult"); ---- diff --git a/components/camel-netty/src/main/docs/netty-component.adoc b/components/camel-netty/src/main/docs/netty-component.adoc index fae4f21792e8..8dde795569b1 100644 --- a/components/camel-netty/src/main/docs/netty-component.adoc +++ b/components/camel-netty/src/main/docs/netty-component.adoc @@ -382,22 +382,8 @@ and instantiated/utilized on a Camel route in the following way Registry registry = camelContext.getRegistry(); ServerInitializerFactory factory = new TestServerInitializerFactory(); registry.bind("spf", factory); -context.addRoutes(new RouteBuilder() { - public void configure() { - String netty_ssl_endpoint = - "netty:tcp://0.0.0.0:5150?serverInitializerFactory=#spf" - String return_string = - "When You Go Home, Tell Them Of Us And Say," - + "For Your Tomorrow, We Gave Our Today."; - - from(netty_ssl_endpoint) - .process(new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getOut().setBody(return_string); - } - } - } -}); +from("netty:tcp://0.0.0.0:5150?serverInitializerFactory=#spf") + .setBody(constant("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.")); ---- === Reusing Netty boss and worker thread pools @@ -604,31 +590,16 @@ public ChannelHandler getDecoder() throws Exception { }; } -RouteBuilder builder = new RouteBuilder() { - public void configure() { - from("netty:udp://0.0.0.0:5155?sync=true&decoders=#decoder") - .process(new Processor() { - public void process(Exchange exchange) throws Exception { - Poetry poetry = (Poetry) exchange.getIn().getBody(); - // Process poetry in some way - exchange.getOut().setBody("Message received); - } - } - } -}; +from("netty:udp://0.0.0.0:5155?sync=true&decoders=#decoder") + .to("bean:poetryProcessor"); ---- === A TCP-based Netty consumer endpoint using One-way communication -._Java-only: Java RouteBuilder class_ [source,java] ---- -RouteBuilder builder = new RouteBuilder() { - public void configure() { - from("netty:tcp://0.0.0.0:5150") - .to("mock:result"); - } -}; +from("netty:tcp://0.0.0.0:5150") + .to("mock:result"); ---- === An SSL/TCP-based Netty consumer endpoint using Request-Reply communication @@ -686,26 +657,11 @@ Spring DSL based configuration of endpoint [[Netty-UsingBasicSSLTLSconfigurationontheJettyComponent]] Using Basic SSL/TLS configuration on the Jetty Component -._Java-only: Java programmatic SSL route configuration_ +._Java-only: SSL route configuration_ [source,java] ---- -context.addRoutes(new RouteBuilder() { - public void configure() { - String netty_ssl_endpoint = - "netty:tcp://0.0.0.0:5150?sync=true&ssl=true&passphrase=changeit" - + "&keyStoreResource=file:src/test/resources/keystore.jks&trustStoreResource=file:src/test/resources/keystore.jks"; - String return_string = - "When You Go Home, Tell Them Of Us And Say," - + "For Your Tomorrow, We Gave Our Today."; - - from(netty_ssl_endpoint) - .process(new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getOut().setBody(return_string); - } - } - } -}); +from("netty:tcp://0.0.0.0:5150?sync=true&ssl=true&passphrase=changeit&keyStoreResource=file:src/test/resources/keystore.jks&trustStoreResource=file:src/test/resources/keystore.jks") + .setBody(constant("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.")); ---- [[Netty-GettingaccesstoSSLSessionandtheclientcertificate]] diff --git a/components/camel-openapi-java/src/main/docs/openapi-java.adoc b/components/camel-openapi-java/src/main/docs/openapi-java.adoc index 61f08ca85c69..4a80952be374 100644 --- a/components/camel-openapi-java/src/main/docs/openapi-java.adoc +++ b/components/camel-openapi-java/src/main/docs/openapi-java.adoc @@ -38,38 +38,26 @@ the REST components (without the need for servlet) You can enable the OpenApi api from the rest-dsl by configuring the `apiContextPath` dsl as shown below: -._Java-only: RouteBuilder with Rest DSL configuration and class literals_ +._Java-only: Rest DSL configuration with class literals_ [source,java] ---- -public class UserRouteBuilder extends RouteBuilder { - @Override - public void configure() throws Exception { - // configure we want to use servlet as the component for the rest DSL, - // and we enable json binding mode - restConfiguration().component("netty-http").bindingMode(RestBindingMode.json) - // and output using pretty print - .dataFormatProperty("prettyPrint", "true") - // setup context path and port number that netty will use - .contextPath("/").port(8080) - // add OpenApi api-doc out of the box - .apiContextPath("/api-doc") - .apiProperty("api.title", "User API").apiProperty("api.version", "1.2.3") - // and enable CORS - .apiProperty("cors", "true"); - - // this user REST service is json only - rest("/user").description("User rest service") - .consumes("application/json").produces("application/json") - .get("/{id}").description("Find user by id").outType(User.class) - .param().name("id").type(path).description("The id of the user to get").dataType("int").endParam() - .to("bean:userService?method=getUser(${header.id})") - .put().description("Updates or create a user").type(User.class) - .param().name("body").type(body).description("The user to update or create").endParam() - .to("bean:userService?method=updateUser") - .get("/findAll").description("Find all users").outType(User[].class) - .to("bean:userService?method=listUsers"); - } -} +restConfiguration().component("netty-http").bindingMode(RestBindingMode.json) + .dataFormatProperty("prettyPrint", "true") + .contextPath("/").port(8080) + .apiContextPath("/api-doc") + .apiProperty("api.title", "User API").apiProperty("api.version", "1.2.3") + .apiProperty("cors", "true"); + +rest("/user").description("User rest service") + .consumes("application/json").produces("application/json") + .get("/{id}").description("Find user by id").outType(User.class) + .param().name("id").type(path).description("The id of the user to get").dataType("int").endParam() + .to("bean:userService?method=getUser(${header.id})") + .put().description("Updates or create a user").type(User.class) + .param().name("body").type(body).description("The user to update or create").endParam() + .to("bean:userService?method=updateUser") + .get("/findAll").description("Find all users").outType(User[].class) + .to("bean:userService?method=listUsers"); ---- diff --git a/components/camel-platform-http-vertx/src/main/docs/platform-http-vertx.adoc b/components/camel-platform-http-vertx/src/main/docs/platform-http-vertx.adoc index 21570df32095..26549b7f9fb1 100644 --- a/components/camel-platform-http-vertx/src/main/docs/platform-http-vertx.adoc +++ b/components/camel-platform-http-vertx/src/main/docs/platform-http-vertx.adoc @@ -42,26 +42,17 @@ header named `orderid` with value `123`. In addition to the implementation of the `PlatformHttp` SPI based on Vert.x, this module provides a Vert.x based HTTP server compatible with the `VertxPlatformHttpEngine`: -._Java-only: programmatic CamelContext and VertxPlatformHttpServer setup_ +._Java-only: programmatic VertxPlatformHttpServer setup_ [source,java] ---- -final int port = AvailablePortFinder.getNextAvailable(); -final CamelContext context = new DefaultCamelContext(); - VertxPlatformHttpServerConfiguration conf = new VertxPlatformHttpServerConfiguration(); conf.setBindPort(port); context.addService(new VertxPlatformHttpServer(conf)); -context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("platform-http:/test") - .routeId("get") - .setBody().constant("Hello from Camel's PlatformHttp service"); - } -}); -context.start(); +from("platform-http:/test") + .routeId("get") + .setBody().constant("Hello from Camel's PlatformHttp service"); ---- == Implementing a reverse proxy @@ -178,14 +169,8 @@ authenticationConfig.setEnabled(true); conf.setAuthenticationConfig(authenticationConfig); context.addService(new VertxPlatformHttpServer(conf)); -context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("platform-http:/test") - .routeId("get") - .setBody().constant("Hello from Camel's PlatformHttp service"); - } -}); -context.start(); +from("platform-http:/test") + .routeId("get") + .setBody().constant("Hello from Camel's PlatformHttp service"); ---- \ No newline at end of file diff --git a/components/camel-pqc/src/main/docs/pqc-component.adoc b/components/camel-pqc/src/main/docs/pqc-component.adoc index 8e6dc49da967..3cf9c5206799 100644 --- a/components/camel-pqc/src/main/docs/pqc-component.adoc +++ b/components/camel-pqc/src/main/docs/pqc-component.adoc @@ -791,24 +791,21 @@ As example you could use the secret key to dynamically instruct the CryptoDataFo ._Java-only: extracting secret key from encapsulation for downstream CryptoDataFormat usage_ [source,java] -------------------------------------------------------------------------------- - CryptoDataFormat cryptoFormat = new CryptoDataFormat("AES", null); - return new RouteBuilder() { - @Override - public void configure() { - from("direct:encapsulate").to("pqc:keyenc?operation=generateSecretKeyEncapsulation&symmetricKeyAlgorithm=AES") - .to("mock:encapsulate") - .to("pqc:keyenc?operation=extractSecretKeyEncapsulation&symmetricKeyAlgorithm=AES") - .to("pqc:keyenc?operation=extractSecretKeyFromEncapsulation&symmetricKeyAlgorithm=AES") - .setHeader(CryptoDataFormat.KEY, body()) - .setBody(constant("Hello")) - .marshal(cryptoFormat) - .log("Encrypted ${body}") - .to("mock:encrypted") - .unmarshal(cryptoFormat) - .log("Unencrypted ${body}") - .to("mock:unencrypted"); - ; - } +CryptoDataFormat cryptoFormat = new CryptoDataFormat("AES", null); + +from("direct:encapsulate") + .to("pqc:keyenc?operation=generateSecretKeyEncapsulation&symmetricKeyAlgorithm=AES") + .to("mock:encapsulate") + .to("pqc:keyenc?operation=extractSecretKeyEncapsulation&symmetricKeyAlgorithm=AES") + .to("pqc:keyenc?operation=extractSecretKeyFromEncapsulation&symmetricKeyAlgorithm=AES") + .setHeader(CryptoDataFormat.KEY, body()) + .setBody(constant("Hello")) + .marshal(cryptoFormat) + .log("Encrypted ${body}") + .to("mock:encrypted") + .unmarshal(cryptoFormat) + .log("Unencrypted ${body}") + .to("mock:unencrypted"); -------------------------------------------------------------------------------- This could be used to generate a secret key, protect it through Encapsulation and KEM approach and re-use it once extracted. @@ -3240,24 +3237,11 @@ void testPQCDataFormatRoundTrip() throws Exception { pqcFormat.setKeyEncapsulationAlgorithm("MLKEM"); pqcFormat.setSymmetricKeyAlgorithm("AES"); - // Create route - context.addRoutes(new RouteBuilder() { - @Override - public void configure() { - from("direct:start") - .marshal(pqcFormat) - .to("mock:encrypted") - .unmarshal(pqcFormat) - .to("mock:decrypted"); - } - }); - - // Test - String original = "Sensitive data"; - template.sendBody("direct:start", original); - - MockEndpoint encrypted = getMockEndpoint("mock:encrypted"); - MockEndpoint decrypted = getMockEndpoint("mock:decrypted"); + from("direct:start") + .marshal(pqcFormat) + .to("mock:encrypted") + .unmarshal(pqcFormat) + .to("mock:decrypted"); encrypted.assertIsSatisfied(); decrypted.assertIsSatisfied(); diff --git a/components/camel-ref/src/main/docs/ref-component.adoc b/components/camel-ref/src/main/docs/ref-component.adoc index 49a92cf569ce..0321cb334ca2 100644 --- a/components/camel-ref/src/main/docs/ref-component.adoc +++ b/components/camel-ref/src/main/docs/ref-component.adoc @@ -82,17 +82,10 @@ context.getRegistry().bind("endpoint2", context.getEndpoint("log:end")); Use the `ref` URI scheme to refer to endpoint's bond to the Camel registry: -._Java-only: RouteBuilder class definition_ [source,java] ---- -public class MyRefRoutes extends RouteBuilder { - @Override - public void configure() { - // direct:start -> log:end - from("ref:endpoint1") - .to("ref:endpoint2"); - } -} +from("ref:endpoint1") + .to("ref:endpoint2"); ---- diff --git a/components/camel-rss/src/main/docs/rss-component.adoc b/components/camel-rss/src/main/docs/rss-component.adoc index 0ba653f53d6c..04a69650777b 100644 --- a/components/camel-rss/src/main/docs/rss-component.adoc +++ b/components/camel-rss/src/main/docs/rss-component.adoc @@ -219,15 +219,10 @@ protected RoutesBuilder createRouteBuilder() throws Exception { } }); - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("timer://mytimer?fixedRate=false&period=60&synchronous=true") - .to("http://feeds.aps.org/rss/recent/prstper.xml?httpClientConfigurer=myHttpClientConfigurer") - .unmarshal(new RssDataFormat()) // Convert raw response to structured RSS - .to("mock:result"); - } - }; + from("timer://mytimer?fixedRate=false&period=60&synchronous=true") + .to("http://feeds.aps.org/rss/recent/prstper.xml?httpClientConfigurer=myHttpClientConfigurer") + .unmarshal(new RssDataFormat()) + .to("mock:result"); } ---- diff --git a/components/camel-sap-netweaver/src/main/docs/sap-netweaver-component.adoc b/components/camel-sap-netweaver/src/main/docs/sap-netweaver-component.adoc index 60cfbb15de1d..cb11fbaa7d2d 100644 --- a/components/camel-sap-netweaver/src/main/docs/sap-netweaver-component.adoc +++ b/components/camel-sap-netweaver/src/main/docs/sap-netweaver-component.adoc @@ -83,25 +83,13 @@ Service] format. We have the following Camel route -._Java-only: route using toF() string formatting_ [source,java] ---- from("direct:start") - .setHeader("CamelNetWeaverCommand", constant(command)) - .toF("sap-netweaver:%s?username=%s&password=%s", url, username, password) + .setHeader("CamelNetWeaverCommand", constant("FlightCollection(carrid='AA',connid='0017',fldate=datetime'2016-04-20T00%3A00%3A00')")) + .to("sap-netweaver:https://sapes4.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT?username=P1909969254&password=TODO") .to("log:response") - .to("velocity:flight-info.vm") ----- - -Where `url`, `username`, `password` and `command` are defined as: - -._Java-only: Java field definitions_ -[source,java] ----- -private String username = "P1909969254"; -private String password = "TODO"; -private String url = "https://sapes4.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT"; -private String command = "FlightCollection(carrid='AA',connid='0017',fldate=datetime'2016-04-20T00%3A00%3A00')"; + .to("velocity:flight-info.vm"); ---- The password is invalid. You would need to create an account at SAP diff --git a/components/camel-shiro/src/main/docs/shiro.adoc b/components/camel-shiro/src/main/docs/shiro.adoc index 6986775ad948..2efdbd90265e 100644 --- a/components/camel-shiro/src/main/docs/shiro.adoc +++ b/components/camel-shiro/src/main/docs/shiro.adoc @@ -165,31 +165,21 @@ further following proper authentication. The SecurityToken object contains a Username/Password details that are used to determine where the user is a valid user. -._Java-only: Java RouteBuilder with security policy_ +._Java-only: route with Shiro security policy_ [source,java] ---- - protected RouteBuilder createRouteBuilder() throws Exception { - final ShiroSecurityPolicy securityPolicy = - new ShiroSecurityPolicy("classpath:shiro.ini", passPhrase); - - return new RouteBuilder() { - public void configure() { - onException(UnknownAccountException.class). - to("mock:authenticationException"); - onException(IncorrectCredentialsException.class). - to("mock:authenticationException"); - onException(LockedAccountException.class). - to("mock:authenticationException"); - onException(AuthenticationException.class). - to("mock:authenticationException"); - - from("direct:secureEndpoint"). - to("log:incoming payload"). - policy(securityPolicy). - to("mock:success"); - } - }; - } +final ShiroSecurityPolicy securityPolicy = + new ShiroSecurityPolicy("classpath:shiro.ini", passPhrase); + +onException(UnknownAccountException.class).to("mock:authenticationException"); +onException(IncorrectCredentialsException.class).to("mock:authenticationException"); +onException(LockedAccountException.class).to("mock:authenticationException"); +onException(AuthenticationException.class).to("mock:authenticationException"); + +from("direct:secureEndpoint") + .to("log:incoming payload") + .policy(securityPolicy) + .to("mock:success"); ---- [[ShiroSecurity-ApplyingShiroAuthorizationonaCamelRoute]] @@ -201,31 +191,21 @@ specifies the permissions necessary for the user to proceed with the execution of the route segment. If the user does not have the proper permission set, the request is not authorized to continue any further. -._Java-only: Java RouteBuilder with security policy_ +._Java-only: route with Shiro security policy and permissions_ [source,java] ---- - protected RouteBuilder createRouteBuilder() throws Exception { - final ShiroSecurityPolicy securityPolicy = - new ShiroSecurityPolicy("./src/test/resources/securityconfig.ini", passPhrase); - - return new RouteBuilder() { - public void configure() { - onException(UnknownAccountException.class). - to("mock:authenticationException"); - onException(IncorrectCredentialsException.class). - to("mock:authenticationException"); - onException(LockedAccountException.class). - to("mock:authenticationException"); - onException(AuthenticationException.class). - to("mock:authenticationException"); - - from("direct:secureEndpoint"). - to("log:incoming payload"). - policy(securityPolicy). - to("mock:success"); - } - }; - } +final ShiroSecurityPolicy securityPolicy = + new ShiroSecurityPolicy("./src/test/resources/securityconfig.ini", passPhrase); + +onException(UnknownAccountException.class).to("mock:authenticationException"); +onException(IncorrectCredentialsException.class).to("mock:authenticationException"); +onException(LockedAccountException.class).to("mock:authenticationException"); +onException(AuthenticationException.class).to("mock:authenticationException"); + +from("direct:secureEndpoint") + .to("log:incoming payload") + .policy(securityPolicy) + .to("mock:success"); ---- [[ShiroSecurity-CreatingaShiroSecurityTokenandinjectingitintoaMessageExchange]] diff --git a/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc b/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc index 6e434dc84e7d..f0c3a819129e 100644 --- a/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc +++ b/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc @@ -428,16 +428,9 @@ And the java code (from a unit test): mock.assertIsSatisfied(); } - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("direct:a") - .to("thymeleaf:org/apache/camel/component/thymeleaf/letter.txt") - .to("mock:result"); - } - }; - } + from("direct:a") + .to("thymeleaf:org/apache/camel/component/thymeleaf/letter.txt") + .to("mock:result"); ---- diff --git a/components/camel-velocity/src/main/docs/velocity-component.adoc b/components/camel-velocity/src/main/docs/velocity-component.adoc index a46fff12c752..a28575c00a9f 100644 --- a/components/camel-velocity/src/main/docs/velocity-component.adoc +++ b/components/camel-velocity/src/main/docs/velocity-component.adoc @@ -431,16 +431,9 @@ And the java code (from an unit test): mock.assertIsSatisfied(); } - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("direct:a") - .to("velocity:org/apache/camel/component/velocity/letter.vm") - .to("mock:result"); - } - }; - } + from("direct:a") + .to("velocity:org/apache/camel/component/velocity/letter.vm") + .to("mock:result"); ---- diff --git a/components/camel-wasm/src/main/docs/wasm-language.adoc b/components/camel-wasm/src/main/docs/wasm-language.adoc index b4c6fe8d38b4..3353ab443108 100644 --- a/components/camel-wasm/src/main/docs/wasm-language.adoc +++ b/components/camel-wasm/src/main/docs/wasm-language.adoc @@ -132,32 +132,11 @@ pub extern fn transform(ptr: u32, len: u32) -> u64 { Supposing we have compiled a Wasm module containing the function above, then it can be called in a Camel Route by its name and module resource location: -._Java-only: programmatic CamelContext and FluentProducerTemplate usage_ [source,java] ---- - try (CamelContext cc = new DefaultCamelContext()) { - FluentProducerTemplate pt = cc.createFluentProducerTemplate(); - - cc.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:in") - .tramsform() - .wasm("transform", "classpath://functions.wasm"); - } - }); - cc.start(); - - Exchange out = pt.to("direct:in") - .withHeader("foo", "bar") - .withBody("hello") - .request(Exchange.class); - - assertThat(out.getMessage().getHeaders()) - .containsEntry("foo", "bar"); - assertThat(out.getMessage().getBody(String.class)) - .isEqualTo("HELLO"); -} +from("direct:in") + .transform() + .wasm("transform", "classpath://functions.wasm"); ---- diff --git a/components/camel-xmlsecurity/src/main/docs/xmlSecurity-dataformat.adoc b/components/camel-xmlsecurity/src/main/docs/xmlSecurity-dataformat.adoc index 446d36529799..ed2928201438 100644 --- a/components/camel-xmlsecurity/src/main/docs/xmlSecurity-dataformat.adoc +++ b/components/camel-xmlsecurity/src/main/docs/xmlSecurity-dataformat.adoc @@ -142,14 +142,10 @@ final KeyStoreParameters tsParameters = new KeyStoreParameters(); tsParameters.setPassword("password"); tsParameters.setResource("sender.truststore"); -context.addRoutes(new RouteBuilder() { - public void configure() { - from("direct:start") - .marshal().xmlSecurity("//cust:cheesesites/italy", namespaces, true, "recipient", - testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters) - .to("mock:encrypted"); - } -} +from("direct:start") + .marshal().xmlSecurity("//cust:cheesesites/italy", namespaces, true, "recipient", + testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters) + .to("mock:encrypted"); ---- [[XMLSecurityDataFormat-SpringXML]] diff --git a/components/camel-xslt-saxon/src/main/docs/xslt-saxon-component.adoc b/components/camel-xslt-saxon/src/main/docs/xslt-saxon-component.adoc index f7f8374d1f21..d9cb4323d34c 100644 --- a/components/camel-xslt-saxon/src/main/docs/xslt-saxon-component.adoc +++ b/components/camel-xslt-saxon/src/main/docs/xslt-saxon-component.adoc @@ -320,14 +320,8 @@ SimpleRegistry registry = new SimpleRegistry(); registry.put("function1", new MyExtensionFunction1()); registry.put("function2", new MyExtensionFunction2()); -CamelContext context = new DefaultCamelContext(registry); -context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start") - .to("xslt-saxon:org/apache/camel/component/xslt/extensions/extensions.xslt?saxonExtensionFunctions=#function1,#function2"); - } -}); +from("direct:start") + .to("xslt-saxon:org/apache/camel/component/xslt/extensions/extensions.xslt?saxonExtensionFunctions=#function1,#function2"); ----
