Coverage Report - org.mule.transport.cxf.support.CxfUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
CxfUtils
0%
0/14
0%
0/6
6
 
 1  
 /*
 2  
  * $Id: CxfUtils.java 11549 2008-04-09 05:12:30Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.transport.cxf.support;
 12  
 
 13  
 import org.mule.api.endpoint.EndpointNotFoundException;
 14  
 
 15  
 import java.io.IOException;
 16  
 
 17  
 import org.apache.cxf.endpoint.Endpoint;
 18  
 import org.apache.cxf.service.model.EndpointInfo;
 19  
 import org.apache.cxf.transport.ChainInitiationObserver;
 20  
 import org.apache.cxf.transport.Destination;
 21  
 import org.apache.cxf.transport.DestinationFactory;
 22  
 import org.apache.cxf.transport.MessageObserver;
 23  
 
 24  0
 public final class CxfUtils
 25  
 {
 26  
 
 27  
     public static Endpoint getEndpoint(DestinationFactory df, String uri)
 28  
         throws IOException, EndpointNotFoundException
 29  
     {
 30  0
         int idx = uri.indexOf('?');
 31  0
         if (idx != -1)
 32  
         {
 33  0
             uri = uri.substring(0, idx);
 34  
         }
 35  
 
 36  0
         EndpointInfo ei = new EndpointInfo();
 37  0
         ei.setAddress(uri);
 38  
 
 39  0
         Destination d = df.getDestination(ei);
 40  0
         if (d.getMessageObserver() == null)
 41  
         {
 42  
             // TODO is this the right Mule exception?
 43  0
             throw new EndpointNotFoundException(uri);
 44  
         }
 45  
 
 46  0
         MessageObserver mo = d.getMessageObserver();
 47  0
         if (!(mo instanceof ChainInitiationObserver))
 48  
         {
 49  0
             throw new EndpointNotFoundException(uri);
 50  
         }
 51  
 
 52  0
         ChainInitiationObserver co = (ChainInitiationObserver) mo;
 53  0
         return co.getEndpoint();
 54  
     }
 55  
 
 56  
 }