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:
$Revision: 1040099 $

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()
          Lets complete the route creation, creating a single event driven route for the current from endpoint with any processors required
 Processor createProcessor(ProcessorDefinition<?> node)
          Creates a processor
 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
 RoutePolicy getRoutePolicy()
          Gets the route policy
 ShutdownRoute getShutdownRoute()
          Gets the option to use when shutting down route.
 ShutdownRunningTask getShutdownRunningTask()
          Gets the option to use when shutting down a route and how to act when it has running tasks.
 Boolean isAutoStartup()
          Gets whether it should automatic start when Camel starts.
 Boolean isHandleFault()
          Returns whether tracing 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
 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 it should automatic 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, to slow things down to better helps you to see what goes

Is disabled by default

 void setHandleFault(Boolean handleFault)
          Sets whether handle fault 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 setRoutePolicy(RoutePolicy routePolicy)
          Sets a custom route policy
 void setShutdownRoute(ShutdownRoute shutdownRoute)
          Sets the option to use when shutting down routes.
 void setShutdownRunningTask(ShutdownRunningTask shutdownRunningTask)
          Sets the option to use when shutting down a route and how to act when it has running tasks.
 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

createProcessor

public Processor createProcessor(ProcessorDefinition<?> node)
                          throws Exception
Description copied from interface: RouteContext
Creates a processor

Specified by:
createProcessor in interface RouteContext
Parameters:
node - the node
Returns:
the created processor
Throws:
Exception - can be thrown

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.

commit

public void commit()
Description copied from interface: RouteContext
Lets complete 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).

Is disabled by default

Specified by:
setTracing in interface RuntimeConfiguration
Parameters:
tracing - whether tracing is enabled or not.

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).

Is disabled by default

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 handle fault is enabled or not (default is disabled).

Is disabled by default

Specified by:
setHandleFault in interface RuntimeConfiguration
Parameters:
handleFault - whether handle fault is enabled or not.

isHandleFault

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

Specified by:
isHandleFault in interface RuntimeConfiguration
Returns:
true if tracing 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, to slow things down to better helps you to see what goes

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 it should automatic start when Camel starts.

Currently only routes can be disabled, as CamelContext itself are always started}
Default is true to always startup.

Specified by:
setAutoStartup in interface RuntimeConfiguration
Parameters:
autoStartup - whether to auto startup.

isAutoStartup

public Boolean isAutoStartup()
Description copied from interface: RuntimeConfiguration
Gets whether it should automatic start when Camel starts.

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

setShutdownRoute

public void setShutdownRoute(ShutdownRoute shutdownRoute)
Description copied from interface: RuntimeConfiguration
Sets the option to use when shutting down 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 route.

Specified by:
getShutdownRoute in interface RuntimeConfiguration
Returns:
the option

setShutdownRunningTask

public void setShutdownRunningTask(ShutdownRunningTask shutdownRunningTask)
Description copied from interface: RuntimeConfiguration
Sets the option to use when shutting down a route and how to act when it has running tasks.

A running task is for example a BatchConsumer which has a group of messages to process. With this option you can control whether it should complete the entire group or stop after the current message has been processed.

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

getShutdownRunningTask

public ShutdownRunningTask getShutdownRunningTask()
Description copied from interface: RuntimeConfiguration
Gets the option to use when shutting down a route and how to act when it has running tasks.

Specified by:
getShutdownRunningTask in interface RuntimeConfiguration
Returns:
the option

getRoutePolicy

public RoutePolicy getRoutePolicy()
Description copied from interface: RouteContext
Gets the route policy

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

setRoutePolicy

public void setRoutePolicy(RoutePolicy routePolicy)
Description copied from interface: RouteContext
Sets a custom route policy

Specified by:
setRoutePolicy in interface RouteContext
Parameters:
routePolicy - the custom route policy

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


Apache CAMEL