001: /*
002: * $Id: DynamicURIInboundEndpoint.java 11366 2008-03-14 11:48:22Z dirk.olmes $
003: * --------------------------------------------------------------------------------------
004: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
005: *
006: * The software in this package is published under the terms of the CPAL v1.0
007: * license, a copy of which has been included with this distribution in the
008: * LICENSE.txt file.
009: */
010:
011: package org.mule.endpoint;
012:
013: import org.mule.api.MuleContext;
014: import org.mule.api.MuleMessage;
015: import org.mule.api.endpoint.EndpointURI;
016: import org.mule.api.endpoint.InboundEndpoint;
017: import org.mule.api.routing.filter.Filter;
018: import org.mule.api.security.EndpointSecurityFilter;
019: import org.mule.api.transaction.TransactionConfig;
020: import org.mule.api.transport.ConnectionStrategy;
021: import org.mule.api.transport.Connector;
022:
023: import java.util.List;
024: import java.util.Map;
025:
026: /**
027: * Allow's EndpointURI to be set and changed dynamically by wrapping up an immutable endpoint instance.
028: */
029: public class DynamicURIInboundEndpoint implements InboundEndpoint {
030:
031: private static final long serialVersionUID = -2814979100270307813L;
032:
033: private InboundEndpoint endpoint;
034: private EndpointURI dynamicEndpointURI;
035:
036: public DynamicURIInboundEndpoint(InboundEndpoint endpoint) {
037: this .endpoint = endpoint;
038: }
039:
040: public DynamicURIInboundEndpoint(InboundEndpoint endpoint,
041: EndpointURI dynamicEndpointURI) {
042: this .endpoint = endpoint;
043: setEndpointURI(dynamicEndpointURI);
044: }
045:
046: public EndpointURI getEndpointURI() {
047: if (dynamicEndpointURI != null) {
048: return dynamicEndpointURI;
049: } else {
050: return endpoint.getEndpointURI();
051: }
052: }
053:
054: public void setEndpointURI(EndpointURI dynamicEndpointURI) {
055: this .dynamicEndpointURI = dynamicEndpointURI;
056: }
057:
058: public ConnectionStrategy getConnectionStrategy() {
059: return endpoint.getConnectionStrategy();
060: }
061:
062: public Connector getConnector() {
063: return endpoint.getConnector();
064: }
065:
066: public String getEncoding() {
067: return endpoint.getEncoding();
068: }
069:
070: public Filter getFilter() {
071: return endpoint.getFilter();
072: }
073:
074: public String getInitialState() {
075: return endpoint.getInitialState();
076: }
077:
078: public MuleContext getMuleContext() {
079: return endpoint.getMuleContext();
080: }
081:
082: public String getName() {
083: return endpoint.getName();
084: }
085:
086: public Map getProperties() {
087: return endpoint.getProperties();
088: }
089:
090: public Object getProperty(Object key) {
091: return endpoint.getProperty(key);
092: }
093:
094: public String getProtocol() {
095: return endpoint.getProtocol();
096: }
097:
098: public int getRemoteSyncTimeout() {
099: return endpoint.getRemoteSyncTimeout();
100: }
101:
102: public List getResponseTransformers() {
103: return endpoint.getResponseTransformers();
104: }
105:
106: public EndpointSecurityFilter getSecurityFilter() {
107: return endpoint.getSecurityFilter();
108: }
109:
110: public TransactionConfig getTransactionConfig() {
111: return endpoint.getTransactionConfig();
112: }
113:
114: public List getTransformers() {
115: return endpoint.getTransformers();
116: }
117:
118: public boolean isDeleteUnacceptedMessages() {
119: return endpoint.isDeleteUnacceptedMessages();
120: }
121:
122: public boolean isReadOnly() {
123: return endpoint.isReadOnly();
124: }
125:
126: public boolean isRemoteSync() {
127: return endpoint.isRemoteSync();
128: }
129:
130: public boolean isSynchronous() {
131: return endpoint.isSynchronous();
132: }
133:
134: public MuleMessage request(long timeout) throws Exception {
135: return endpoint.request(timeout);
136: }
137:
138: public int hashCode() {
139: final int prime = 31;
140: int result = 1;
141: result = prime
142: * result
143: + ((dynamicEndpointURI == null) ? 0
144: : dynamicEndpointURI.hashCode());
145: result = prime * result
146: + ((endpoint == null) ? 0 : endpoint.hashCode());
147: return result;
148: }
149:
150: public boolean equals(Object obj) {
151: if (this == obj)
152: return true;
153: if (obj == null)
154: return false;
155: if (getClass() != obj.getClass())
156: return false;
157: final DynamicURIInboundEndpoint other = (DynamicURIInboundEndpoint) obj;
158: if (dynamicEndpointURI == null) {
159: if (other.dynamicEndpointURI != null)
160: return false;
161: } else if (!dynamicEndpointURI.equals(other.dynamicEndpointURI))
162: return false;
163: if (endpoint == null) {
164: if (other.endpoint != null)
165: return false;
166: } else if (!endpoint.equals(other.endpoint))
167: return false;
168: return true;
169: }
170:
171: }
|