org.apache.camel.impl
Class DefaultRouteContext

java.lang.Object
  extended by org.apache.camel.impl.DefaultRouteContext
All Implemented Interfaces:
RuntimeConfiguration, RouteContext

public class DefaultRouteContext
extends Object
implements RouteContext

The context used to activate new routing rules

Version:

Constructor Summary
DefaultRouteContext(CamelContext camelContext)
          Only used for lazy construction from inside ExpressionType
DefaultRouteContext(CamelContext camelContext, RouteDefinition route, FromDefinition from, Collection<Route> routes)
           
 
Method Summary
 void addEventDrivenProcessor(Processor processor)
          Adds an event driven processor
 void addInterceptStrategy(InterceptStrategy interceptStrategy)
          Adds a InterceptStrategy to this route context
 void commit()
          For completing the route creation, creating a single event driven route for the current from endpoint with any processors required
 int getAndIncrement(ProcessorDefinition<?> node)
          A private counter that increments, is used to as book keeping when building a route based on the model

We need this special book keeping be able to assign the correct ProcessorDefinition to the Channel

 CamelContext getCamelContext()
          Gets the camel context
 Long getDelayer()
          Gets the delay value
 Endpoint getEndpoint()
          Gets the endpoint
 FromDefinition getFrom()
          Gets the from type
 List<InterceptStrategy> getInterceptStrategies()
          This method retrieves the InterceptStrategy instances this route context.
 InterceptStrategy getManagedInterceptStrategy()
          Gets the special managed intercept strategy if any
 RouteDefinition getRoute()
          Get the route type
 List<RoutePolicy> getRoutePolicyList()
          Gets the route policy List
 ShutdownRoute getShutdownRoute()
          Gets the option to use when shutting down the route.
 ShutdownRunningTask getShutdownRunningTask()
          Gets the ShutdownRunningTask option in use when shutting down a route.
 Boolean isAutoStartup()
          Gets whether the object should automatically start when Camel starts.
 Boolean isHandleFault()
          Returns whether fault handling enabled
 boolean isRouteAdded()
          Returns the isRouteAdded flag
 Boolean isStreamCaching()
          Returns whether stream cache is enabled
 Boolean isTracing()
          Returns whether tracing enabled
<T> T
lookup(String name, Class<T> type)
          lookup an object by name and type
<T> Map<String,T>
lookupByType(Class<T> type)
          lookup objects by type
<T> T
mandatoryLookup(String name, Class<T> type)
          lookup an object by name and type or throws NoSuchBeanException if not found.
 Endpoint resolveEndpoint(String uri)
          Resolves an endpoint from the URI
 Endpoint resolveEndpoint(String uri, String ref)
          Resolves an endpoint from either a URI or a named reference
 void setAutoStartup(Boolean autoStartup)
          Sets whether the object should automatically start when Camel starts.
 void setDelayer(Long delay)
          Sets a delay value in millis that a message is delayed at every step it takes in the route path, slowing the process down to better observe what is occurring

Is disabled by default

 void setHandleFault(Boolean handleFault)
          Sets whether fault handling is enabled or not (default is disabled).
 void setInterceptStrategies(List<InterceptStrategy> interceptStrategies)
          This method sets the InterceptStrategy instances on this route context.
 void setIsRouteAdded(boolean routeAdded)
          If this flag is true, ProcessorDefinition.addRoutes(RouteContext, java.util.Collection) will not add processor to addEventDrivenProcessor to the RouteContext and it will prevent from adding an EventDrivenRoute.
 void setManagedInterceptStrategy(InterceptStrategy interceptStrategy)
          Sets a special intercept strategy for management.
 void setRoutePolicyList(List<RoutePolicy> routePolicyList)
          Sets a custom route policy List
 void setShutdownRoute(ShutdownRoute shutdownRoute)
          Sets the ShutdownRoute option for routes.
 void setShutdownRunningTask(ShutdownRunningTask shutdownRunningTask)
          Sets the ShutdownRunningTask option to use when shutting down a route.
 void setStreamCaching(Boolean cache)
          Sets whether stream caching is enabled or not (default is disabled).
 void setTracing(Boolean tracing)
          Sets whether tracing is enabled or not (default is disabled).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRouteContext

public DefaultRouteContext(CamelContext camelContext,
                           RouteDefinition route,
                           FromDefinition from,
                           Collection<Route> routes)

DefaultRouteContext

public DefaultRouteContext(CamelContext camelContext)
Only used for lazy construction from inside ExpressionType

Method Detail

getEndpoint

public Endpoint getEndpoint()
Description copied from interface: RouteContext
Gets the endpoint

Specified by:
getEndpoint in interface RouteContext
Returns:
the endpoint

