Package org.apache.camel.builder
Class AdviceWithRouteBuilder
java.lang.Object
org.apache.camel.builder.BuilderSupport
org.apache.camel.builder.RouteBuilder
org.apache.camel.builder.AdviceWithRouteBuilder
- All Implemented Interfaces:
ModelRoutesBuilder,org.apache.camel.CamelContextAware,org.apache.camel.Ordered,org.apache.camel.RoutesBuilder,org.apache.camel.spi.HasCamelContext,org.apache.camel.spi.ResourceAware
A
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.-
Field Summary
Fields inherited from class org.apache.camel.builder.RouteBuilder
logFields inherited from interface org.apache.camel.Ordered
HIGHEST, LOWEST -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets a list of additional tasks to execute after theRouteBuilder.configure()method has been executed during the advice process.Gets the original route to be adviced.booleanWhether to log the adviced routes before/after as XML.voidMock all endpoints.voidmockEndpoints(String... pattern) Mock all endpoints matching the given pattern.voidmockEndpointsAndSkip(String... pattern) Mock all endpoints matching the given pattern, and skips sending to the original endpoint (detour messages).voidreplaceFromWith(String uri) Replaces the route from endpoint with a new urivoidreplaceFromWith(org.apache.camel.Endpoint endpoint) Replaces the route from endpoint with a new endpointvoidsetLogRouteAsXml(boolean logRouteAsXml) Sets whether to log the adviced routes before/after as XML.voidsetOriginalRoute(RouteDefinition originalRoute) Sets the original route to be adviced.<T extends ProcessorDefinition<?>>
ProcessorDefinition<?> Weaves by adding the nodes to the start of the route (excl onException etc).<T extends ProcessorDefinition<?>>
ProcessorDefinition<?> Weaves by adding the nodes to the end of the route (excl onException etc).<T extends ProcessorDefinition<?>>
AdviceWithBuilder<T> Weaves by matching id of the nodes in the route (incl onException etc).<T extends ProcessorDefinition<?>>
AdviceWithBuilder<T> weaveByToString(String pattern) Weaves by matching the to string representation of the nodes in the route (incl onException etc).<T extends ProcessorDefinition<?>>
AdviceWithBuilder<T> 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<?>>
AdviceWithBuilder<T> weaveByType(Class<T> type) Weaves by matching type of the nodes in the route (incl onException etc).Methods inherited from class org.apache.camel.builder.RouteBuilder
addLifecycleInterceptor, addRoutes, addRoutesToCamelContext, addTemplatedRoutesToCamelContext, bindToRegistry, bindToRegistry, checkInitialized, configuration, configure, configureRest, configureRests, configureRoute, configureRouteConfiguration, configureRoutes, configureRouteTemplate, configureTemplatedRoute, dataFormat, errorHandler, errorHandler, expression, from, from, from, fromF, getBeans, getOrder, getResource, getRestCollection, getRestConfiguration, getRests, getRouteCollection, getRoutes, getRouteTemplateCollection, getTemplatedRouteCollection, initializeCamelContext, intercept, interceptFrom, interceptFrom, interceptSendToEndpoint, loadRoutesBuilder, loadRoutesBuilder, onCompletion, onException, onException, populateBeans, populateOrUpdateRoutes, populateRests, populateRoutes, populateRouteTemplates, populateTemplatedRoutes, populateTransformers, populateValidators, prepareModel, property, propertyInject, removeLifecycleInterceptor, rest, rest, restConfiguration, routeTemplate, setErrorHandlerFactory, setResource, setRestCollection, setRouteTemplateCollection, setTemplatedRouteCollection, templatedRoute, toString, transformer, updateRoutesToCamelContext, validatorMethods inherited from class org.apache.camel.builder.BuilderSupport
body, bodyAs, constant, constant, constant, createErrorHandlerBuilder, csimple, csimple, datasonnet, datasonnet, datasonnet, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, exceptionMessage, exchangeProperty, expression, getCamelContext, getContext, getErrorHandlerFactory, hasErrorHandlerFactory, header, joor, joor, jsonpath, jsonpath, jtaTransactionErrorHandler, jtaTransactionErrorHandler, jtaTransactionErrorHandler, method, method, method, method, noErrorHandler, regexReplaceAll, regexReplaceAll, setCamelContext, simple, simple, simpleF, simpleF, springTransactionErrorHandler, springTransactionErrorHandler, springTransactionErrorHandler, systemProperty, systemProperty, xpath, xpath, xpath, xpath
-
Constructor Details
-
AdviceWithRouteBuilder
public AdviceWithRouteBuilder() -
AdviceWithRouteBuilder
public AdviceWithRouteBuilder(org.apache.camel.CamelContext context)
-
-
Method Details
-
setOriginalRoute
Sets the original route to be adviced.- Parameters:
originalRoute- the original route.
-
getOriginalRoute
Gets the original route to be adviced.- Returns:
- the original route.
-
isLogRouteAsXml
public boolean isLogRouteAsXml()Whether to log the adviced routes before/after as XML. This is usable to know how the route was adviced and changed. However marshalling the route model to XML costs CPU resources and you can then turn this off by not logging. This is default enabled. -
setLogRouteAsXml
public void setLogRouteAsXml(boolean logRouteAsXml) Sets whether to log the adviced routes before/after as XML. This is usable to know how the route was adviced and changed. However marshalling the route model to XML costs CPU resources and you can then turn this off by not logging. This is default enabled. -
getAdviceWithTasks
Gets a list of additional tasks to execute after theRouteBuilder.configure()method has been executed during the advice process.- Returns:
- a list of additional
AdviceWithTasktasks to be executed during the advice process.
-
mockEndpoints
Mock all endpoints.- Throws:
Exception- can be thrown if error occurred
-
mockEndpoints
Mock all endpoints matching the given pattern.- Parameters:
pattern- the pattern(s).- Throws:
Exception- can be thrown if error occurred- See Also:
-
mockEndpointsAndSkip
Mock all endpoints matching the given pattern, and skips sending to the original endpoint (detour messages).- Parameters:
pattern- the pattern(s).- Throws:
Exception- can be thrown if error occurred- See Also:
-
replaceFromWith
Replaces the route from endpoint with a new uri- Parameters:
uri- uri of the new endpoint
-
replaceFromWith
public void replaceFromWith(org.apache.camel.Endpoint endpoint) Replaces the route from endpoint with a new endpoint- Parameters:
endpoint- the new endpoint
-
weaveById
Weaves by matching id of the nodes in the route (incl onException etc). Uses thePatternHelper.matchPattern(String, String)matching algorithm.- Parameters:
pattern- the pattern- Returns:
- the builder
- See Also:
-
weaveByToString
Weaves by matching the to string representation of the nodes in the route (incl onException etc). Uses thePatternHelper.matchPattern(String, String)matching algorithm.- Parameters:
pattern- the pattern- Returns:
- the builder
- See Also:
-
weaveByToUri
Weaves by matching sending to endpoints with the given uri of the nodes in the route (incl onException etc). Uses thePatternHelper.matchPattern(String, String)matching algorithm.- Parameters:
pattern- the pattern- Returns:
- the builder
- See Also:
-
weaveByType
Weaves by matching type of the nodes in the route (incl onException etc).- Parameters:
type- the processor type- Returns:
- the builder
-
weaveAddFirst
Weaves by adding the nodes to the start of the route (excl onException etc).- Returns:
- the builder
-
weaveAddLast
Weaves by adding the nodes to the end of the route (excl onException etc).- Returns:
- the builder
-