org.apache.camel.processor.interceptor
Class DefaultChannel

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.processor.interceptor.DefaultChannel
All Implemented Interfaces:
AsyncProcessor, Channel, ModelChannel, Navigate<Processor>, Processor, Service, ShutdownableService, StatefulService, SuspendableService

public class DefaultChannel
extends ServiceSupport
implements ModelChannel

DefaultChannel is the default Channel.

The current implementation is just a composite containing the interceptors and error handler that beforehand was added to the route graph directly.
With this Channel we can in the future implement better strategies for routing the Exchange in the route graph, as we have a Channel between each and every node in the graph.

Version:

Field Summary
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
DefaultChannel()
           
 
Method Summary
 void addInterceptStrategies(List<InterceptStrategy> strategies)
          Adds a list of InterceptStrategy to apply each Exchange before its routed to the next Processor.
 void addInterceptStrategy(InterceptStrategy strategy)
          Adds a InterceptStrategy to apply each Exchange before its routed to the next Processor.
protected  boolean continueProcessing(Exchange exchange)
          Strategy to determine if we should continue processing the Exchange.
protected  void doStart()
          Implementations override this method to support customized start/stop.
protected  void doStop()
          Implementations override this method to support customized start/stop.
 Processor getErrorHandler()
          Gets the ErrorHandler this Channel uses.
 List<InterceptStrategy> getInterceptStrategies()
          Gets the list of InterceptStrategy registered to this Channel.
 Processor getNextProcessor()
          Gets the next Processor to route to (not wrapped)
 Processor getOutput()
          Gets the wrapped output that at runtime should be delegated to.
 ProcessorDefinition<?> getProcessorDefinition()
          Gets the definition of the next processor
 RouteContext getRouteContext()
          Gets the RouteContext
 boolean hasInterceptorStrategy(Class<?> type)
           
 boolean hasNext()
          Are there more outputs?
 void initChannel(ProcessorDefinition<?> outputDefinition, RouteContext routeContext)
          Initializes the channel.
 List<Processor> next()
          Next group of outputs
 void postInitChannel(ProcessorDefinition<?> outputDefinition, RouteContext routeContext)
          Post initializes the channel.
 void process(Exchange exchange)
          Processes the message exchange
 boolean process(Exchange exchange, AsyncCallback callback)
          Processes the message exchange.
 void setChildDefinition(ProcessorDefinition<?> childDefinition)
          If the initialized output definition contained outputs (children) then we need to set the child so we can leverage fine grained tracing
 void setErrorHandler(Processor errorHandler)
          Sets the ErrorHandler this Channel uses.
 void setNextProcessor(Processor next)
          Sets the processor that the channel should route the Exchange to.
 void setOutput(Processor output)
          Sets the wrapped output that at runtime should be delegated to.
 String toString()
           
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultChannel

public DefaultChannel()
Method Detail

next

public List<Processor> next()
Description copied from interface: Navigate
Next group of outputs

Specified by:
next in interface Navigate<Processor>
Returns:
next group or null if no more outputs

hasNext

public boolean hasNext()
Description copied from interface: Navigate
Are there more outputs?

Specified by:
hasNext in interface Navigate<Processor>
Returns:
true if more outputs

setNextProcessor

public void setNextProcessor(Processor next)
Description copied from interface: Channel
Sets the processor that the channel should route the Exchange to.

Specified by:
setNextProcessor in interface Channel
Parameters:
next - the next processor

getOutput

public Processor getOutput()
Description copied from interface: Channel
Gets the wrapped output that at runtime should be delegated to.

Specified by:
getOutput in interface Channel
Returns:
the output to route the Exchange to

setOutput

public void setOutput(Processor output)
Description copied from interface: Channel
Sets the wrapped output that at runtime should be delegated to.

Specified by:
setOutput in interface Channel
Parameters:
output - the output to route the Exchange to

getNextProcessor

public Processor getNextProcessor()
Description copied from interface: Channel
Gets the next Processor to route to (not wrapped)

Specified by:
getNextProcessor in interface Channel
Returns:
the next processor

hasInterceptorStrategy

public boolean hasInterceptorStrategy(Class<?> type)

setErrorHandler

public void setErrorHandler(Processor errorHandler)
Description copied from interface: Channel
Sets the ErrorHandler this Channel uses.

Specified by:
setErrorHandler in interface Channel
Parameters:
errorHandler - the error handler

