Coverage Report - org.mule.module.cxf.support.ProxyServiceFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
ProxyServiceFactoryBean
0%
0/35
0%
0/14
0
 
 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.support;
 8  
 
 9  
 import java.lang.reflect.Method;
 10  
 import java.util.ArrayList;
 11  
 import java.util.List;
 12  
 import java.util.logging.Level;
 13  
 import java.util.logging.Logger;
 14  
 
 15  
 import javax.xml.namespace.QName;
 16  
 import javax.xml.transform.Source;
 17  
 
 18  
 import org.apache.cxf.common.logging.LogUtils;
 19  
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 20  
 import org.apache.cxf.service.factory.ServiceConstructionException;
 21  
 import org.apache.cxf.service.model.EndpointInfo;
 22  
 import org.apache.cxf.service.model.OperationInfo;
 23  
 import org.apache.cxf.service.model.ServiceInfo;
 24  
 import org.mule.module.cxf.i18n.CxfMessages;
 25  
 
 26  
 public class ProxyServiceFactoryBean extends ReflectionServiceFactoryBean
 27  
 {
 28  
 
 29  0
     private static final Logger LOG = LogUtils.getLogger(ProxyServiceFactoryBean.class);
 30  
 
 31  
     public ProxyServiceFactoryBean()
 32  0
     {
 33  0
         getServiceConfigurations().add(0, new ProxyServiceConfiguration());
 34  
 
 35  0
         List<String> ignoredClasses = new ArrayList<String>();
 36  0
         ignoredClasses.add("java.lang.Object");
 37  0
         ignoredClasses.add("java.lang.Throwable");
 38  0
         ignoredClasses.add("org.omg.CORBA_2_3.portable.ObjectImpl");
 39  0
         ignoredClasses.add("org.omg.CORBA.portable.ObjectImpl");
 40  0
         ignoredClasses.add("javax.ejb.EJBObject");
 41  0
         ignoredClasses.add("javax.rmi.CORBA.Stub");
 42  0
         setIgnoredClasses(ignoredClasses);
 43  0
     }
 44  
 
 45  
 
 46  
     @Override
 47  
     protected void initializeFaultInterceptors()
 48  
     {
 49  0
         getService().getOutFaultInterceptors().add(new ProxyFaultOutInterceptor());
 50  0
     }
 51  
 
 52  
     @Override
 53  
     protected void initializeWSDLOperations()
 54  
     {
 55  0
         if (getServiceClass().isAssignableFrom(ProxyService.class))
 56  
         {
 57  0
             initializeWSDLOperationsForProvider();
 58  
         }
 59  
         else
 60  
         {
 61  0
             super.initializeWSDLOperations();
 62  
         }
 63  0
     }
 64  
 
 65  
     protected void initializeWSDLOperationsForProvider()
 66  
     {
 67  0
         Class c = Source.class;
 68  
 
 69  0
         if (getEndpointInfo() == null && isFromWsdl())
 70  
         {
 71  
             // most likely, they specified a WSDL, but for some reason
 72  
             // did not give a valid ServiceName/PortName. For provider,
 73  
             // we'll allow this since everything is bound directly to
 74  
             // the invoke method, however, this CAN cause other problems
 75  
             // such as addresses in the wsdl not getting updated and such
 76  
             // so we'll WARN about it.....
 77  0
             List<QName> enames = new ArrayList<QName>();
 78  0
             for (ServiceInfo si : getService().getServiceInfos())
 79  
             {
 80  0
                 for (EndpointInfo ep : si.getEndpoints())
 81  
                 {
 82  0
                     enames.add(ep.getName());
 83  
                 }
 84  
             }
 85  0
             LOG.log(Level.WARNING, "COULD_NOT_FIND_ENDPOINT",  new ComponentNotFoundRuntimeException(
 86  
                 CxfMessages.couldNotFindEndpoint(getEndpointName(), enames)));
 87  
         }
 88  
 
 89  
         try
 90  
         {
 91  0
             Method invoke = getServiceClass().getMethod("invoke", c);
 92  
 
 93  
             // Bind every operation to the invoke method.
 94  0
             for (ServiceInfo si : getService().getServiceInfos())
 95  
             {
 96  0
                 for (OperationInfo o : si.getInterface().getOperations())
 97  
                 {
 98  0
                     getMethodDispatcher().bind(o, invoke);
 99  
                 }
 100  
             }
 101  
         }
 102  0
         catch (SecurityException e)
 103  
         {
 104  0
             throw new ServiceConstructionException(e);
 105  
         }
 106  0
         catch (NoSuchMethodException e)
 107  
         {
 108  0
             throw new ServiceConstructionException(e);
 109  0
         }
 110  
 
 111  0
     }
 112  
 
 113  
 }