Package org.apache.camel
Interface RouteTemplateContext
-
- All Superinterfaces:
HasCamelContext
public interface RouteTemplateContext extends HasCamelContext
The context used during creating aRoute
from a route template.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
RouteTemplateContext.BeanSupplier<T>
Used for template beans to supply the local bean the route template should use when creating route(s).
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
bind(String id, Class<?> type, Object bean)
Binds the bean to the repository (if possible).void
bind(String id, Class<?> type, Supplier<Object> bean)
Binds the bean (via a supplier) to the repository (if possible).default void
bind(String id, Object bean)
Binds the bean to the repository (if possible).void
bindAsPrototype(String id, Class<?> type, Supplier<Object> bean)
Binds the bean (via a supplier) to the repository (if possible).Consumer<RouteTemplateContext>
getConfigurer()
Gets the custom configurer.BeanRepository
getLocalBeanRepository()
Gets the local bean repository for the route template when creating the new routeMap<String,Object>
getParameters()
The parameters to use for the route template when creating the new routeObject
getProperty(String name)
Gets the property with the given name<T> T
getProperty(String name, Class<?> type)
Gets the property with the given nameboolean
hasParameter(String name)
Whether the route template has a parameter with the given namevoid
setConfigurer(Consumer<RouteTemplateContext> configurer)
Sets a custom configurer which allows to do configuration while the route template is being used to create a route.void
setParameter(String name, Object value)
Sets a parameter-
Methods inherited from interface org.apache.camel.spi.HasCamelContext
getCamelContext
-
-
-
-
Method Detail
-
bind
default void bind(String id, Object bean)
Binds the bean to the repository (if possible). If the bean isCamelContextAware
then the registry will automatic inject the context if possible.- Parameters:
id
- the id of the beanbean
- the bean
-
bind
void bind(String id, Class<?> type, Object bean)
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 isCamelContextAware
then the registry will automatic inject the context if possible.- Parameters:
id
- the id of the beantype
- the type of the bean to associate the bindingbean
- the bean
-
bind
void bind(String id, Class<?> type, Supplier<Object> bean)
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 isCamelContextAware
then the registry will automatic 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
void bindAsPrototype(String id, Class<?> type, Supplier<Object> bean)
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 isCamelContextAware
then the registry will automatic 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
-
getProperty
Object getProperty(String name)
Gets the property with the given name- Parameters:
name
- name of property- Returns:
- the property value or null if no property exists
-
getProperty
<T> T getProperty(String name, Class<?> type)
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
void setParameter(String name, Object value)
Sets a parameter- Parameters:
name
- the parameter namevalue
- the parameter value
-
getParameters
Map<String,Object> getParameters()
The parameters to use for the route template when creating the new route
-
hasParameter
boolean hasParameter(String name)
Whether the route template has a parameter with the given name- 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
void setConfigurer(Consumer<RouteTemplateContext> configurer)
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
Consumer<RouteTemplateContext> getConfigurer()
Gets the custom configurer.
-
-