Coverage Report - org.kuali.rice.ksb.messaging.serviceconnectors.SOAPConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
SOAPConnector
0%
0/22
0%
0/4
2.333
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.ksb.messaging.serviceconnectors;
 18  
 
 19  
 import java.net.URL;
 20  
 
 21  
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 22  
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 23  
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 24  
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 25  
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 26  
 import org.kuali.rice.core.api.exception.RiceRuntimeException;
 27  
 import org.kuali.rice.ksb.api.bus.support.SoapServiceConfiguration;
 28  
 import org.kuali.rice.ksb.security.soap.CXFWSS4JInInterceptor;
 29  
 import org.kuali.rice.ksb.security.soap.CXFWSS4JOutInterceptor;
 30  
 import org.kuali.rice.ksb.security.soap.CredentialsOutHandler;
 31  
 import org.kuali.rice.ksb.service.KSBServiceLocator;
 32  
 
 33  
 
 34  
 /**
 35  
  *
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  * @since 0.9
 38  
  */
 39  
 public class SOAPConnector extends AbstractServiceConnector {
 40  
         
 41  
         public SOAPConnector(final SoapServiceConfiguration serviceConfiguration, final URL alternateEndpointUrl) {
 42  0
                 super(serviceConfiguration, alternateEndpointUrl);
 43  0
         }
 44  
 
 45  
         protected SoapServiceConfiguration getSoapServiceConfiguration() {
 46  0
                 return (SoapServiceConfiguration)getServiceConfiguration();
 47  
         }
 48  
         
 49  
         /**
 50  
          * This overridden method returns a CXF client proxy for web service.
 51  
          * 
 52  
          * @see org.kuali.rice.ksb.messaging.serviceconnectors.ServiceConnector#getService()
 53  
          */
 54  
         public Object getService() {
 55  
                 ClientProxyFactoryBean clientFactory;
 56  
                 
 57  
                 //Use the correct bean factory depending on pojo service or jaxws service
 58  0
                 if (getSoapServiceConfiguration().isJaxWsService()){                        
 59  0
                         clientFactory = new JaxWsProxyFactoryBean();
 60  
                 } else {
 61  0
                         clientFactory = new ClientProxyFactoryBean();
 62  0
                         clientFactory.getServiceFactory().setDataBinding(new AegisDatabinding());
 63  
                 }                
 64  
 
 65  
                 try {
 66  0
                         clientFactory.setServiceClass(Class.forName(getSoapServiceConfiguration().getServiceInterface()));
 67  0
                 } catch (ClassNotFoundException e) {
 68  0
                         throw new RiceRuntimeException("Failed to connect to soap service " + getServiceConfiguration().getServiceName() + " because failed to load interface class: " + getSoapServiceConfiguration().getServiceInterface(), e);
 69  0
                 }
 70  0
                 clientFactory.setBus(KSBServiceLocator.getCXFBus());
 71  0
                 clientFactory.setServiceName(getSoapServiceConfiguration().getServiceName());
 72  0
                 clientFactory.setAddress(getActualEndpointUrl().toExternalForm());
 73  
                 
 74  
                 //Set logging and security interceptors
 75  0
                 clientFactory.getOutInterceptors().add(new LoggingOutInterceptor());
 76  0
                 clientFactory.getOutInterceptors().add(new CXFWSS4JOutInterceptor(getSoapServiceConfiguration().getBusSecurity()));
 77  0
                 if (getCredentialsSource() != null) {
 78  0
                         clientFactory.getOutInterceptors().add(new CredentialsOutHandler(getCredentialsSource(), getSoapServiceConfiguration()));
 79  
                 }
 80  
                 
 81  0
                 clientFactory.getInInterceptors().add(new LoggingInInterceptor());
 82  0
                 clientFactory.getInInterceptors().add(new CXFWSS4JInInterceptor(getSoapServiceConfiguration().getBusSecurity()));
 83  
                 
 84  0
                 Object service = clientFactory.create();                
 85  0
                 return getServiceProxyWithFailureMode(service, getSoapServiceConfiguration());
 86  
         }        
 87  
 }