Coverage Report - org.mule.transport.service.MetaTransportServiceDescriptor
 
Classes in this File Line Coverage Branch Coverage Complexity
MetaTransportServiceDescriptor
0%
0/14
0%
0/4
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.transport.service;
 8  
 
 9  
 import org.mule.api.registry.ServiceException;
 10  
 import org.mule.api.registry.ServiceType;
 11  
 import org.mule.api.transport.Connector;
 12  
 import org.mule.config.i18n.CoreMessages;
 13  
 import org.mule.transport.AbstractConnector;
 14  
 import org.mule.util.PropertiesUtils;
 15  
 import org.mule.util.SpiUtils;
 16  
 
 17  
 import java.util.Properties;
 18  
 
 19  
 /**
 20  
  * Used to describe a Meta transport, one which only defines an endpoint, not a connector, receiver, dispatcher, etc
 21  
  *
 22  
  * @since 3.0.0
 23  
  */
 24  
 public class MetaTransportServiceDescriptor extends DefaultTransportServiceDescriptor
 25  
 {
 26  
     private String metaScheme;
 27  
 
 28  
     public MetaTransportServiceDescriptor(String metaScheme, String scheme, Properties props, ClassLoader classLoader) throws ServiceException
 29  
     {
 30  0
         super(metaScheme, props, classLoader);
 31  0
         this.metaScheme = metaScheme;
 32  0
         Properties p = SpiUtils.findServiceDescriptor(ServiceType.TRANSPORT, scheme);
 33  
         //Load any overrides for the for the endpoint scheme
 34  0
         if (p == null)
 35  
         {
 36  0
             throw new ServiceException(CoreMessages.failedToCreate("transport: " + metaScheme + ":" + scheme));
 37  
         }
 38  0
         Properties temp = new Properties();
 39  0
         PropertiesUtils.getPropertiesWithPrefix(props, scheme + ".", temp);
 40  0
         if (temp.size() > 0)
 41  
         {
 42  0
             p.putAll(PropertiesUtils.removeNamespaces(temp));
 43  
         }
 44  0
         setOverrides(p);
 45  0
     }
 46  
 
 47  
     /**
 48  
      * Override the connector cration and register our Meta scheme with the connecotr so that the connector can
 49  
      * be used when creating endpoints using this meta transport
 50  
      *
 51  
      * @return a transport connector matching the scheme of the descriptor with the meta scheme registered with the
 52  
      *         connector
 53  
      * @throws TransportServiceException if the connector cannot be created
 54  
      */
 55  
     @Override
 56  
     public Connector createConnector() throws TransportServiceException
 57  
     {
 58  0
         AbstractConnector c = (AbstractConnector) super.createConnector();
 59  0
         c.registerSupportedMetaProtocol(metaScheme);
 60  0
         return c;
 61  
     }
 62  
 }