org.apache.camel.model
Class RouteDefinition

java.lang.Object
  extended by org.apache.camel.model.OptionalIdentifiedDefinition
      extended by org.apache.camel.model.ProcessorDefinition<RouteDefinition>
          extended by org.apache.camel.model.RouteDefinition
All Implemented Interfaces:
Block, NamedNode

public class RouteDefinition
extends ProcessorDefinition<RouteDefinition>

Represents an XML <route/> element

Version:

Field Summary
 
Fields inherited from class org.apache.camel.model.ProcessorDefinition
inheritErrorHandler, log
 
Constructor Summary
RouteDefinition()
           
RouteDefinition(Endpoint endpoint)
           
RouteDefinition(String uri)
           
 
Method Summary
protected  RouteContext addRoutes(CamelContext camelContext, Collection<Route> routes, FromDefinition fromType)
           
 List<RouteContext> addRoutes(ModelCamelContext camelContext, Collection<Route> routes)
           
 RouteDefinition adviceWith(CamelContext camelContext, RouteBuilder builder)
          Deprecated. 
 RouteDefinition adviceWith(ModelCamelContext camelContext, RouteBuilder builder)
          Advices this route with the route builder.
 RouteDefinition autoStartup(boolean autoStartup)
          Sets the auto startup property on this route.
 RouteDefinition autoStartup(String autoStartup)
          Sets the auto startup property on this route.
 RouteDefinition delayer(long delay)
          Enable delayer for this route.
 RouteDefinition errorHandler(ErrorHandlerFactory errorHandlerBuilder)
          Installs the given error handler builder.
 RouteDefinition from(Endpoint... endpoints)
          Creates inputs to the route
 RouteDefinition from(Endpoint endpoint)
          Creates an input to the route
 RouteDefinition from(String... uris)
          Creates inputs to the route
 RouteDefinition from(String uri)
          Creates an input to the route
 String getAutoStartup()
           
 String getDelayer()
           
 ErrorHandlerFactory getErrorHandlerBuilder()
           
 String getErrorHandlerRef()
           
 String getGroup()
          The group that this route belongs to; could be the name of the RouteBuilder class or be explicitly configured in the XML.
 String getHandleFault()
           
 List<FromDefinition> getInputs()
           
 List<ProcessorDefinition> getOutputs()
           
 List<RoutePolicy> getRoutePolicies()
           
 String getRoutePolicyRef()
           
 String getShortName()
          Returns a short name for this node which can be useful for ID generation or referring to related resources like images
 ShutdownRoute getShutdownRoute()
           
 ShutdownRunningTask getShutdownRunningTask()
           
 Integer getStartupOrder()
           
 ServiceStatus getStatus(CamelContext camelContext)
          Returns the status of the route if it has been registered with a CamelContext
 String getStreamCache()
           
 String getTrace()
           
 RouteDefinition group(String name)
          Set the group name for this route
 RouteDefinition handleFault()
          Enable handle fault for this route.
 boolean isAutoStartup(CamelContext camelContext)
           
 boolean isOutputSupported()
           
 boolean isStartable(CamelContext camelContext)
           
 boolean isStoppable(CamelContext camelContext)
           
 void markPrepared()
          Marks the route definition as prepared.
 RouteDefinition noAutoStartup()
          Disables this route from being auto started when Camel starts.
 RouteDefinition noDelayer()
          Disable delayer for this route.
 RouteDefinition noHandleFault()
          Disable handle fault for this route.
 RouteDefinition noStreamCaching()
          Disable stream caching for this route.
 RouteDefinition noTracing()
          Disable tracing for this route.
 void prepare(ModelCamelContext context)
          Prepares the route definition to be ready to be added to CamelContext
 Endpoint resolveEndpoint(CamelContext camelContext, String uri)
           
 RouteDefinition routeId(String id)
          Set the route id for this route
 RouteDefinition routePolicy(RoutePolicy... policies)
          Configures route policies for this route
 RouteDefinition routePolicyRef(String routePolicyRef)
          Configures a route policy for this route
 void setAutoStartup(String autoStartup)
           
 void setDelayer(String delayer)
           
 void setErrorHandlerBuilder(ErrorHandlerFactory errorHandlerBuilder)
          Sets the error handler to use with processors created by this builder
 void setErrorHandlerBuilderIfNull(ErrorHandlerFactory errorHandlerBuilder)
          Sets the error handler if one is not already set
 void setErrorHandlerRef(String errorHandlerRef)
          Sets the bean ref name of the error handler builder to use on this route
 void setGroup(String group)
           
 void setHandleFault(String handleFault)
           
 void setInputs(List<FromDefinition> inputs)
           
 void setOutputs(List<ProcessorDefinition> outputs)
           
 void setRoutePolicies(List<RoutePolicy> routePolicies)
           
 void setRoutePolicyRef(String routePolicyRef)
           
 void setShutdownRoute(ShutdownRoute shutdownRoute)
           
 void setShutdownRunningTask(ShutdownRunningTask shutdownRunningTask)
           
 void setStartupOrder(Integer startupOrder)
           
 void setStreamCache(String streamCache)
           
 void setTrace(String trace)
           
 RouteDefinition shutdownRoute(ShutdownRoute shutdownRoute)
          Configures a shutdown route option.
 RouteDefinition shutdownRunningTask(ShutdownRunningTask shutdownRunningTask)
          Configures a shutdown running task option.
 RouteDefinition startupOrder(int order)
          Configures the startup order for this route

