Coverage Report - org.mule.providers.soap.axis.AxisServiceProxy
 
Classes in this File Line Coverage Branch Coverage Complexity
AxisServiceProxy
0%
0/5
N/A
2.5
AxisServiceProxy$AxisServiceHandler
0%
0/18
0%
0/3
2.5
 
 1  
 /*
 2  
  * $Id: AxisServiceProxy.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.providers.soap.axis;
 12  
 
 13  
 import org.mule.config.ExceptionHelper;
 14  
 import org.mule.config.MuleProperties;
 15  
 import org.mule.impl.MuleMessage;
 16  
 import org.mule.impl.RequestContext;
 17  
 import org.mule.providers.AbstractMessageReceiver;
 18  
 import org.mule.providers.soap.ServiceProxy;
 19  
 import org.mule.providers.soap.axis.extras.AxisCleanAndAddProperties;
 20  
 import org.mule.umo.UMOException;
 21  
 import org.mule.umo.UMOExceptionPayload;
 22  
 import org.mule.umo.UMOMessage;
 23  
 import org.mule.umo.provider.UMOMessageAdapter;
 24  
 
 25  
 import java.lang.reflect.InvocationHandler;
 26  
 import java.lang.reflect.Method;
 27  
 import java.lang.reflect.Proxy;
 28  
 
 29  
 /**
 30  
  * <code>ServiceProxy</code> is a proxy that wraps a soap endpointUri to look like
 31  
  * a Web service. Also provides helper methods for building and describing web
 32  
  * service interfaces in Mule.
 33  
  * 
 34  
  * @author <a href="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
 35  
  * @version $Revision: 7976 $
 36  
  */
 37  
 
 38  0
 public class AxisServiceProxy extends ServiceProxy
 39  
 {
 40  
 
 41  
     public static Object createProxy(AbstractMessageReceiver receiver, boolean synchronous, Class[] classes)
 42  
     {
 43  0
         final ClassLoader cl = Thread.currentThread().getContextClassLoader();
 44  0
         return Proxy.newProxyInstance(cl, classes, createServiceHandler(receiver, synchronous));
 45  
     }
 46  
 
 47  
     public static InvocationHandler createServiceHandler(AbstractMessageReceiver receiver, boolean synchronous)
 48  
     {
 49  0
         return new AxisServiceHandler(receiver, synchronous);
 50  
     }
 51  
 
 52  0
     private static class AxisServiceHandler implements InvocationHandler
 53  
     {
 54  
         private AbstractMessageReceiver receiver;
 55  0
         private boolean synchronous = true;
 56  
 
 57  
         public AxisServiceHandler(AbstractMessageReceiver receiver, boolean synchronous)
 58  0
         {
 59  0
             this.receiver = receiver;
 60  0
             this.synchronous = synchronous;
 61  0
         }
 62  
 
 63  
         public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
 64  
         {
 65  0
             UMOMessageAdapter messageAdapter = receiver.getConnector().getMessageAdapter(args);
 66  0
             messageAdapter.setProperty(MuleProperties.MULE_METHOD_PROPERTY, method);
 67  
             
 68  
             // add all custom headers, filter out all mule headers (such as
 69  
             // MULE_SESSION) except
 70  
             // for MULE_USER header. Filter out other headers like "soapMethods" and
 71  
             // MuleProperties.MULE_METHOD_PROPERTY and "soapAction"
 72  
             // and also filter out any http related header
 73  0
             messageAdapter.addProperties(AxisCleanAndAddProperties.cleanAndAdd(RequestContext.getEventContext()));                        
 74  
                                    
 75  0
             UMOMessage message = receiver.routeMessage(new MuleMessage(messageAdapter), synchronous);
 76  
             
 77  0
             if (message != null)
 78  
             {
 79  0
                 UMOExceptionPayload wsException = message.getExceptionPayload();
 80  
 
 81  0
                 if (wsException != null)
 82  
                 {
 83  0
                     UMOException umoException = ExceptionHelper.getRootMuleException(wsException.getException());
 84  
                     // if the exception has a cause, then throw only the cause
 85  0
                     if (umoException.getCause() != null)
 86  
                     {
 87  0
                         throw umoException.getCause();
 88  
                     }
 89  
                     else
 90  
                     {
 91  0
                         throw umoException;
 92  
                     }
 93  
                 }
 94  
 
 95  0
                 return message.getPayload();
 96  
             }
 97  
             else
 98  
             {
 99  0
                 return null;
 100  
             }
 101  
         }
 102  
     }
 103  
 }