[ 
https://issues.apache.org/jira/browse/CAMEL-13295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16786138#comment-16786138
 ] 

Guillaume Nodet commented on CAMEL-13295:
-----------------------------------------

Actually, it may even cleaner to do the following:
{code:java}
RouteBuilder.addRoutes(context, rb -> 
    rb.from(u).to("reactive-streams:" + uuid));
{code}
By adding the following method to {{RouteBuilder}} :
{code}
public static void addRoutes(
        CamelContext context, 
        ThrowingConsumer<RouteBuilder, Exception> rbc) throws Exception 
{
    context.addRoutes(new RouteBuilder(context) {
        @Override
        public void configure() throws Exception {
            rbc.accept(this);
        }
    });
}
{code}

> Add a helper method to easily add a route
> -----------------------------------------
>
>                 Key: CAMEL-13295
>                 URL: https://issues.apache.org/jira/browse/CAMEL-13295
>             Project: Camel
>          Issue Type: Improvement
>            Reporter: Guillaume Nodet
>            Assignee: Guillaume Nodet
>            Priority: Major
>             Fix For: 3.0.0-M2
>
>
> Using the following method in `ModelCamelContext`
> {code:java}
> default void addRoute(ThrowingConsumer<RouteBuilder, Exception> rbc) throws 
> Exception {
>     addRoutes(new RouteBuilder() {
>         @Override
>         public void configure() throws Exception {
>             rbc.accept(this);
>         }
>     });
> }
> {code}
> we can simply blocks such as
> {code}
> new RouteBuilder() {
>     @Override
>     public void configure() throws Exception {
>         from(u).to("reactive-streams:" + uuid);
>     }
> }.addRoutesToCamelContext(context);
> {code}
> into
> {code}
> context.adapt(ModelCamelContext.class).addRoute(rb -> 
>     rb.from(u).to("reactive-streams:" + uuid));
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to