Camel will reorder routes and star them ordered by 0..N where 0 is the lowest number and N the highest number.

 RouteDefinition streamCaching()
          Enable stream caching for this route.
 String toString()
           
 RouteDefinition tracing()
          Enable tracing for this route.
 
Methods inherited from class org.apache.camel.model.ProcessorDefinition
addInterceptStrategies, addInterceptStrategy, addOutput, addRoutes, aggregate, aggregate, aggregate, aggregate, aop, attribute, bean, bean, bean, bean, beanRef, beanRef, choice, clearOutput, configureChild, convertBodyTo, convertBodyTo, createChannel, createChildProcessor, createCompositeProcessor, createOutputsProcessor, createOutputsProcessor, createProcessor, delay, delay, delay, doTry, dynamicRouter, dynamicRouter, end, endChoice, endDoTry, endParent, enrich, enrich, enrichRef, filter, filter, filter, filter, getInterceptStrategies, getLabel, getNodeFactory, getOtherAttributes, getParent, id, idempotentConsumer, idempotentConsumer, idempotentConsumer, inheritErrorHandler, inOnly, inOnly, inOnly, inOnly, inOnly, inOnly, inOut, inOut, inOut, inOut, inOut, inOut, isAbstract, isInheritErrorHandler, loadBalance, loadBalance, log, log, log, log, loop, loop, loop, makeProcessor, markRollbackOnly, markRollbackOnlyLast, marshal, marshal, marshal, marshal, multicast, multicast, multicast, onCompletion, onException, onException, pipeline, pipeline, pipeline, pipeline, placeholder, policy, policy, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrichRef, preCreateProcessor, process, processRef, recipientList, recipientList, recipientList, removeFaultHeader, removeHeader, removeHeaders, removeHeaders, removeProperty, resequence, resequence, resolveKnownConstantFields, resolvePropertyPlaceholders, rollback, rollback, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, sample, sample, sample, setBody, setBody, setExchangePattern, setFaultBody, setFaultHeader, setHeader, setHeader, setInheritErrorHandler, setNodeFactory, setOtherAttributes, setOutHeader, setOutHeader, setParent, setProperty, setProperty, sort, sort, sort, split, split, split, stop, threads, threads, threads, threads, throttle, throttle, throwException, to, to, to, to, to, to, to, to, to, to, toF, transacted, transacted, transform, transform, unmarshal, unmarshal, unmarshal, unmarshal, validate, validate, validate, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wrapChannel, wrapInErrorHandler, wrapProcessor
 
Methods inherited from class org.apache.camel.model.OptionalIdentifiedDefinition
description, getDescription, getDescriptionText, getId, hasCustomIdAssigned, idOrCreate, setDescription, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RouteDefinition

public RouteDefinition()

RouteDefinition

public RouteDefinition(String uri)

RouteDefinition

public RouteDefinition(Endpoint endpoint)
Method Detail

prepare

public void prepare(ModelCamelContext context)
Prepares the route definition to be ready to be added to CamelContext