getFrom

public FromDefinition getFrom()
Description copied from interface: RouteContext
Gets the from type

Specified by:
getFrom in interface RouteContext
Returns:
the from type

getRoute

public RouteDefinition getRoute()
Description copied from interface: RouteContext
Get the route type

Specified by:
getRoute in interface RouteContext
Returns:
the route type

getCamelContext

public CamelContext getCamelContext()
Description copied from interface: RouteContext
Gets the camel context

Specified by:
getCamelContext in interface RouteContext
Returns:
the camel context

resolveEndpoint

public Endpoint resolveEndpoint(String uri)
Description copied from interface: RouteContext
Resolves an endpoint from the URI

Specified by:
resolveEndpoint in interface RouteContext
Parameters:
uri - the URI
Returns:
the resolved endpoint

resolveEndpoint

public Endpoint resolveEndpoint(String uri,
                                String ref)
Description copied from interface: RouteContext
Resolves an endpoint from either a URI or a named reference

Specified by:
resolveEndpoint in interface RouteContext
Parameters:
uri - the URI or
ref - the named reference
Returns:
the resolved endpoint

lookup

public <T> T lookup(String name,
                    Class<T> type)
Description copied from interface: RouteContext
lookup an object by name and type

Specified by:
lookup in interface RouteContext
Parameters:
name - the name to lookup
type - the expected type
Returns:
the found object

lookupByType

public <T> Map<String,T> lookupByType(Class<T> type)
Description copied from interface: RouteContext
lookup objects by type

Specified by:
lookupByType in interface RouteContext
Parameters:
type - the expected type
Returns:
the found objects with the name as the key in the map. Returns an empty map if none found.

mandatoryLookup

public <T> T mandatoryLookup(String name,
                             Class<T> type)
Description copied from interface: RouteContext
lookup an object by name and type or throws NoSuchBeanException if not found.

Specified by:
mandatoryLookup in interface RouteContext
Parameters:
name - the name to lookup
type - the expected type
Returns:
the found object

commit

public void commit()
Description copied from interface: RouteContext
For completing the route creation, creating a single event driven route for the current from endpoint with any processors required

Specified by:
commit in interface RouteContext

addEventDrivenProcessor

public void addEventDrivenProcessor(Processor processor)
Description copied from interface: RouteContext
Adds an event driven processor

Specified by:
addEventDrivenProcessor in interface RouteContext
Parameters:
processor - the processor

getInterceptStrategies

public List<InterceptStrategy> getInterceptStrategies()
Description copied from interface: RouteContext
This method retrieves the InterceptStrategy instances this route context.

Specified by:
getInterceptStrategies in interface RouteContext
Returns:
the strategy

setInterceptStrategies

public void setInterceptStrategies(List<InterceptStrategy> interceptStrategies)
Description copied from interface: RouteContext
This method sets the InterceptStrategy instances on this route context.

Specified by:
setInterceptStrategies in interface RouteContext
Parameters:
interceptStrategies - the strategies

addInterceptStrategy

public void addInterceptStrategy(InterceptStrategy interceptStrategy)
Description copied from interface: RouteContext
Adds a InterceptStrategy to this route context

Specified by:
addInterceptStrategy in interface RouteContext
Parameters:
interceptStrategy - the strategy

setManagedInterceptStrategy

public void setManagedInterceptStrategy(InterceptStrategy interceptStrategy)
Description copied from interface: RouteContext
Sets a special intercept strategy for management.

Is by default used to correlate managed performance counters with processors when the runtime route is being constructed

Specified by:
setManagedInterceptStrategy in interface RouteContext
Parameters:
interceptStrategy - the managed intercept strategy

getManagedInterceptStrategy

public InterceptStrategy getManagedInterceptStrategy()
Description copied from interface: RouteContext
Gets the special managed intercept strategy if any

Specified by:
getManagedInterceptStrategy in interface RouteContext
Returns:
the managed intercept strategy, or null if not managed

isRouteAdded

public boolean isRouteAdded()
Description copied from interface: RouteContext
Returns the isRouteAdded flag

Specified by:
isRouteAdded in interface RouteContext
Returns:
the flag

setIsRouteAdded

public void setIsRouteAdded(boolean routeAdded)
Description copied from interface: RouteContext
If this flag is true, ProcessorDefinition.addRoutes(RouteContext, java.util.Collection) will not add processor to addEventDrivenProcessor to the RouteContext and it will prevent from adding an EventDrivenRoute.

Specified by:
setIsRouteAdded in interface RouteContext
Parameters:
routeAdded - the flag

setTracing

public void setTracing(Boolean tracing)
Description copied from interface: RuntimeConfiguration
Sets whether tracing is enabled or not (default is disabled).

