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:
Routes
Direct Known Subclasses:
NoRouteBuilder

public abstract class RouteBuilder
extends BuilderSupport
implements Routes

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

Version:
$Revision: 751655 $

Constructor Summary
RouteBuilder()
           
RouteBuilder(CamelContext context)
           
 
Method Summary
protected  void addRoutes(Routes routes)
          Adds a collection of routes to this context
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)
           
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
 CamelContext getContext()
          Gets the Camel context used.
 RoutesDefinition getRouteCollection()
           
 List<Route> getRouteList()
          Uses CamelContext.getRoutes() to return the routes in the context.
 RouteBuilder inheritErrorHandler(boolean inherit)
          Configures whether or not the error handler is inherited by every processing node (or just the top most one)
 InterceptDefinition intercept()
          Adds a route for an interceptor; use the ProcessorDefinition.proceed() method to continue processing the underlying route being intercepted.
 RouteBuilder intercept(DelegateProcessor interceptor)
          Adds the given interceptor to this route
 ChoiceDefinition intercept(Predicate predicate)
          Applies a route for an interceptor if the given predicate is true otherwise the interceptor route is not applied
 void noStreamCaching()
          Completely disable stream caching for all routes being defined in the same RouteBuilder after this.
 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(List<Route> routes)
           
 void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
          Sets the error handler to use with processors created by this builder
 void setInheritErrorHandler(boolean inheritErrorHandler)
           
 void setRouteCollection(RoutesDefinition routeCollection)
           
 void streamCaching()
          Enable stream caching for all routes being defined in the same RouteBuilder after this call.
 String toString()
           
 
Methods inherited from class org.apache.camel.builder.BuilderSupport
bean, bean, body, body, constant, createErrorHandlerBuilder, deadLetterChannel, deadLetterChannel, deadLetterChannel, endpoint, endpoint, endpoints, endpoints, exceptionMessage, faultBody, faultBodyAs, getErrorHandlerBuilder, header, isInheritErrorHandler, loggingErrorHandler, loggingErrorHandler, loggingErrorHandler, loggingErrorHandler, noErrorHandler, outBody, outBody, property, regexReplaceAll, regexReplaceAll, setContext, systemProperty, systemProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.Routes
setContext
 

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

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

inheritErrorHandler

public RouteBuilder inheritErrorHandler(boolean inherit)
Configures whether or not the error handler is inherited by every processing node (or just the top most one)

Parameters:
inherit - whether error handlers should be inherited or not
Returns:
the current builder

intercept

public RouteBuilder intercept(DelegateProcessor interceptor)
Adds the given interceptor to this route

Parameters:
interceptor - the interceptor
Returns:
the builder

intercept

public InterceptDefinition intercept()
Adds a route for an interceptor; use the ProcessorDefinition.proceed() method to continue processing the underlying route being intercepted.

Returns:
the builder

intercept

public ChoiceDefinition intercept(Predicate predicate)
Applies a route for an interceptor if the given predicate is true otherwise the interceptor route is not applied

Parameters:
predicate - the predicate
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

getContext

public CamelContext getContext()
Description copied from interface: Routes
Gets the Camel context used.

Specified by:
getContext in interface Routes
Overrides:
getContext in class BuilderSupport

getRouteList

public List<Route> getRouteList()
                         throws Exception
Uses CamelContext.getRoutes() to return the routes in the context.

Specified by:
getRouteList in interface Routes
Throws:
Exception

setInheritErrorHandler

public void setInheritErrorHandler(boolean inheritErrorHandler)
Overrides:
setInheritErrorHandler in class BuilderSupport

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(List<Route> routes)
                       throws Exception
Throws:
Exception

setRouteCollection

public void setRouteCollection(RoutesDefinition routeCollection)

getRouteCollection

public RoutesDefinition getRouteCollection()

noStreamCaching

public void noStreamCaching()
Completely disable stream caching for all routes being defined in the same RouteBuilder after this.


streamCaching

public void streamCaching()
Enable stream caching for all routes being defined in the same RouteBuilder after this call.


createContainer

protected CamelContext createContainer()
Factory method


configureRoute

protected void configureRoute(RouteDefinition route)

addRoutes

protected void addRoutes(Routes routes)
                  throws Exception
Adds a collection of routes to this context

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


Copyright © 2009 Apache Software Foundation. All Rights Reserved.