org.apache.camel.builder
Class AdviceWithRouteBuilder

java.lang.Object
  extended by org.apache.camel.builder.BuilderSupport
      extended by org.apache.camel.builder.RouteBuilder
          extended by org.apache.camel.builder.AdviceWithRouteBuilder
All Implemented Interfaces:
RoutesBuilder

public abstract class AdviceWithRouteBuilder
extends RouteBuilder

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. The Camel team plan for Camel 3.0 to support this as internal refactorings in the routing engine is needed to support this properly.

See Also:
RouteDefinition.adviceWith(org.apache.camel.CamelContext, RouteBuilder)

Field Summary
 
Fields inherited from class org.apache.camel.builder.RouteBuilder
log
 
Constructor Summary
AdviceWithRouteBuilder()
           
 
Method Summary
 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 we advice.
 void mockEndpoints()
          Mock all endpoints in the route.
 void mockEndpoints(String pattern)
          Mock all endpoints matching the given pattern.
 void replaceFromWith(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 setOriginalRoute(RouteDefinition originalRoute)
          Sets the original route which we advice.
<T extends ProcessorDefinition>
ProcessorDefinition
weaveAddFirst()
          Weaves by adding the nodes to the start of the route.
<T extends ProcessorDefinition>
ProcessorDefinition
weaveAddLast()
          Weaves by adding the nodes to the end of the route.
<T extends ProcessorDefinition>
AdviceWithBuilder
weaveById(String pattern)
          Weaves by matching id of the nodes in the route.
<T extends ProcessorDefinition>
AdviceWithBuilder
weaveByToString(String pattern)
          Weaves by matching the to string representation of the nodes in the route.
<T extends ProcessorDefinition>
AdviceWithBuilder
weaveByType(Class<T> type)
          Weaves by matching type of the nodes in the route.
 
Methods inherited from class org.apache.camel.builder.RouteBuilder
addRoutes, addRoutesToCamelContext, checkInitialized, configure, configureRoute, configureRoutes, createContainer, errorHandler, from, from, from, from, fromF, getContext, getRouteCollection, includeRoutes, intercept, interceptFrom, interceptFrom, interceptSendToEndpoint, onCompletion, onException, onException, populateRoutes, setErrorHandlerBuilder, setRouteCollection, toString
 
Methods inherited from class org.apache.camel.builder.BuilderSupport
bean, bean, bean, bean, body, body, constant, createErrorHandlerBuilder, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, endpoints, endpoints, exceptionMessage, faultBody, faultBodyAs, getErrorHandlerBuilder, header, loggingErrorHandler, loggingErrorHandler, loggingErrorHandler, loggingErrorHandler, noErrorHandler, outBody, outBody, property, regexReplaceAll, regexReplaceAll, sendTo, setContext, setContext, simple, simple, systemProperty, systemProperty, xpath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AdviceWithRouteBuilder

public AdviceWithRouteBuilder()
Method Detail

setOriginalRoute

public void setOriginalRoute(RouteDefinition originalRoute)
Sets the original route which we advice.

Parameters:
originalRoute - the original route we advice.

getOriginalRoute

public RouteDefinition getOriginalRoute()
Gets the original route we advice.

Returns:
the original route.

getAdviceWithTasks

public List<AdviceWithTask> getAdviceWithTasks()
Gets a list of additional tasks to execute after the RouteBuilder.configure() method has been executed during the advice process.

Returns:
a list of additional AdviceWithTask tasks to be executed during the advice process.

mockEndpoints

public void mockEndpoints()
                   throws Exception
Mock all endpoints in the route.

Throws:
Exception - can be thrown if error occurred

mockEndpoints

public void mockEndpoints(String pattern)
                   throws Exception
Mock all endpoints matching the given pattern.

Parameters:
pattern - the pattern.
Throws:
Exception - can be thrown if error occurred
See Also:
EndpointHelper.matchEndpoint(org.apache.camel.CamelContext, String, String)

replaceFromWith

public void replaceFromWith(String uri)
Replaces the route from endpoint with a new uri

Parameters:
uri - uri of the new endpoint

replaceFromWith

public void replaceFromWith(Endpoint endpoint)
Replaces the route from endpoint with a new endpoint

Parameters:
endpoint - the new endpoint

weaveById

public <T extends ProcessorDefinition> AdviceWithBuilder weaveById(String pattern)
Weaves by matching id of the nodes in the route.

Uses the EndpointHelper.matchPattern(String, String) matching algorithm.

Parameters:
pattern - the pattern
Returns:
the builder
See Also:
EndpointHelper.matchPattern(String, String)

weaveByToString

public <T extends ProcessorDefinition> AdviceWithBuilder weaveByToString(String pattern)
Weaves by matching the to string representation of the nodes in the route.

Uses the EndpointHelper.matchPattern(String, String) matching algorithm.

Parameters:
pattern - the pattern
Returns:
the builder
See Also:
EndpointHelper.matchPattern(String, String)

weaveByType

public <T extends ProcessorDefinition> AdviceWithBuilder weaveByType(Class<T> type)
Weaves by matching type of the nodes in the route.

Parameters:
type - the processor type
Returns:
the builder

weaveAddFirst

public <T extends ProcessorDefinition> ProcessorDefinition weaveAddFirst()
Weaves by adding the nodes to the start of the route.

Returns:
the builder

weaveAddLast

public <T extends ProcessorDefinition> ProcessorDefinition weaveAddLast()
Weaves by adding the nodes to the end of the route.

Returns:
the builder


Apache CAMEL