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