View Javadoc

1   /*
2    * $Id: CxfComponentExceptionStrategy.java 19651 2010-09-14 15:22:50Z dirk.olmes $
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.MuleContext;
14  import org.mule.exception.DefaultServiceExceptionStrategy;
15  
16  import org.apache.cxf.interceptor.Fault;
17  
18  /**
19   * This exception strategy forces the exception thrown from a web service invocation
20   * to be passed as-is, not wrapped in a Mule exception object. This ensures the Cxf
21   * serialiser/deserialiser can send the correct exception object to the client.
22   */
23  public class CxfComponentExceptionStrategy extends DefaultServiceExceptionStrategy
24  {
25      public CxfComponentExceptionStrategy(MuleContext context)
26      {
27          super(context);
28      }
29      
30      @Override
31      protected void defaultHandler(Throwable t)
32      {
33          if (t.getCause() instanceof Fault)
34          {
35              super.defaultHandler(t.getCause());
36          }
37          else
38          {
39              super.defaultHandler(t);
40          }
41      }
42  }