View Javadoc

1   /*
2    * $Id: CxfComponentExceptionStrategy.java 22711 2011-08-20 01:50:25Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.module.cxf;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.exception.RollbackSourceCallback;
15  import org.mule.exception.DefaultMessagingExceptionStrategy;
16  
17  import org.apache.cxf.interceptor.Fault;
18  
19  /**
20   * This exception strategy forces the exception thrown from a web service invocation
21   * to be passed as-is, not wrapped in a Mule exception object. This ensures the Cxf
22   * serialiser/deserialiser can send the correct exception object to the client.
23   */
24  public class CxfComponentExceptionStrategy extends DefaultMessagingExceptionStrategy
25  {
26      @Override
27      protected void doHandleException(Exception e, MuleEvent event, RollbackSourceCallback rollbackMethod)
28      {
29          if (e.getCause() instanceof Fault)
30          {
31              super.doHandleException((Exception) e.getCause(), event, rollbackMethod);
32          }
33          else
34          {
35              super.doHandleException(e, event, rollbackMethod);
36          }
37      }
38  }