Coverage Report - org.mule.endpoint.DynamicURIOutboundEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
DynamicURIOutboundEndpoint
36%
18/50
33%
8/24
1.667
 
 1  
 /*
 2  
  * $Id: DynamicURIOutboundEndpoint.java 11311 2008-03-10 20:15:57Z dfeist $
 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.endpoint;
 12  
 
 13  
 import org.mule.api.MuleContext;
 14  
 import org.mule.api.MuleEvent;
 15  
 import org.mule.api.MuleMessage;
 16  
 import org.mule.api.endpoint.EndpointURI;
 17  
 import org.mule.api.endpoint.OutboundEndpoint;
 18  
 import org.mule.api.routing.filter.Filter;
 19  
 import org.mule.api.security.EndpointSecurityFilter;
 20  
 import org.mule.api.transaction.TransactionConfig;
 21  
 import org.mule.api.transport.ConnectionStrategy;
 22  
 import org.mule.api.transport.Connector;
 23  
 import org.mule.api.transport.DispatchException;
 24  
 
 25  
 import java.util.List;
 26  
 import java.util.Map;
 27  
 
 28  
 /**
 29  
  * Allow's EndpointURI to be set and changed dynamically by wrapping up an immutable
 30  
  * endpoint instance.
 31  
  */
 32  
 public class DynamicURIOutboundEndpoint implements OutboundEndpoint
 33  
 {
 34  
 
 35  
     private static final long serialVersionUID = -2814979100270307813L;
 36  
 
 37  
     private OutboundEndpoint endpoint;
 38  
     private EndpointURI dynamicEndpointURI;
 39  
 
 40  
     public DynamicURIOutboundEndpoint(OutboundEndpoint endpoint)
 41  0
     {
 42  0
         this.endpoint = endpoint;
 43  0
     }
 44  
 
 45  
     public DynamicURIOutboundEndpoint(OutboundEndpoint endpoint, EndpointURI dynamicEndpointURI)
 46  16
     {
 47  16
         this.endpoint = endpoint;
 48  16
         setEndpointURI(dynamicEndpointURI);
 49  16
     }
 50  
 
 51  
     public EndpointURI getEndpointURI()
 52  
     {
 53  4
         if (dynamicEndpointURI != null)
 54  
         {
 55  4
             return dynamicEndpointURI;
 56  
         }
 57  
         else
 58  
         {
 59  0
             return endpoint.getEndpointURI();
 60  
         }
 61  
     }
 62  
 
 63  
     public void setEndpointURI(EndpointURI dynamicEndpointURI)
 64  
     {
 65  16
         this.dynamicEndpointURI = dynamicEndpointURI;
 66  16
     }
 67  
 
 68  
     public void dispatch(MuleEvent event) throws DispatchException
 69  
     {
 70  0
         endpoint.dispatch(event);
 71  0
     }
 72  
 
 73  
     public ConnectionStrategy getConnectionStrategy()
 74  
     {
 75  0
         return endpoint.getConnectionStrategy();
 76  
     }
 77  
 
 78  
     public Connector getConnector()
 79  
     {
 80  0
         return endpoint.getConnector();
 81  
     }
 82  
 
 83  
     public String getEncoding()
 84  
     {
 85  0
         return endpoint.getEncoding();
 86  
     }
 87  
 
 88  
     public Filter getFilter()
 89  
     {
 90  0
         return endpoint.getFilter();
 91  
     }
 92  
 
 93  
     public String getInitialState()
 94  
     {
 95  0
         return endpoint.getInitialState();
 96  
     }
 97  
 
 98  
     public MuleContext getMuleContext()
 99  
     {
 100  0
         return endpoint.getMuleContext();
 101  
     }
 102  
 
 103  
     public String getName()
 104  
     {
 105  0
         return endpoint.getName();
 106  
     }
 107  
 
 108  
     public Map getProperties()
 109  
     {
 110  0
         return endpoint.getProperties();
 111  
     }
 112  
 
 113  
     public Object getProperty(Object key)
 114  
     {
 115  0
         return endpoint.getProperty(key);
 116  
     }
 117  
 
 118  
     public String getProtocol()
 119  
     {
 120  0
         return endpoint.getProtocol();
 121  
     }
 122  
 
 123  
     public int getRemoteSyncTimeout()
 124  
     {
 125  0
         return endpoint.getRemoteSyncTimeout();
 126  
     }
 127  
 
 128  
     public List getResponseTransformers()
 129  
     {
 130  0
         return endpoint.getResponseTransformers();
 131  
     }
 132  
 
 133  
     public EndpointSecurityFilter getSecurityFilter()
 134  
     {
 135  0
         return endpoint.getSecurityFilter();
 136  
     }
 137  
 
 138  
     public TransactionConfig getTransactionConfig()
 139  
     {
 140  6
         return endpoint.getTransactionConfig();
 141  
     }
 142  
 
 143  
     public List getTransformers()
 144  
     {
 145  0
         return endpoint.getTransformers();
 146  
     }
 147  
 
 148  
     public boolean isDeleteUnacceptedMessages()
 149  
     {
 150  0
         return endpoint.isDeleteUnacceptedMessages();
 151  
     }
 152  
 
 153  
     public boolean isReadOnly()
 154  
     {
 155  0
         return endpoint.isReadOnly();
 156  
     }
 157  
 
 158  
     public boolean isRemoteSync()
 159  
     {
 160  0
         return endpoint.isRemoteSync();
 161  
     }
 162  
 
 163  
     public boolean isSynchronous()
 164  
     {
 165  0
         return endpoint.isSynchronous();
 166  
     }
 167  
 
 168  
     public MuleMessage send(MuleEvent event) throws DispatchException
 169  
     {
 170  0
         return endpoint.send(event);
 171  
     }
 172  
 
 173  
     public int hashCode()
 174  
     {
 175  0
         final int prime = 31;
 176  0
         int result = 1;
 177  0
         result = prime * result + ((dynamicEndpointURI == null) ? 0 : dynamicEndpointURI.hashCode());
 178  0
         result = prime * result + ((endpoint == null) ? 0 : endpoint.hashCode());
 179  0
         return result;
 180  
     }
 181  
 
 182  
     public boolean equals(Object obj)
 183  
     {
 184  6
         if (this == obj) return true;
 185  6
         if (obj == null) return false;
 186  6
         if (getClass() != obj.getClass()) return false;
 187  6
         final DynamicURIOutboundEndpoint other = (DynamicURIOutboundEndpoint) obj;
 188  6
         if (dynamicEndpointURI == null)
 189  
         {
 190  0
             if (other.dynamicEndpointURI != null) return false;
 191  
         }
 192  6
         else if (!dynamicEndpointURI.equals(other.dynamicEndpointURI)) return false;
 193  6
         if (endpoint == null)
 194  
         {
 195  0
             if (other.endpoint != null) return false;
 196  
         }
 197  6
         else if (!endpoint.equals(other.endpoint)) return false;
 198  6
         return true;
 199  
     }
 200  
 
 201  
 }