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,
LambdaRouteBuilder 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() |
void |
configuration()
Called on initialization to build routes configuration (global routes configurations) using the fluent builder
syntax.
|
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) |
protected void |
configureRouteConfiguration(RouteConfigurationDefinition routesConfiguration) |
RoutesDefinition |
configureRoutes(org.apache.camel.CamelContext context)
Configures the routes
|
protected void |
configureRouteTemplate(RouteTemplateDefinition routeTemplate) |
void |
errorHandler(ErrorHandlerBuilder errorHandlerBuilder)
Installs the given error handler builder
|
void |
errorHandler(String ref)
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. |
org.apache.camel.spi.Resource |
getResource()
The
Resource which is the source code for this route (such as XML, YAML, Groovy or Java source file) |
RestsDefinition |
getRestCollection() |
RestConfigurationDefinition |
getRestConfiguration() |
RoutesDefinition |
getRouteCollection() |
RouteTemplatesDefinition |
getRouteTemplateCollection() |
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
|
static RouteBuilder |
loadRoutesBuilder(org.apache.camel.spi.Resource resource,
org.apache.camel.util.function.ThrowingBiConsumer<Reader,RouteBuilder,Exception> consumer)
|
static RouteBuilder |
loadRoutesBuilder(org.apache.camel.util.function.ThrowingConsumer<RouteBuilder,Exception> consumer)
Loads
RoutesBuilder using the given consumer to create a RouteBuilder instance. |
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 |
populateOrUpdateRoutes() |
protected void |
populateRests() |
protected void |
populateRoutes() |
protected void |
populateRouteTemplates() |
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
|
RouteTemplateDefinition |
routeTemplate(String id)
Creates a new route template
|
void |
setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
Sets the error handler to use with processors created by this builder
|
void |
setResource(org.apache.camel.spi.Resource resource)
Sets the
Resource which is the source code for this route (such as XML, YAML, Groovy or Java source file) |
void |
setRestCollection(RestsDefinition restCollection) |
void |
setRouteCollection(RoutesDefinition routeCollection) |
void |
setRouteTemplateCollection(RouteTemplatesDefinition routeTemplateCollection) |
String |
toString() |
TransformerBuilder |
transformer()
Create a new
TransformerBuilder . |
Set<String> |
updateRoutesToCamelContext(org.apache.camel.CamelContext context) |
ValidatorBuilder |
validator()
Create a new
ValidatorBuilder . |
body, bodyAs, constant, constant, constant, createErrorHandlerBuilder, csimple, csimple, datasonnet, datasonnet, datasonnet, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, endpoints, endpoints, exceptionMessage, exchangeProperty, getCamelContext, getContext, getErrorHandlerBuilder, hasErrorHandlerBuilder, header, joor, joor, jsonpath, jsonpath, method, method, method, method, noErrorHandler, regexReplaceAll, regexReplaceAll, setCamelContext, setContext, simple, simple, simpleF, simpleF, systemProperty, systemProperty, xpath, xpath, xpath, xpath
public RouteBuilder()
public RouteBuilder(org.apache.camel.CamelContext context)
public org.apache.camel.spi.Resource getResource()
Resource
which is the source code for this route (such as XML, YAML, Groovy or Java source file)public void setResource(org.apache.camel.spi.Resource resource)
Resource
which is the source code for this route (such as XML, YAML, Groovy or Java source file)public static void addRoutes(org.apache.camel.CamelContext context, LambdaRouteBuilder rbc) throws Exception
RouteBuilder.addRoutes(context, rb -> rb.from("direct:inbound").bean(MyBean.class)));
context
- the camel context to add routesrbc
- a lambda expression receiving the RouteBuilder
to use to create routesException
- if an error occurspublic static RouteBuilder loadRoutesBuilder(org.apache.camel.spi.Resource resource, org.apache.camel.util.function.ThrowingBiConsumer<Reader,RouteBuilder,Exception> consumer)
resource
- the resource to be loaded.consumer
- the function used to create a RoutesBuilder
RoutesBuilder
public static RouteBuilder loadRoutesBuilder(org.apache.camel.util.function.ThrowingConsumer<RouteBuilder,Exception> consumer)
RoutesBuilder
using the given consumer to create a RouteBuilder
instance.consumer
- the function used to create a RoutesBuilder
RoutesBuilder
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.Ordered
public abstract void configure() throws Exception
Exception
- can be thrown during configurationpublic void configuration() 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 RouteTemplateDefinition routeTemplate(String id)
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 void errorHandler(String ref)
ref
- reference to the error handler to usepublic <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.RoutesBuilder
Exception
public Set<String> updateRoutesToCamelContext(org.apache.camel.CamelContext context) throws Exception
updateRoutesToCamelContext
in interface org.apache.camel.RoutesBuilder
Exception
public 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)
BuilderSupport
setErrorHandlerBuilder
in class BuilderSupport
public void addLifecycleInterceptor(RouteBuilderLifecycleStrategy interceptor)
RouteBuilderLifecycleStrategy
to be used.public void removeLifecycleInterceptor(RouteBuilderLifecycleStrategy interceptor)
RouteBuilderLifecycleStrategy
.protected void populateTransformers()
protected void populateValidators()
public RestsDefinition getRestCollection()
public void setRestCollection(RestsDefinition restCollection)
public RestConfigurationDefinition getRestConfiguration()
public RoutesDefinition getRouteCollection()
public void setRouteCollection(RoutesDefinition routeCollection)
public RouteTemplatesDefinition getRouteTemplateCollection()
public void setRouteTemplateCollection(RouteTemplatesDefinition routeTemplateCollection)
protected void configureRest(RestDefinition rest)
protected void configureRoute(RouteDefinition route)
protected void configureRouteTemplate(RouteTemplateDefinition routeTemplate)
protected void configureRouteConfiguration(RouteConfigurationDefinition routesConfiguration)
Apache Camel