Parameters:
context - the camel context

markPrepared

public void markPrepared()
Marks the route definition as prepared.

This is needed if routes have been created by components such as camel-spring or camel-blueprint. Usually they share logic in the camel-core-xml module which prepares the routes.


toString

public String toString()
Overrides:
toString in class Object

getShortName

public String getShortName()
Description copied from class: OptionalIdentifiedDefinition
Returns a short name for this node which can be useful for ID generation or referring to related resources like images

Specified by:
getShortName in interface NamedNode
Overrides:
getShortName in class OptionalIdentifiedDefinition
Returns:
defaults to "node" but derived nodes should overload this to provide a unique name

getStatus

public ServiceStatus getStatus(CamelContext camelContext)
Returns the status of the route if it has been registered with a CamelContext


isStartable

public boolean isStartable(CamelContext camelContext)

isStoppable

public boolean isStoppable(CamelContext camelContext)

addRoutes

public List<RouteContext> addRoutes(ModelCamelContext camelContext,
                                    Collection<Route> routes)
                             throws Exception
Throws:
Exception

resolveEndpoint

public Endpoint resolveEndpoint(CamelContext camelContext,
                                String uri)
                         throws NoSuchEndpointException
Throws:
NoSuchEndpointException

adviceWith

@Deprecated
public RouteDefinition adviceWith(CamelContext camelContext,
                                             RouteBuilder builder)
                           throws Exception
Deprecated. 

Throws:
Exception

adviceWith

public RouteDefinition adviceWith(ModelCamelContext camelContext,
                                  RouteBuilder builder)
                           throws Exception
Advices this route with the route builder.

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.

You can use a regular RouteBuilder but the specialized AdviceWithRouteBuilder has additional features when using the advice with feature. We therefore suggest you to use the AdviceWithRouteBuilder.

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.

Parameters:
camelContext - the camel context
builder - the route builder
Returns:
a new route which is this route merged with the route builder
Throws:
Exception - can be thrown from the route builder
See Also:
AdviceWithRouteBuilder

from

public RouteDefinition from(String uri)
Creates an input to the route

Parameters:
uri - the from uri
Returns:
the builder

from

public RouteDefinition from(Endpoint endpoint)
Creates an input to the route

Parameters:
endpoint - the from endpoint
Returns:
the builder

from

public RouteDefinition from(String... uris)
Creates inputs to the route

Parameters:
uris - the from uris
Returns:
the builder

from

public RouteDefinition from(Endpoint... endpoints)
Creates inputs to the route

Parameters:
endpoints - the from endpoints
Returns:
the builder

group

public RouteDefinition group(String name)
Set the group name for this route

Parameters:
name - the group name
Returns:
the builder

routeId

public RouteDefinition routeId(String id)
Set the route id for this route

Overrides:
routeId in class ProcessorDefinition<RouteDefinition>
Parameters:
id - the route id
Returns:
the builder

noStreamCaching

public RouteDefinition noStreamCaching()
Disable stream caching for this route.

Returns:
the builder

streamCaching

public RouteDefinition streamCaching()
Enable stream caching for this route.

Returns:
the builder

noTracing

public RouteDefinition noTracing()
Disable tracing for this route.

Returns:
the builder

tracing

public RouteDefinition tracing()
Enable tracing for this route.

Returns:
the builder

noHandleFault

public RouteDefinition noHandleFault()
Disable handle fault for this route.

Returns:
the builder

handleFault

public RouteDefinition handleFault()
Enable handle fault for this route.

Returns:
the builder

noDelayer

public RouteDefinition noDelayer()
Disable delayer for this route.

Returns:
the builder

delayer

public RouteDefinition delayer(long delay)
Enable delayer for this route.

Parameters:
delay - delay in millis
Returns:
the builder

errorHandler

