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:
Channel, Navigate<Processor>, Processor, Service

public class DefaultChannel
extends ServiceSupport
implements Processor, 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: 771248 $

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 defintion of the next processor
 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
 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, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, removeChildService, 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 Channel
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 defintion of the next processor

Specified by:
getProcessorDefinition in interface Channel

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 defintion the Channel represents
routeContext - the route context
Throws:
Exception - is thrown if some error occured

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.

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 © 2009 Apache Software Foundation. All Rights Reserved.