Coverage Report - org.mule.endpoint.AbstractMetaEndpointBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractMetaEndpointBuilder
0%
0/29
0%
0/6
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.endpoint;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.endpoint.EndpointException;
 11  
 import org.mule.api.endpoint.EndpointURI;
 12  
 import org.mule.api.endpoint.ImmutableEndpoint;
 13  
 import org.mule.api.transport.Connector;
 14  
 import org.mule.transport.AbstractConnector;
 15  
 import org.mule.util.BeanUtils;
 16  
 
 17  
 import java.util.Map;
 18  
 
 19  
 /**
 20  
  * A base class used for Meta endpoint builders such as RSS or ATOM.  This class overrides the {@link #setProperties(java.util.Map)}
 21  
  * method
 22  
  */
 23  
 public abstract class AbstractMetaEndpointBuilder extends EndpointURIEndpointBuilder
 24  
 {
 25  
     protected AbstractMetaEndpointBuilder()
 26  0
     {
 27  0
     }
 28  
 
 29  
     protected AbstractMetaEndpointBuilder(EndpointURIEndpointBuilder global)
 30  
             throws EndpointException
 31  
     {
 32  0
         super(global);
 33  0
     }
 34  
 
 35  
     protected AbstractMetaEndpointBuilder(URIBuilder builder)
 36  
     {
 37  0
         super(builder);
 38  0
     }
 39  
 
 40  
     protected AbstractMetaEndpointBuilder(String address, MuleContext muleContext)
 41  
     {
 42  0
         super(address, muleContext);
 43  0
     }
 44  
 
 45  
     protected AbstractMetaEndpointBuilder(EndpointURI endpointURI)
 46  
     {
 47  0
         super(endpointURI);
 48  0
     }
 49  
 
 50  
     protected AbstractMetaEndpointBuilder(ImmutableEndpoint source)
 51  
     {
 52  0
         super(source);
 53  0
     }
 54  
 
 55  
     @Override
 56  
     public void setProperties(Map<Object, Object> properties)
 57  
     {
 58  
         //This is required since properties were historically set as a properties map
 59  0
         for (Map.Entry<Object, Object> entry : properties.entrySet())
 60  
         {
 61  
             try
 62  
             {
 63  0
                 BeanUtils.setProperty(this, entry.getKey().toString(), entry.getValue());
 64  
             }
 65  0
             catch (Exception e)
 66  
             {
 67  
                 //ignore
 68  0
             }
 69  
         }
 70  0
         properties.remove("connector");
 71  0
         super.setProperties(properties);
 72  0
     }
 73  
 
 74  
     @Override
 75  
     protected String getScheme()
 76  
     {
 77  0
         return uriBuilder.getEndpoint().getScheme();
 78  
     }
 79  
 
 80  
     public static String getEndpointAddressWithoutMetaScheme(String string)
 81  
     {
 82  0
         int idx = string.indexOf(':');
 83  0
         if (idx != -1)
 84  
         {
 85  0
             string = string.substring(idx+1);
 86  
         }
 87  0
         return string;
 88  
     }
 89  
 
 90  
     @Override
 91  
     protected Connector getConnector() throws EndpointException
 92  
     {
 93  0
         AbstractConnector c = (AbstractConnector) super.getConnector();
 94  0
         EndpointURI endpointURI = uriBuilder.getEndpoint();
 95  0
         if(!c.supportsProtocol(endpointURI.getFullScheme()))
 96  
         {
 97  0
             c.registerSupportedMetaProtocol(endpointURI.getSchemeMetaInfo());
 98  
         }
 99  0
         return c;
 100  
     }
 101  
 }