View Javadoc

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