org.apache.camel.builder
Class RouteBuilder

java.lang.Object
  extended by org.apache.camel.builder.BuilderSupport
      extended by org.apache.camel.builder.RouteBuilder
All Implemented Interfaces:
RoutesBuilder
Direct Known Subclasses:
AdviceWithRouteBuilder, CafeRouteBuilder, CamelCxfExample.MyRouteBuilder, CamelRoute, CamelRouterBuilder, Client, Customer, GroovyRouteBuilder, IncrementRoute, JmsToFileRoute, LoanBroker, LoanBroker, MyRouteBuilder, MyRouteBuilder, MyRouteBuilder, MyRouteBuilder, MyRouteBuilder, ProcessBuilder, ReportIncidentRoutes, ScriptRouteBuilder, ServerRoutes, SpringRouteBuilder, TutorialRouteBuilder, TutorialRouteBuilder

public abstract class RouteBuilder
extends BuilderSupport
implements RoutesBuilder

A Java DSL which is used to build DefaultRoute instances in a CamelContext for smart routing.

Version:

Field Summary
protected  org.slf4j.Logger log
           
 
Constructor Summary
RouteBuilder()
           
RouteBuilder(CamelContext context)
           
 
Method Summary
protected  void addRoutes(RoutesBuilder routes)
          Deprecated. will be removed in Camel 3.0. Instead use includeRoutes instead.
 void addRoutesToCamelContext(CamelContext context)
          Adds the routes from this Route Builder to the CamelContext.
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 configureRoute(RouteDefinition route)
           
 RoutesDefinition configureRoutes(CamelContext context)
          Configures the routes
protected  CamelContext createContainer()
          Factory method
 RouteBuilder errorHandler(ErrorHandlerBuilder errorHandlerBuilder)
          Installs the given error handler builder
 RouteDefinition from(Endpoint... endpoints)
          Creates a new route from the given endpoint
 RouteDefinition from(Endpoint endpoint)
          Creates a new route from the given endpoint
 RouteDefinition from(String... uris)
          Creates a new route from the given URIs input
 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
 CamelContext getContext()
           
 RoutesDefinition getRouteCollection()
           
 void includeRoutes(RoutesBuilder routes)
          Includes the routes from the build to this builder.
 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... exceptions)
          Exception clause for catching certain exceptions and handling them.
 OnExceptionDefinition onException(Class exception)
          Exception clause for catching certain exceptions and handling them.
protected  void populateRoutes()
           
 void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
          Sets the error handler to use with processors created by this builder
 void setRouteCollection(RoutesDefinition routeCollection)
           
 String 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, simple, simple, systemProperty, systemProperty, xpath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected org.slf4j.Logger log
Constructor Detail

RouteBuilder

public RouteBuilder()

RouteBuilder

public RouteBuilder(CamelContext context)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

configure

public abstract void configure()
                        throws Exception
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.

Throws:
Exception - can be thrown during configuration

from

public RouteDefinition from(String uri)
Creates a new route from the given URI input

Parameters:
uri - the from uri
Returns:
the builder

fromF

public RouteDefinition fromF(String uri,
                             Object... args)
Creates a new route from the given URI input

Parameters:
uri - the String formatted from uri
args - arguments for the string formatting of the uri
Returns:
the builder

from

public RouteDefinition from(Endpoint endpoint)
Creates a new route from the given endpoint

Parameters:
endpoint - the from endpoint
Returns:
the builder

from

public RouteDefinition from(String... uris)
Creates a new route from the given URIs input

Parameters:
uris - the from uris
Returns:
the builder

from

public RouteDefinition from(Endpoint... endpoints)
Creates a new route from the given endpoint

Parameters:
endpoints - the from endpoints
Returns:
the builder

errorHandler

public RouteBuilder errorHandler(ErrorHandlerBuilder errorHandlerBuilder)
Installs the given error handler builder

Parameters:
errorHandlerBuilder - the error handler to be used by default for all child routes
Returns:
the current builder with the error handler configured

intercept

public InterceptDefinition intercept()
Adds a route for an interceptor that intercepts every processing step.

Returns:
the builder

interceptFrom

public InterceptFromDefinition interceptFrom()
Adds a route for an interceptor that intercepts incoming messages on any inputs in this route

Returns:
the builder

interceptFrom

public InterceptFromDefinition interceptFrom(String uri)
Adds a route for an interceptor that intercepts incoming messages on the given endpoint.

Parameters:
uri - endpoint uri
Returns:
the builder

interceptSendToEndpoint

public InterceptSendToEndpointDefinition interceptSendToEndpoint(String uri)
Applies a route for an interceptor if an exchange is send to the given endpoint

Parameters:
uri - endpoint uri
Returns:
the builder

onException

public OnExceptionDefinition onException(Class exception)
Exception clause for catching certain exceptions and handling them.

Parameters:
exception - exception to catch
Returns:
the builder

onException

public OnExceptionDefinition onException(Class... exceptions)
Exception clause for catching certain exceptions and handling them.

Parameters:
exceptions - list of exceptions to catch
Returns:
the builder

onCompletion

public OnCompletionDefinition onCompletion()
On completion callback for doing custom routing when the Exchange is complete.

Returns:
the builder

getContext

public CamelContext getContext()
Overrides:
getContext in class BuilderSupport

addRoutesToCamelContext

public void addRoutesToCamelContext(CamelContext context)
                             throws Exception
Description copied from interface: RoutesBuilder
Adds the routes from this Route Builder to the CamelContext.

Specified by:
addRoutesToCamelContext in interface RoutesBuilder
Parameters:
context - the Camel context
Throws:
Exception - is thrown if initialization of routes failed

configureRoutes

public RoutesDefinition configureRoutes(CamelContext context)
                                 throws Exception
Configures the routes

Parameters:
context - the Camel context
Returns:
the routes configured
Throws:
Exception - can be thrown during configuration

includeRoutes

public void includeRoutes(RoutesBuilder routes)
                   throws Exception
Includes the routes from the build to this builder.

This allows you to use other builds as route templates.

Parameters:
routes - other builder with routes to include
Throws:
Exception - can be thrown during configuration

setErrorHandlerBuilder

public void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
Description copied from class: BuilderSupport
Sets the error handler to use with processors created by this builder

Overrides:
setErrorHandlerBuilder in class BuilderSupport

checkInitialized

protected void checkInitialized()
                         throws Exception
Throws:
Exception

populateRoutes

protected void populateRoutes()
                       throws Exception
Throws:
Exception

setRouteCollection

public void setRouteCollection(RoutesDefinition routeCollection)

getRouteCollection

public RoutesDefinition getRouteCollection()

createContainer

protected CamelContext createContainer()
Factory method

Returns:
the CamelContext

configureRoute

protected void configureRoute(RouteDefinition route)

addRoutes

@Deprecated
protected void addRoutes(RoutesBuilder routes)
                  throws Exception
Deprecated. will be removed in Camel 3.0. Instead use includeRoutes instead.

Adds a collection of routes to this context

Parameters:
routes - the routes
Throws:
Exception - if the routes could not be created for whatever reason


Apache CAMEL