public abstract class RouteBuilder extends BuilderSupport implements org.apache.camel.RoutesBuilder, org.apache.camel.Ordered
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
log |
| Constructor and Description |
|---|
RouteBuilder() |
RouteBuilder(org.apache.camel.CamelContext context) |
| Modifier and Type | Method and Description |
|---|---|
void |
addLifecycleInterceptor(RouteBuilderLifecycleStrategy interceptor)
Adds the given
RouteBuilderLifecycleStrategy to be used. |
static void |
addRoutes(org.apache.camel.CamelContext context,
org.apache.camel.util.function.ThrowingConsumer<RouteBuilder,Exception> rbc)
Add routes to a context using a lambda expression.
|
void |
addRoutesToCamelContext(org.apache.camel.CamelContext context) |
void |
bindToRegistry(String id,
Class<?> type,
Object bean)
Binds the bean to the repository (if possible).
|
void |
bindToRegistry(String id,
Object bean)
Binds the bean to the repository (if possible).
|
protected void |
checkInitialized() |
abstract void |
configure()
Called on initialization to build the routes using the fluent builder
syntax.
This is a central method for RouteBuilder implementations to implement
the routes using the Java fluent builder syntax.
|
protected void |
configureRest(RestDefinition rest) |
RestsDefinition |
configureRests(org.apache.camel.CamelContext context)
Configures the rests
|
protected void |
configureRoute(RouteDefinition route) |
RoutesDefinition |
configureRoutes(org.apache.camel.CamelContext context)
Configures the routes
|
void |
errorHandler(ErrorHandlerBuilder errorHandlerBuilder)
Installs the given
error handler
builder
|
RouteDefinition |
from(org.apache.camel.Endpoint endpoint)
Creates a new route from the given endpoint
|
RouteDefinition |
from(EndpointConsumerBuilder endpointDefinition) |
RouteDefinition |
from(String uri)
Creates a new route from the given URI input
|
RouteDefinition |
fromF(String uri,
Object... args)
Creates a new route from the given URI input
|
int |
getOrder()
Override this method to define ordering of
RouteBuilder classes that are added to
Camel from various runtimes such as camel-main, camel-spring-boot. |
RestsDefinition |
getRestCollection() |
Map<String,RestConfigurationDefinition> |
getRestConfigurations() |
RoutesDefinition |
getRouteCollection() |
InterceptDefinition |
intercept()
Adds a route for an interceptor that intercepts every processing step.
|
InterceptFromDefinition |
interceptFrom()
Adds a route for an interceptor that intercepts incoming messages on any
inputs in this route
|
InterceptFromDefinition |
interceptFrom(String uri)
Adds a route for an interceptor that intercepts incoming messages on the
given endpoint.
|
InterceptSendToEndpointDefinition |
interceptSendToEndpoint(String uri)
Applies a route for an interceptor if an exchange is send to the given
endpoint
|
OnCompletionDefinition |
onCompletion()
On completion
callback for doing custom routing when the
Exchange is complete. |
OnExceptionDefinition |
onException(Class<? extends Throwable>... exceptions)
Exception
clause for catching certain exceptions and handling them.
|
OnExceptionDefinition |
onException(Class<? extends Throwable> exception)
Exception
clause for catching certain exceptions and handling them.
|
protected void |
populateRests() |
protected void |
populateRoutes() |
protected void |
populateTransformers() |
protected void |
populateValidators() |
<T> T |
propertyInject(String key,
Class<T> type)
Injects a property placeholder value with the given key converted to the
given type.
|
void |
removeLifecycleInterceptor(RouteBuilderLifecycleStrategy interceptor)
Adds the given
RouteBuilderLifecycleStrategy. |
RestDefinition |
rest()
Creates a new REST service
|
RestDefinition |
rest(String path)
Creates a new REST service
|
RestConfigurationDefinition |
restConfiguration()
Configures the REST services
|
RestConfigurationDefinition |
restConfiguration(String component)
Configures the REST service for the given component
|
void |
setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
Sets the error handler to use with processors created by this builder
|
void |
setRestCollection(RestsDefinition restCollection) |
void |
setRouteCollection(RoutesDefinition routeCollection) |
String |
toString() |
TransformerBuilder |
transformer()
Create a new
TransformerBuilder. |
ValidatorBuilder |
validator()
Create a new
ValidatorBuilder. |
body, bodyAs, constant, createErrorHandlerBuilder, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, endpoints, endpoints, exceptionMessage, exchangeProperty, getContext, getErrorHandlerBuilder, header, jsonpath, jsonpath, language, method, method, method, method, noErrorHandler, regexReplaceAll, regexReplaceAll, setContext, simple, simple, simpleF, simpleF, systemProperty, systemProperty, xpath, xpath, xpath, xpathprotected org.slf4j.Logger log
public RouteBuilder()
public RouteBuilder(org.apache.camel.CamelContext context)
public int getOrder()
RouteBuilder classes that are added to
Camel from various runtimes such as camel-main, camel-spring-boot. This allows end users
to control the ordering if some routes must be added and started before others.
Use low numbers for higher priority. Normally the sorting will start from 0 and move upwards.
So if you want to be last then use Integer.MAX_VALUE or eg Ordered.LOWEST.getOrder in interface org.apache.camel.Orderedpublic static void addRoutes(org.apache.camel.CamelContext context, org.apache.camel.util.function.ThrowingConsumer<RouteBuilder,Exception> rbc) throws Exception
RouteBuilder.addRoutes(context, rb ->
rb.from("direct:inbound").bean(ProduceTemplateBean.class)));
context - the camel context to add routesrbc - a lambda expression receiving the RouteBuilder to use
to create routesException - if an error occurspublic abstract void configure() throws Exception
Exception - can be thrown during configurationpublic void bindToRegistry(String id, Object bean)
id - the id of the beanbean - the beanpublic void bindToRegistry(String id, Class<?> type, Object bean)
id - the id of the beantype - the type of the bean to associate the bindingbean - the beanpublic RestConfigurationDefinition restConfiguration()
public RestConfigurationDefinition restConfiguration(String component)
public RestDefinition rest()
public RestDefinition rest(String path)
path - the base pathpublic TransformerBuilder transformer()
TransformerBuilder.public ValidatorBuilder validator()
ValidatorBuilder.public RouteDefinition from(String uri)
uri - the from uripublic RouteDefinition fromF(String uri, Object... args)
uri - the String formatted from uriargs - arguments for the string formatting of the uripublic RouteDefinition from(org.apache.camel.Endpoint endpoint)
endpoint - the from endpointpublic RouteDefinition from(EndpointConsumerBuilder endpointDefinition)
public void errorHandler(ErrorHandlerBuilder errorHandlerBuilder)
errorHandlerBuilder - the error handler to be used by default for
all child routespublic <T> T propertyInject(String key, Class<T> type) throws Exception
key - the property keytype - the type to convert the value asException - is thrown if property with key not found or error
converting to the given type.public InterceptDefinition intercept()
public InterceptFromDefinition interceptFrom()
public InterceptFromDefinition interceptFrom(String uri)
uri - endpoint uripublic InterceptSendToEndpointDefinition interceptSendToEndpoint(String uri)
uri - endpoint uripublic OnExceptionDefinition onException(Class<? extends Throwable> exception)
exception - exception to catchpublic OnExceptionDefinition onException(Class<? extends Throwable>... exceptions)
exceptions - list of exceptions to catchpublic OnCompletionDefinition onCompletion()
Exchange is complete.public void addRoutesToCamelContext(org.apache.camel.CamelContext context) throws Exception
addRoutesToCamelContext in interface org.apache.camel.RoutesBuilderExceptionpublic RoutesDefinition configureRoutes(org.apache.camel.CamelContext context) throws Exception
context - the Camel contextException - can be thrown during configurationpublic RestsDefinition configureRests(org.apache.camel.CamelContext context) throws Exception
context - the Camel contextException - can be thrown during configurationpublic void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
BuilderSupportsetErrorHandlerBuilder in class BuilderSupportpublic void addLifecycleInterceptor(RouteBuilderLifecycleStrategy interceptor)
RouteBuilderLifecycleStrategy to be used.public void removeLifecycleInterceptor(RouteBuilderLifecycleStrategy interceptor)
RouteBuilderLifecycleStrategy.protected void checkInitialized() throws Exception
Exceptionprotected void populateRoutes() throws Exception
Exceptionprotected void populateRests() throws Exception
Exceptionprotected void populateTransformers()
protected void populateValidators()
public RestsDefinition getRestCollection()
public Map<String,RestConfigurationDefinition> getRestConfigurations()
public void setRestCollection(RestsDefinition restCollection)
public void setRouteCollection(RoutesDefinition routeCollection)
public RoutesDefinition getRouteCollection()
protected void configureRest(RestDefinition rest)
protected void configureRoute(RouteDefinition route)
Apache Camel