Interface RouteTemplateContext
- All Superinterfaces:
HasCamelContext
Contextual environment provided to a route template
while it is being instantiated into a concrete
Route.
A route template is a parameterized route blueprint registered in the CamelContext. When the template is
instantiated (for example by a Kamelet), the framework creates a RouteTemplateContext that carries the
parameter bindings and a local bean repository. Template beans (RouteTemplateContext.BeanSupplier) declared inside the template
are resolved through this context rather than the global registry, so each instantiation gets its own private set of
beans.
Implementors provide this context to the template engine; application developers typically interact with it only when
writing custom RouteTemplateParameterSource or Kamelet binding code.- Since:
- 3.10
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceUsed for template beans to supply the local bean the route template should use when creating route(s). -
Method Summary
Modifier and TypeMethodDescriptionvoidBinds the bean to the repository (if possible).voidBinds the bean (via a supplier) to the repository (if possible).default voidBinds the bean to the repository (if possible).voidbindAsPrototype(String id, Class<?> type, Supplier<Object> bean) Binds the bean (via a supplier) to the repository (if possible).@Nullable Consumer<RouteTemplateContext> Gets the custom configurer.@Nullable ObjectgetEnvironmentVariable(String name) Gets the environment variable parameter that matches the given property name.Gets the local bean repository for the route template when creating the new routeThe parameters to use for the route template when creating the new route@Nullable ObjectgetProperty(String name) Gets the property with the given name<T> @Nullable TgetProperty(String name, Class<?> type) Gets the property with the given namebooleanhasEnvironmentVariable(String name) Whether the route template has an environment variable parameter that matches the given parameter name.booleanhasParameter(String name) Whether the route template has a parameter with the given namevoidregisterDestroyMethod(String id, String method) Registers an optional destroy method to invoke on the bean when stopping Camel.voidsetConfigurer(@Nullable Consumer<RouteTemplateContext> configurer) Sets a custom configurer which allows to do configuration while the route template is being used to create a route.voidsetParameter(String name, Object value) Sets a parameterMethods inherited from interface HasCamelContext
getCamelContext
-
Method Details
-
bind
Binds the bean to the repository (if possible). If the bean isCamelContextAwarethen the registry will automatically inject the context if possible.- Parameters:
id- the id of the beanbean- the bean
-
bind
Binds the bean to the repository (if possible). Binding by id and type allows to bind multiple entries with the same id but with different type. If the bean isCamelContextAwarethen the registry will automatically inject the context if possible.- Parameters:
id- the id of the beantype- the type of the bean to associate the bindingbean- the bean
-
bind
Binds the bean (via a supplier) to the repository (if possible). Camel will cache the result from the supplier from first lookup (singleton scope). If you do not need cached then usebindAsPrototype(String, Class, Supplier)instead. Binding by id and type allows to bind multiple entries with the same id but with different type. If the bean isCamelContextAwarethen the registry will automatically inject the context if possible.- Parameters:
id- the id of the beantype- the type of the bean to associate the bindingbean- a supplier for the bean
-
bindAsPrototype
Binds the bean (via a supplier) to the repository (if possible). Notice that the supplier will be called each time the bean is being looked up (not cached). Binding by id and type allows to bind multiple entries with the same id but with different type. If the bean isCamelContextAwarethen the registry will automatically inject the context if possible.- Parameters:
id- the id of the beantype- the type of the bean to associate the bindingbean- a supplier for the bean
-
registerDestroyMethod
-
getProperty
-
getEnvironmentVariable
Gets the environment variable parameter that matches the given property name. The match is performed by normalizing the given property name as an OS environment variable name. The environment variable name may use pure uppercase or camelCase converted to underscore property names. As an example bucketNameOrArn property matches BUCKETNAMEORARN and BUCKET_NAME_OR_ARN environment variables.- Parameters:
name- name of property- Returns:
- the property value or null if no property exists
-
getProperty
Gets the property with the given name- Parameters:
name- name of propertytype- the type of the property- Returns:
- the property value or null if no property exists
- Throws:
TypeConversionException- is thrown if error during type conversion
-
setParameter
-
getParameters
-
hasParameter
Whether the route template has a parameter with the given name- Parameters:
name- the parameter name- Returns:
- true if exists
-
hasEnvironmentVariable
Whether the route template has an environment variable parameter that matches the given parameter name. The match is performed by normalizing the given name as an OS environment variable name. The environment variable name may use pure uppercase or camelCase converted to underscore property names. As an example bucketNameOrArn property matches BUCKETNAMEORARN and BUCKET_NAME_OR_ARN environment variables.- Parameters:
name- the parameter name- Returns:
- true if exists
-
getLocalBeanRepository
BeanRepository getLocalBeanRepository()Gets the local bean repository for the route template when creating the new route -
setConfigurer
Sets a custom 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
-
getConfigurer
@Nullable Consumer<RouteTemplateContext> getConfigurer()Gets the custom configurer.
-