getErrorHandler

public Processor getErrorHandler()
Description copied from interface: Channel
Gets the ErrorHandler this Channel uses.

Specified by:
getErrorHandler in interface Channel
Returns:
the error handler, or null if no error handler is used.

addInterceptStrategy

public void addInterceptStrategy(InterceptStrategy strategy)
Description copied from interface: Channel
Adds a InterceptStrategy to apply each Exchange before its routed to the next Processor.

Specified by:
addInterceptStrategy in interface Channel
Parameters:
strategy - the intercept strategy

addInterceptStrategies

public void addInterceptStrategies(List<InterceptStrategy> strategies)
Description copied from interface: Channel
Adds a list of InterceptStrategy to apply each Exchange before its routed to the next Processor.

Specified by:
addInterceptStrategies in interface Channel
Parameters:
strategies - list of strategies

getInterceptStrategies

public List<InterceptStrategy> getInterceptStrategies()
Description copied from interface: Channel
Gets the list of InterceptStrategy registered to this Channel.

Specified by:
getInterceptStrategies in interface Channel
Returns:
list of strategies, returns an empty list if no strategies is registered.

getProcessorDefinition

public ProcessorDefinition<?> getProcessorDefinition()
Description copied from interface: ModelChannel
Gets the definition of the next processor

Specified by:
getProcessorDefinition in interface ModelChannel
Returns:
the processor definition

setChildDefinition

public void setChildDefinition(ProcessorDefinition<?> childDefinition)
Description copied from interface: ModelChannel
If the initialized output definition contained outputs (children) then we need to set the child so we can leverage fine grained tracing

Specified by:
setChildDefinition in interface ModelChannel
Parameters:
childDefinition - the child

getRouteContext

public RouteContext getRouteContext()
Description copied from interface: Channel
Gets the RouteContext

Specified by:
getRouteContext in interface Channel
Returns:
the route context

doStart

protected void doStart()
                throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: See ServiceSupport.doStop() for more details.

Specified by:
doStart in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStop()

doStop

protected void doStop()
               throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: Camel will invoke this ServiceSupport.doStop() method when the service is being stopped. This method will also be invoked if the service is still in uninitialized state (eg has not been started). The method is always called to allow the service to do custom logic when the service is being stopped, such as when CamelContext is shutting down.

Specified by:
doStop in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStart()

initChannel

public void initChannel(ProcessorDefinition<?> outputDefinition,
                        RouteContext routeContext)
                 throws Exception
Description copied from interface: ModelChannel
Initializes the channel.

Specified by:
initChannel in interface ModelChannel
Parameters:
outputDefinition - the route definition the Channel represents
routeContext - the route context
Throws:
Exception - is thrown if some error occurred

postInitChannel

public void postInitChannel(ProcessorDefinition<?> outputDefinition,
                            RouteContext routeContext)
                     throws Exception
Description copied from interface: ModelChannel
Post initializes the channel.

Specified by:
postInitChannel in interface ModelChannel
Parameters:
outputDefinition - the route definition the Channel represents
routeContext - the route context
Throws:
Exception - is thrown if some error occurred

process

public void process(Exchange exchange)
             throws Exception
Description copied from interface: Processor
Processes the message exchange

Specified by:
process in interface Processor
Parameters:
exchange - the message exchange
Throws:
Exception - if an internal processing error has occurred.

process

public boolean process(Exchange exchange,
                       AsyncCallback callback)
Description copied from interface: AsyncProcessor
Processes the message exchange. Similar to Processor.process(org.apache.camel.Exchange), but the caller supports having the exchange asynchronously processed.

If there was a failure processing then the caused Exception would be set on the Exchange.

Specified by:
process in interface AsyncProcessor
Parameters:
exchange - the message exchange
callback - the AsyncCallback will be invoked when the processing of the exchange is completed. If the exchange is completed synchronously, then the callback is also invoked synchronously. The callback should therefore be careful of starting recursive loop.
Returns:
(doneSync) true to continue execute synchronously, false to continue being executed asynchronously
See Also:
AsyncProcessorHelper.process(AsyncProcessor, Exchange, AsyncCallback)

continueProcessing

protected boolean continueProcessing(Exchange exchange)
Strategy to determine if we should continue processing the Exchange.


toString

public String toString()
Overrides:
toString in class Object


Apache CAMEL