[
https://issues.apache.org/jira/browse/CAMEL-16394?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-16394.
---------------------------------
Resolution: Fixed
> 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
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 3.10.0
>
>
> 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) -> {
> // the lambda mechanism here is used as illustration
> // purpose to stress the fact that the materialization
> // of beans should be delayed till the route is reified
> 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)