Coverage Report - org.mule.module.cxf.builder.ProxyServiceMessageProcessorBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
ProxyServiceMessageProcessorBuilder
0%
0/24
0%
0/4
0
 
 1  
 /*
 2  
  * $Id: ProxyServiceMessageProcessorBuilder.java 19191 2010-08-25 21:05:23Z tcarlson $
 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.builder;
 12  
 
 13  
 import org.mule.module.cxf.CxfConstants;
 14  
 import org.mule.module.cxf.support.CopyAttachmentInInterceptor;
 15  
 import org.mule.module.cxf.support.CopyAttachmentOutInterceptor;
 16  
 import org.mule.module.cxf.support.CxfUtils;
 17  
 import org.mule.module.cxf.support.OutputPayloadInterceptor;
 18  
 import org.mule.module.cxf.support.ProxyService;
 19  
 import org.mule.module.cxf.support.ProxyServiceFactoryBean;
 20  
 import org.mule.module.cxf.support.ResetStaxInterceptor;
 21  
 import org.mule.module.cxf.support.ReversibleStaxInInterceptor;
 22  
 
 23  
 import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
 24  
 import org.apache.cxf.databinding.stax.StaxDataBinding;
 25  
 import org.apache.cxf.databinding.stax.StaxDataBindingFeature;
 26  
 import org.apache.cxf.endpoint.Server;
 27  
 import org.apache.cxf.frontend.ServerFactoryBean;
 28  
 
 29  
 /**
 30  
  * Creates an inbound proxy based on a specially configure CXF Server.
 31  
  * This allows you to send raw XML to your MessageProcessor and have it sent
 32  
  * through CXF for SOAP processing, WS-Security, etc.
 33  
  * <p>
 34  
  * The input to the resulting MessageProcessor can be either a SOAP Body
 35  
  * or a SOAP Envelope depending on how the payload attribute is configured.
 36  
  * Valid values are "body" or "envelope". 
 37  
  */
 38  0
 public class ProxyServiceMessageProcessorBuilder extends AbstractInboundMessageProcessorBuilder
 39  
 {
 40  
     private String payload;
 41  
     
 42  
     @Override
 43  
     protected ServerFactoryBean createServerFactory() throws Exception
 44  
     {
 45  0
         ServerFactoryBean sfb = new ServerFactoryBean();
 46  0
         sfb.setDataBinding(new StaxDataBinding());
 47  0
         sfb.getFeatures().add(new StaxDataBindingFeature());
 48  0
         sfb.setServiceFactory(new ProxyServiceFactoryBean());
 49  0
         sfb.setServiceClass(ProxyService.class);
 50  
         
 51  0
         addProxyInterceptors(sfb);
 52  
         
 53  0
         return sfb;
 54  
     }
 55  
 
 56  
     @Override
 57  
     protected Class<?> getServiceClass()
 58  
     {
 59  0
         return ProxyService.class;
 60  
     }
 61  
 
 62  
     @Override
 63  
     protected void configureServer(Server server)
 64  
     {
 65  0
         if (isProxyEnvelope()) 
 66  
         {
 67  0
             CxfUtils.removeInterceptor(server.getEndpoint().getBinding().getOutInterceptors(), SoapOutInterceptor.class.getName());
 68  
         }
 69  
         
 70  0
     }
 71  
 
 72  
     @Override
 73  
     public boolean isProxy()
 74  
     {
 75  0
         return true;
 76  
     }
 77  
 
 78  
     protected void addProxyInterceptors(ServerFactoryBean sfb)
 79  
     {
 80  0
         sfb.getOutInterceptors().add(new OutputPayloadInterceptor());
 81  0
         sfb.getInInterceptors().add(new CopyAttachmentInInterceptor());
 82  0
         sfb.getOutInterceptors().add(new CopyAttachmentOutInterceptor());
 83  
         
 84  0
         if (isProxyEnvelope()) 
 85  
         {
 86  0
             sfb.getInInterceptors().add(new ReversibleStaxInInterceptor());
 87  0
             sfb.getInInterceptors().add(new ResetStaxInterceptor());
 88  
         }
 89  0
     }
 90  
 
 91  
     public boolean isProxyEnvelope()
 92  
     {
 93  0
         return CxfConstants.PAYLOAD_ENVELOPE.equals(payload);
 94  
     }
 95  
 
 96  
     public String getPayload()
 97  
     {
 98  0
         return payload;
 99  
     }
 100  
 
 101  
     public void setPayload(String payload)
 102  
     {
 103  0
         this.payload = payload;
 104  0
     }
 105  
     
 106  
 }