Class TemplatedRouteBuilder


  • public final class TemplatedRouteBuilder
    extends Object
    Fluent builder for adding new routes from route templates.
    • Method Detail

      • builder

        public static TemplatedRouteBuilder builder​(org.apache.camel.CamelContext camelContext,
                                                    String routeTemplateId)
        Creates a new TemplatedRouteBuilder to specify input parameters, and others, for the route template.
        Parameters:
        camelContext - the camel context
        routeTemplateId - the id of the route template
        Returns:
        the builder
      • routeId

        public TemplatedRouteBuilder routeId​(String routeId)
        Sets the id of the route. If no route id is configured, then Camel will auto assign a route id, which is returned from the build method.
        Parameters:
        routeId - the route id
      • prefixId

        public TemplatedRouteBuilder prefixId​(String prefixId)
        Sets a prefix to use for all node ids (not route id).
        Parameters:
        prefixId - the prefix id
      • parameter

        public TemplatedRouteBuilder parameter​(String name,
                                               Object value)
        Adds a parameter the route template will use when creating the route.
        Parameters:
        name - parameter name
        value - parameter value
      • parameters

        public TemplatedRouteBuilder parameters​(Map<String,​Object> parameters)
        Adds parameters the route template will use when creating the route.
        Parameters:
        parameters - the template parameters to add
      • bean

        public TemplatedRouteBuilder bean​(String id,
                                          Object bean)
        Binds the bean to the template local repository (takes precedence over global beans)
        Parameters:
        id - the id of the bean
        bean - the bean
      • bean

        public TemplatedRouteBuilder bean​(String id,
                                          Class<?> type,
                                          Object bean)
        Binds the bean to the template local repository (takes precedence over global beans)
        Parameters:
        id - the id of the bean
        type - the type of the bean to associate the binding
        bean - the bean
      • bean

        public TemplatedRouteBuilder bean​(String id,
                                          Class<?> type,
                                          Supplier<Object> bean)
        Binds the bean (via a supplier) to the template local repository (takes precedence over global beans)
        Parameters:
        id - the id of the bean
        type - the type of the bean to associate the binding
        bean - the bean
      • handler

        public TemplatedRouteBuilder handler​(Consumer<RouteTemplateDefinition> handler)
        Sets a handler which gives access to the route template model that will be used for creating the route. This can be used to do validation. Any changes to the model happens before the route is created and added, however these changes affect future usage of the same template.
        Parameters:
        handler - the handler with callback to invoke with the given route template
      • configure

        public TemplatedRouteBuilder configure​(Consumer<org.apache.camel.RouteTemplateContext> configurer)
        Sets a configurer which allows to do configuration while the route template is being used to create a route. This gives control over the creating process, such as binding local beans and doing other kind of customization.
        Parameters:
        configurer - the configurer with callback to invoke with the given route template context
      • add

        public String add()
        Adds the route to the CamelContext which is built from the configured route template.
        Returns:
        the route id of the route that was added.