Specified by:
setTracing in interface RuntimeConfiguration
Parameters:
tracing - whether to enable tracing.

isTracing

public Boolean isTracing()
Description copied from interface: RuntimeConfiguration
Returns whether tracing enabled

Specified by:
isTracing in interface RuntimeConfiguration
Returns:
true if tracing is enabled

setStreamCaching

public void setStreamCaching(Boolean cache)
Description copied from interface: RuntimeConfiguration
Sets whether stream caching is enabled or not (default is disabled).

Specified by:
setStreamCaching in interface RuntimeConfiguration
Parameters:
cache - whether stream caching is enabled or not

isStreamCaching

public Boolean isStreamCaching()
Description copied from interface: RuntimeConfiguration
Returns whether stream cache is enabled

Specified by:
isStreamCaching in interface RuntimeConfiguration
Returns:
true if stream cache is enabled

setHandleFault

public void setHandleFault(Boolean handleFault)
Description copied from interface: RuntimeConfiguration
Sets whether fault handling is enabled or not (default is disabled).

Specified by:
setHandleFault in interface RuntimeConfiguration
Parameters:
handleFault - whether to enable fault handling.

isHandleFault

public Boolean isHandleFault()
Description copied from interface: RuntimeConfiguration
Returns whether fault handling enabled

Specified by:
isHandleFault in interface RuntimeConfiguration
Returns:
true if fault handling is enabled

setDelayer

public void setDelayer(Long delay)
Description copied from interface: RuntimeConfiguration
Sets a delay value in millis that a message is delayed at every step it takes in the route path, slowing the process down to better observe what is occurring

Is disabled by default

Specified by:
setDelayer in interface RuntimeConfiguration
Parameters:
delay - delay in millis

getDelayer

public Long getDelayer()
Description copied from interface: RuntimeConfiguration
Gets the delay value

Specified by:
getDelayer in interface RuntimeConfiguration
Returns:
delay in millis, or null if disabled

setAutoStartup

public void setAutoStartup(Boolean autoStartup)
Description copied from interface: RuntimeConfiguration
Sets whether the object should automatically start when Camel starts.

Currently only routes can be disabled, as CamelContexts are always started.
Default is true to always start up.

Specified by:
setAutoStartup in interface RuntimeConfiguration
Parameters:
autoStartup - whether to start up automatically.

isAutoStartup

public Boolean isAutoStartup()
Description copied from interface: RuntimeConfiguration
Gets whether the object should automatically start when Camel starts.

Specified by:
isAutoStartup in interface RuntimeConfiguration
Returns:
true if object should automatically start

setShutdownRoute

public void setShutdownRoute(ShutdownRoute shutdownRoute)
Description copied from interface: RuntimeConfiguration
Sets the ShutdownRoute option for routes.

Specified by:
setShutdownRoute in interface RuntimeConfiguration
Parameters:
shutdownRoute - the option to use.

getShutdownRoute

public ShutdownRoute getShutdownRoute()
Description copied from interface: RuntimeConfiguration
Gets the option to use when shutting down the route.

Specified by:
getShutdownRoute in interface RuntimeConfiguration
Returns:
the option

setShutdownRunningTask

public void setShutdownRunningTask(ShutdownRunningTask shutdownRunningTask)
Description copied from interface: RuntimeConfiguration
Sets the ShutdownRunningTask option to use when shutting down a route.

Specified by:
setShutdownRunningTask in interface RuntimeConfiguration
Parameters:
shutdownRunningTask - the option to use.

getShutdownRunningTask

public ShutdownRunningTask getShutdownRunningTask()
Description copied from interface: RuntimeConfiguration
Gets the ShutdownRunningTask option in use when shutting down a route.

Specified by:
getShutdownRunningTask in interface RuntimeConfiguration
Returns:
the option

getAndIncrement

public int getAndIncrement(ProcessorDefinition<?> node)
Description copied from interface: RouteContext
A private counter that increments, is used to as book keeping when building a route based on the model

We need this special book keeping be able to assign the correct ProcessorDefinition to the Channel

Specified by:
getAndIncrement in interface RouteContext
Parameters:
node - the current node
Returns:
the current count

setRoutePolicyList

public void setRoutePolicyList(List<RoutePolicy> routePolicyList)
Description copied from interface: RouteContext
Sets a custom route policy List

Specified by:
setRoutePolicyList in interface RouteContext
Parameters:
routePolicyList - the custom route policy list

getRoutePolicyList

public List<RoutePolicy> getRoutePolicyList()
Description copied from interface: RouteContext
Gets the route policy List

Specified by:
getRoutePolicyList in interface RouteContext
Returns:
the route policy list if any


Apache CAMEL