Coverage Report - org.kuali.rice.ksb.messaging.serviceexporters.SOAPServiceExporter
 
Classes in this File Line Coverage Branch Coverage Complexity
SOAPServiceExporter
0%
0/26
0%
0/2
2.5
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.ksb.messaging.serviceexporters;
 17  
 
 18  
 
 19  
 import org.apache.cxf.Bus;
 20  
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 21  
 import org.apache.cxf.endpoint.ServerRegistry;
 22  
 import org.apache.cxf.frontend.ServerFactoryBean;
 23  
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 24  
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 25  
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 26  
 import org.apache.log4j.Logger;
 27  
 import org.kuali.rice.core.api.exception.RiceRuntimeException;
 28  
 import org.kuali.rice.ksb.api.bus.ServiceDefinition;
 29  
 import org.kuali.rice.ksb.api.bus.support.SoapServiceDefinition;
 30  
 import org.kuali.rice.ksb.security.soap.CXFWSS4JInInterceptor;
 31  
 import org.kuali.rice.ksb.security.soap.CXFWSS4JOutInterceptor;
 32  
 
 33  
 
 34  
 /**
 35  
  *
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  */
 38  
 public class SOAPServiceExporter extends AbstractWebServiceExporter implements ServiceExporter {
 39  
 
 40  0
         static final Logger LOG = Logger.getLogger(SOAPServiceExporter.class);
 41  
                 
 42  
         public SOAPServiceExporter(SoapServiceDefinition serviceDefinition, Bus cxfBus, ServerRegistry cxfServerRegistry) {
 43  0
             super(serviceDefinition, cxfBus, cxfServerRegistry);
 44  0
         }
 45  
 
 46  
         /**
 47  
          * This publishes the cxf service onto the cxf bus.
 48  
          * 
 49  
          * @param serviceImpl
 50  
          * @throws Exception
 51  
          */
 52  
         @Override
 53  
     public void publishService(ServiceDefinition serviceDefinition, Object serviceImpl, String address) {
 54  
                 ServerFactoryBean svrFactory;
 55  
                 
 56  0
                 SoapServiceDefinition soapServiceDefinition = (SoapServiceDefinition)serviceDefinition;
 57  
                 
 58  
                 //Use the correct bean factory depending on pojo service or jaxws service
 59  0
                 if (soapServiceDefinition.isJaxWsService()){
 60  0
                         LOG.info("Creating JaxWsService " + soapServiceDefinition.getServiceName());
 61  0
                         svrFactory = new JaxWsServerFactoryBean();
 62  
                 } else {
 63  0
                         svrFactory = new ServerFactoryBean();
 64  
                         
 65  
                         //JAXB Binding not supported for pojo service (CXF-897)
 66  0
                         svrFactory.getServiceFactory().setDataBinding(new AegisDatabinding());
 67  
                 }
 68  
         
 69  0
                 svrFactory.setBus(getCXFBus());
 70  0
                 svrFactory.setServiceName(soapServiceDefinition.getServiceName());
 71  0
                 svrFactory.setAddress(address);
 72  0
                 svrFactory.setPublishedEndpointUrl(soapServiceDefinition.getEndpointUrl().toExternalForm());
 73  0
                 svrFactory.setServiceBean(serviceImpl);
 74  
                 
 75  
                 try {
 76  0
                         svrFactory.setServiceClass(Class.forName(soapServiceDefinition.getServiceInterface()));
 77  0
                 } catch (ClassNotFoundException e) {
 78  0
                         throw new RiceRuntimeException("Failed to publish service " + soapServiceDefinition.getServiceName() + " because service interface could not be loaded: " + soapServiceDefinition.getServiceInterface(), e);
 79  0
                 }
 80  
                 
 81  
                 //Set logging and security interceptors
 82  0
                 svrFactory.getInInterceptors().add(new LoggingInInterceptor());
 83  0
                 svrFactory.getInInterceptors().add(new CXFWSS4JInInterceptor(soapServiceDefinition.getBusSecurity()));
 84  
                 
 85  0
                 svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
 86  0
                 svrFactory.getOutInterceptors().add(new CXFWSS4JOutInterceptor(soapServiceDefinition.getBusSecurity()));
 87  
                 
 88  0
                 svrFactory.getInFaultInterceptors().add(new CXFWSS4JInInterceptor(soapServiceDefinition.getBusSecurity()));
 89  0
                 svrFactory.getOutFaultInterceptors().add(new CXFWSS4JOutInterceptor(soapServiceDefinition.getBusSecurity()));
 90  
                 
 91  0
                 svrFactory.create();
 92  0
         }
 93  
 
 94  
 }