org.apache.camel.processor.exceptionpolicy
Class DefaultExceptionPolicyStrategy

java.lang.Object
  extended by org.apache.camel.processor.exceptionpolicy.DefaultExceptionPolicyStrategy
All Implemented Interfaces:
ExceptionPolicyStrategy

public class DefaultExceptionPolicyStrategy
extends Object
implements ExceptionPolicyStrategy

The default strategy used in Camel to resolve the OnExceptionDefinition that should handle the thrown exception.

Selection strategy:
This strategy applies the following rules:

Fine grained matching:
If the OnExceptionDefinition has a when defined with an expression the type is also matches against the current exchange using the matchesWhen(org.apache.camel.model.OnExceptionDefinition, org.apache.camel.Exchange) method. This can be used to for more fine grained matching, so you can e.g. define multiple sets of exception types with the same exception class(es) but have a predicate attached to select which to select at runtime.


Constructor Summary
DefaultExceptionPolicyStrategy()
           
 
Method Summary
protected  Iterator<Throwable> createExceptionIterator(Throwable exception)
          Strategy method creating the iterator to walk the exception in the order Camel should use for find the OnExceptionDefinition should be used.
protected  boolean filter(OnExceptionDefinition type, Class<?> exceptionClass, Throwable exception)
          Strategy to filter the given type exception class with the thrown exception
 OnExceptionDefinition getExceptionPolicy(Map<ExceptionPolicyKey,OnExceptionDefinition> exceptionPolicies, Exchange exchange, Throwable exception)
          Resolves the OnExceptionDefinition that should handle the thrown exception.
protected  boolean matchesWhen(OnExceptionDefinition definition, Exchange exchange)
          Strategy method for matching the exception type with the current exchange.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultExceptionPolicyStrategy

public DefaultExceptionPolicyStrategy()
Method Detail

getExceptionPolicy

public OnExceptionDefinition getExceptionPolicy(Map<ExceptionPolicyKey,OnExceptionDefinition> exceptionPolicies,
                                                Exchange exchange,
                                                Throwable exception)
Description copied from interface: ExceptionPolicyStrategy
Resolves the OnExceptionDefinition that should handle the thrown exception.

Specified by:
getExceptionPolicy in interface ExceptionPolicyStrategy
Parameters:
exceptionPolicies - the configured exception policies to resolve from
exchange - the exchange
exception - the exception that was thrown
Returns:
the resolved exception type to handle this exception, null if none found.

filter

protected boolean filter(OnExceptionDefinition type,
                         Class<?> exceptionClass,
                         Throwable exception)
Strategy to filter the given type exception class with the thrown exception

Parameters:
type - the exception type
exceptionClass - the current exception class for testing
exception - the thrown exception
Returns:
true if the to current exception class is a candidate, false to skip it.

matchesWhen

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

This default implementation will match as:

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

createExceptionIterator

protected Iterator<Throwable> createExceptionIterator(Throwable exception)
Strategy method creating the iterator to walk the exception in the order Camel should use for find the OnExceptionDefinition should be used.

The default iterator will walk from the bottom upwards (the last caused by going upwards to the exception)

Parameters:
exception - the exception
Returns:
the iterator


Apache CAMEL