You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Luca Burgazzoli (Jira)" <ji...@apache.org> on 2021/03/24 08:28:00 UTC

[jira] [Created] (CAMEL-16394) Route Template local beans

Luca Burgazzoli created CAMEL-16394:
---------------------------------------

             Summary: Route Template local beans 
                 Key: CAMEL-16394
                 URL: https://issues.apache.org/jira/browse/CAMEL-16394
             Project: Camel
          Issue Type: New Feature
          Components: camel-core
            Reporter: Luca Burgazzoli
             Fix For: 3.x


Now that we have route templates and kamelets, we should explore the option to have route local beans in addition to route local properties. This would be very useful when dealing with EIPs or endpoints that require specific beans.

As example, assuming I have the following template:

{code:java}
routeTemplate()
  .from("direct:start")
  .to("aws2-s3:...?amazonS3Client=#myClient")
{code}

Then myClient need to be created at global scope and there's no way to create one that is specific for the template.

We should provide something like:

{code:java}
routeTemplate()
    .templateParameter("region")
    .templateParameter("bucket")
    .configure((RouteTemplateContext context) -> { 
        context.bind(
            "myClient", 
            S3Client.builder().region(context.getProperty("region")).build()
        );
    })
    .from("direct:start")
    .to("aws2-s3:{{bucket}}?amazonS3Client=#myClient")
{code}

So when the route is materialized, the configure method is invoked, the myClient bean is registered to the current template context and retrieved by the reifier to materialize the route.





--
This message was sent by Atlassian Jira
(v8.3.4#803005)