public abstract class AdviceWithRouteBuilder extends RouteBuilder
RouteBuilder
which has extended capabilities when using the
advice with feature.
Important: It is recommended to only advice a given route once (you can of course advice multiple routes). If
you do it multiple times, then it may not work as expected, especially when any kind of error handling is involved.log
Constructor and Description |
---|
AdviceWithRouteBuilder() |
AdviceWithRouteBuilder(org.apache.camel.CamelContext context) |
Modifier and Type | Method and Description |
---|---|
static RouteDefinition |
adviceWith(org.apache.camel.CamelContext camelContext,
Object routeId,
boolean logXml,
org.apache.camel.util.function.ThrowingConsumer<AdviceWithRouteBuilder,Exception> builder)
|
static RouteDefinition |
adviceWith(org.apache.camel.CamelContext camelContext,
Object routeId,
org.apache.camel.util.function.ThrowingConsumer<AdviceWithRouteBuilder,Exception> builder)
Deprecated.
|
List<AdviceWithTask> |
getAdviceWithTasks()
Gets a list of additional tasks to execute after the
RouteBuilder.configure() method has been executed during the
advice process. |
RouteDefinition |
getOriginalRoute()
Gets the original route to be adviced.
|
boolean |
isLogRouteAsXml()
Whether to log the adviced routes before/after as XML.
|
void |
mockEndpoints()
Mock all endpoints.
|
void |
mockEndpoints(String... pattern)
Mock all endpoints matching the given pattern.
|
void |
mockEndpointsAndSkip(String... pattern)
Mock all endpoints matching the given pattern, and skips sending to the original endpoint (detour
messages).
|
void |
replaceFromWith(org.apache.camel.Endpoint endpoint)
Replaces the route from endpoint with a new endpoint
|
void |
replaceFromWith(String uri)
Replaces the route from endpoint with a new uri
|
void |
setLogRouteAsXml(boolean logRouteAsXml)
Sets whether to log the adviced routes before/after as XML.
|
void |
setOriginalRoute(RouteDefinition originalRoute)
Sets the original route to be adviced.
|
<T extends ProcessorDefinition<?>> |
weaveAddFirst()
Weaves by adding the nodes to the start of the route (excl onException etc).
|
<T extends ProcessorDefinition<?>> |
weaveAddLast()
Weaves by adding the nodes to the end of the route (excl onException etc).
|
<T extends ProcessorDefinition<?>> |
weaveById(String pattern)
Weaves by matching id of the nodes in the route (incl onException etc).
|
<T extends ProcessorDefinition<?>> |
weaveByToString(String pattern)
Weaves by matching the to string representation of the nodes in the route (incl onException etc).
|
<T extends ProcessorDefinition<?>> |
weaveByToUri(String pattern)
Weaves by matching sending to endpoints with the given uri of the nodes in the route (incl onException etc).
|
<T extends ProcessorDefinition<?>> |
weaveByType(Class<T> type)
Weaves by matching type of the nodes in the route (incl onException etc).
|
addLifecycleInterceptor, addRoutes, addRoutesToCamelContext, bindToRegistry, bindToRegistry, checkInitialized, configure, configureRest, configureRests, configureRoute, configureRoutes, configureRouteTemplate, errorHandler, errorHandler, from, from, from, fromF, getOrder, getRestCollection, getRestConfiguration, getRouteCollection, getRouteTemplateCollection, intercept, interceptFrom, interceptFrom, interceptSendToEndpoint, loadRoutesBuilder, loadRoutesBuilder, onCompletion, onException, onException, populateRests, populateRoutes, populateRouteTemplates, populateTransformers, populateValidators, propertyInject, removeLifecycleInterceptor, rest, rest, restConfiguration, routeTemplate, setErrorHandlerBuilder, setRestCollection, setRouteCollection, setRouteTemplateCollection, toString, transformer, validator
body, bodyAs, constant, constant, createErrorHandlerBuilder, csimple, csimple, datasonnet, datasonnet, datasonnet, datasonnet, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, endpoints, endpoints, exceptionMessage, exchangeProperty, getContext, getErrorHandlerBuilder, hasErrorHandlerBuilder, header, joor, joor, jsonpath, jsonpath, method, method, method, method, noErrorHandler, regexReplaceAll, regexReplaceAll, setContext, simple, simple, simpleF, simpleF, systemProperty, systemProperty, xpath, xpath, xpath, xpath
public AdviceWithRouteBuilder()
public AdviceWithRouteBuilder(org.apache.camel.CamelContext context)
@Deprecated public static RouteDefinition adviceWith(org.apache.camel.CamelContext camelContext, Object routeId, org.apache.camel.util.function.ThrowingConsumer<AdviceWithRouteBuilder,Exception> builder) throws Exception
AdviceWith.adviceWith(CamelContext, Object, ThrowingConsumer)
AdviceWithRouteBuilder.adviceWith(context, "myRoute", a -> a.weaveAddLast().to("mock:result");Important: It is recommended to only advice a given route once (you can of course advice multiple routes). If you do it multiple times, then it may not work as expected, especially when any kind of error handling is involved. The advice process will add the interceptors, on exceptions, on completions etc. configured from the route builder to this route. This is mostly used for testing purpose to add interceptors and the likes to an existing route. Will stop and remove the old route from camel context and add and start this new advised route.
camelContext
- the camel contextrouteId
- either the route id as a string value, or null to chose the 1st route, or you
can specify a number for the n'th route, or provide the route definition instance
directly as well.builder
- the advice with route builderException
- can be thrown from the route builder@Deprecated public static RouteDefinition adviceWith(org.apache.camel.CamelContext camelContext, Object routeId, boolean logXml, org.apache.camel.util.function.ThrowingConsumer<AdviceWithRouteBuilder,Exception> builder) throws Exception
AdviceWithRouteBuilder.adviceWith(context, "myRoute", false, a -> a.weaveAddLast().to("mock:result");Important: It is recommended to only advice a given route once (you can of course advice multiple routes). If you do it multiple times, then it may not work as expected, especially when any kind of error handling is involved. The advice process will add the interceptors, on exceptions, on completions etc. configured from the route builder to this route. This is mostly used for testing purpose to add interceptors and the likes to an existing route. Will stop and remove the old route from camel context and add and start this new advised route.
camelContext
- the camel contextrouteId
- either the route id as a string value, or null to chose the 1st route, or you
can specify a number for the n'th route, or provide the route definition instance
directly as well.logXml
- whether to log the before and after advices routes as XML to the log (this can be turned
off to perform faster)builder
- the advice with route builderException
- can be thrown from the route builderpublic void setOriginalRoute(RouteDefinition originalRoute)
originalRoute
- the original route.public RouteDefinition getOriginalRoute()
public boolean isLogRouteAsXml()
public void setLogRouteAsXml(boolean logRouteAsXml)
public List<AdviceWithTask> getAdviceWithTasks()
RouteBuilder.configure()
method has been executed during the
advice process.AdviceWithTask
tasks to be executed during the advice process.public void mockEndpoints() throws Exception
Exception
- can be thrown if error occurredpublic void mockEndpoints(String... pattern) throws Exception
pattern
- the pattern(s).Exception
- can be thrown if error occurredEndpointHelper.matchEndpoint(org.apache.camel.CamelContext, String, String)
public void mockEndpointsAndSkip(String... pattern) throws Exception
pattern
- the pattern(s).Exception
- can be thrown if error occurredEndpointHelper.matchEndpoint(org.apache.camel.CamelContext, String, String)
public void replaceFromWith(String uri)
uri
- uri of the new endpointpublic void replaceFromWith(org.apache.camel.Endpoint endpoint)
endpoint
- the new endpointpublic <T extends ProcessorDefinition<?>> AdviceWithBuilder<T> weaveById(String pattern)
PatternHelper.matchPattern(String, String)
matching algorithm.pattern
- the patternPatternHelper.matchPattern(String, String)
public <T extends ProcessorDefinition<?>> AdviceWithBuilder<T> weaveByToString(String pattern)
PatternHelper.matchPattern(String, String)
matching algorithm.pattern
- the patternPatternHelper.matchPattern(String, String)
public <T extends ProcessorDefinition<?>> AdviceWithBuilder<T> weaveByToUri(String pattern)
PatternHelper.matchPattern(String, String)
matching algorithm.pattern
- the patternPatternHelper.matchPattern(String, String)
public <T extends ProcessorDefinition<?>> AdviceWithBuilder<T> weaveByType(Class<T> type)
type
- the processor typepublic <T extends ProcessorDefinition<?>> ProcessorDefinition<?> weaveAddFirst()
public <T extends ProcessorDefinition<?>> ProcessorDefinition<?> weaveAddLast()
Apache Camel