Coverage Report - org.mule.module.cxf.support.ResetStaxInterceptor
 
Classes in this File Line Coverage Branch Coverage Complexity
ResetStaxInterceptor
0%
0/9
N/A
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 org.mule.module.xml.stax.ReversibleXMLStreamReader;
 10  
 
 11  
 import java.util.List;
 12  
 
 13  
 import org.apache.cxf.interceptor.Fault;
 14  
 import org.apache.cxf.interceptor.StaxInInterceptor;
 15  
 import org.apache.cxf.message.Message;
 16  
 import org.apache.cxf.message.MessageContentsList;
 17  
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 18  
 import org.apache.cxf.phase.Phase;
 19  
 
 20  
 /**
 21  
  * Replaces the XMLStreamReader with a ReversibleXMLStreamReader which caches the xml events so 
 22  
  * we can replay them later.
 23  
  */
 24  
 public class ResetStaxInterceptor extends AbstractPhaseInterceptor<Message>
 25  
 {
 26  
 
 27  
     public ResetStaxInterceptor()
 28  
     {
 29  0
         super(Phase.PRE_INVOKE);
 30  0
         getAfter().add(StaxInInterceptor.class.getName());
 31  0
     }
 32  
 
 33  
     public void handleMessage(Message message) throws Fault
 34  
     {
 35  0
         ReversibleXMLStreamReader reader = message.getContent(ReversibleXMLStreamReader.class);
 36  0
         reader.reset();
 37  
         
 38  
         // Replace the message contents because if you're using WSS4J, it leaves the
 39  
         // stream pointing to the body, when we want it pointing to the envelope.
 40  0
         MessageContentsList parameters = new MessageContentsList();
 41  0
         parameters.add(reader);
 42  0
         message.setContent(List.class, parameters);
 43  0
     }
 44  
 }
 45  
 
 46