org.apache.camel.processor
Class CatchProcessor

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.processor.DelegateAsyncProcessor
          extended by org.apache.camel.processor.CatchProcessor
All Implemented Interfaces:
AsyncProcessor, DelegateProcessor, Navigate<Processor>, Processor, Service, ShutdownableService, StatefulService, SuspendableService, Traceable

public class CatchProcessor
extends DelegateAsyncProcessor
implements Traceable

A processor which catches exceptions.

Version:

Field Summary
 
Fields inherited from class org.apache.camel.processor.DelegateAsyncProcessor
processor
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
CatchProcessor(List<Class<? extends Throwable>> exceptions, Processor processor, Predicate onWhen, Predicate handled)
           
 
Method Summary
 Throwable catches(Exchange exchange, Throwable exception)
          Returns with the exception that is caught by this processor.
 List<Class<? extends Throwable>> getExceptions()
           
 String getTraceLabel()
          Gets the trace label used for logging when tracing is enabled.
 boolean handles(Exchange exchange)
          Whether this catch processor handles the exception it have caught
protected  boolean matchesWhen(Exchange exchange)
          Strategy method for matching the exception type with the current exchange.
 String toString()
           
 
Methods inherited from class org.apache.camel.processor.DelegateAsyncProcessor
doStart, doStop, getProcessor, hasNext, next, process, process, processNext, setProcessor, setProcessor
 
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

CatchProcessor

public CatchProcessor(List<Class<? extends Throwable>> exceptions,
                      Processor processor,
                      Predicate onWhen,
                      Predicate handled)
Method Detail

toString

public String toString()
Overrides:
toString in class DelegateAsyncProcessor

getTraceLabel

public String getTraceLabel()
Description copied from interface: Traceable
Gets the trace label used for logging when tracing is enabled.

The label should be short and precise.

Specified by:
getTraceLabel in interface Traceable
Returns:
the label

catches

public Throwable catches(Exchange exchange,
                         Throwable exception)
Returns with the exception that is caught by this processor. This method traverses exception causes, so sometimes the exception returned from this method might be one of causes of the parameter passed.

Parameters:
exchange - the current exchange
exception - the thrown exception
Returns:
Throwable that this processor catches. null if nothing matches.

handles

public boolean handles(Exchange exchange)
Whether this catch processor handles the exception it have caught

Parameters:
exchange - the current exchange
Returns:
true if this processor handles it, false otherwise.

getExceptions

public List<Class<? extends Throwable>> getExceptions()

matchesWhen

protected boolean matchesWhen(Exchange exchange)
Strategy method for matching the exception type with the current exchange.

This default implementation will match as:

Parameters:
exchange - the current Exchange
Returns:
true if matched, false otherwise.


Apache CAMEL