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