org.apache.camel.processor
Class DefaultChannel

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

public class DefaultChannel
extends ServiceSupport
implements Channel

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

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()
           
protected  void doStop()
           
 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 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.impl.ServiceSupport
addChildService, doShutdown, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, removeChildService, shutdown, start, stop
 
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: Channel
Gets the definition of the next processor

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

setChildDefinition

public void setChildDefinition(ProcessorDefinition<?> childDefinition)
Description copied from interface: Channel
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 Channel
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
Specified by:
doStart in class ServiceSupport
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class ServiceSupport
Throws:
Exception

initChannel

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

Specified by:
initChannel in interface Channel
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:
org.apache.camel.util.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


Copyright © 2007-2010 IONA Open Source Community. All Rights Reserved.