public RouteDefinition errorHandler(ErrorHandlerFactory 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

noAutoStartup

public RouteDefinition noAutoStartup()
Disables this route from being auto started when Camel starts.

Returns:
the builder

autoStartup

public RouteDefinition autoStartup(String autoStartup)
Sets the auto startup property on this route.

Parameters:
autoStartup - - String indicator ("true" or "false")
Returns:
the builder

autoStartup

public RouteDefinition autoStartup(boolean autoStartup)
Sets the auto startup property on this route.

Parameters:
autoStartup - - boolean indicator
Returns:
the builder

startupOrder

public RouteDefinition startupOrder(int order)
Configures the startup order for this route

Camel will reorder routes and star them ordered by 0..N where 0 is the lowest number and N the highest number. Camel will stop routes in reverse order when its stopping.

Parameters:
order - the order represented as a number
Returns:
the builder

routePolicy

public RouteDefinition routePolicy(RoutePolicy... policies)
Configures route policies for this route

Parameters:
policies - the route policies
Returns:
the builder

routePolicyRef

public RouteDefinition routePolicyRef(String routePolicyRef)
Configures a route policy for this route

Parameters:
routePolicyRef - reference to a RoutePolicy to lookup and use. You can specify multiple references by separating using comma.
Returns:
the builder

shutdownRoute

public RouteDefinition shutdownRoute(ShutdownRoute shutdownRoute)
Configures a shutdown route option.

Parameters:
shutdownRoute - the option to use when shutting down this route
Returns:
the builder

shutdownRunningTask

public RouteDefinition shutdownRunningTask(ShutdownRunningTask shutdownRunningTask)
Configures a shutdown running task option.

Parameters:
shutdownRunningTask - the option to use when shutting down and how to act upon running tasks.
Returns:
the builder

getInputs

public List<FromDefinition> getInputs()

setInputs

public void setInputs(List<FromDefinition> inputs)

getOutputs

public List<ProcessorDefinition> getOutputs()
Specified by:
getOutputs in class ProcessorDefinition<RouteDefinition>

setOutputs

public void setOutputs(List<ProcessorDefinition> outputs)

isOutputSupported

public boolean isOutputSupported()
Specified by:
isOutputSupported in class ProcessorDefinition<RouteDefinition>

getGroup

public String getGroup()
The group that this route belongs to; could be the name of the RouteBuilder class or be explicitly configured in the XML.

May be null.


setGroup

public void setGroup(String group)

getStreamCache

public String getStreamCache()

setStreamCache

public void setStreamCache(String streamCache)

getTrace

public String getTrace()

setTrace

public void setTrace(String trace)

getHandleFault

public String getHandleFault()

setHandleFault

public void setHandleFault(String handleFault)

getDelayer

public String getDelayer()

setDelayer

public void setDelayer(String delayer)

getAutoStartup

public String getAutoStartup()

isAutoStartup

public boolean isAutoStartup(CamelContext camelContext)
                      throws Exception
Throws:
Exception

setAutoStartup

public void setAutoStartup(String autoStartup)

getStartupOrder

public Integer getStartupOrder()

setStartupOrder

public void setStartupOrder(Integer startupOrder)

setErrorHandlerRef

public void setErrorHandlerRef(String errorHandlerRef)
Sets the bean ref name of the error handler builder to use on this route


getErrorHandlerRef

public String getErrorHandlerRef()

setErrorHandlerBuilderIfNull

public void setErrorHandlerBuilderIfNull(ErrorHandlerFactory errorHandlerBuilder)
Sets the error handler if one is not already set


setRoutePolicyRef

public void setRoutePolicyRef(String routePolicyRef)

getRoutePolicyRef

public String getRoutePolicyRef()

getRoutePolicies

public List<RoutePolicy> getRoutePolicies()

setRoutePolicies

public void setRoutePolicies(List<RoutePolicy> routePolicies)

getShutdownRoute

public ShutdownRoute getShutdownRoute()

setShutdownRoute

public void setShutdownRoute(ShutdownRoute shutdownRoute)

getShutdownRunningTask

public ShutdownRunningTask getShutdownRunningTask()

setShutdownRunningTask

public void setShutdownRunningTask(ShutdownRunningTask shutdownRunningTask)

getErrorHandlerBuilder

public ErrorHandlerFactory getErrorHandlerBuilder()

setErrorHandlerBuilder

public void setErrorHandlerBuilder(ErrorHandlerFactory errorHandlerBuilder)
Sets the error handler to use with processors created by this builder


addRoutes

protected RouteContext addRoutes(CamelContext camelContext,
                                 Collection<Route> routes,
                                 FromDefinition fromType)
                          throws Exception
Throws:
Exception


Apache CAMEL