001: /*
002: * $Id: DynamicURIOutboundEndpoint.java 11311 2008-03-10 20:15:57Z dfeist $
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.MuleEvent;
015: import org.mule.api.MuleMessage;
016: import org.mule.api.endpoint.EndpointURI;
017: import org.mule.api.endpoint.OutboundEndpoint;
018: import org.mule.api.routing.filter.Filter;
019: import org.mule.api.security.EndpointSecurityFilter;
020: import org.mule.api.transaction.TransactionConfig;
021: import org.mule.api.transport.ConnectionStrategy;
022: import org.mule.api.transport.Connector;
023: import org.mule.api.transport.DispatchException;
024:
025: import java.util.List;
026: import java.util.Map;
027:
028: /**
029: * Allow's EndpointURI to be set and changed dynamically by wrapping up an immutable
030: * endpoint instance.
031: */
032: public class DynamicURIOutboundEndpoint implements OutboundEndpoint {
033:
034: private static final long serialVersionUID = -2814979100270307813L;
035:
036: private OutboundEndpoint endpoint;
037: private EndpointURI dynamicEndpointURI;
038:
039: public DynamicURIOutboundEndpoint(OutboundEndpoint endpoint) {
040: this .endpoint = endpoint;
041: }
042:
043: public DynamicURIOutboundEndpoint(OutboundEndpoint endpoint,
044: EndpointURI dynamicEndpointURI) {
045: this .endpoint = endpoint;
046: setEndpointURI(dynamicEndpointURI);
047: }
048:
049: public EndpointURI getEndpointURI() {
050: if (dynamicEndpointURI != null) {
051: return dynamicEndpointURI;
052: } else {
053: return endpoint.getEndpointURI();
054: }
055: }
056:
057: public void setEndpointURI(EndpointURI dynamicEndpointURI) {
058: this .dynamicEndpointURI = dynamicEndpointURI;
059: }
060:
061: public void dispatch(MuleEvent event) throws DispatchException {
062: endpoint.dispatch(event);
063: }
064:
065: public ConnectionStrategy getConnectionStrategy() {
066: return endpoint.getConnectionStrategy();
067: }
068:
069: public Connector getConnector() {
070: return endpoint.getConnector();
071: }
072:
073: public String getEncoding() {
074: return endpoint.getEncoding();
075: }
076:
077: public Filter getFilter() {
078: return endpoint.getFilter();
079: }
080:
081: public String getInitialState() {
082: return endpoint.getInitialState();
083: }
084:
085: public MuleContext getMuleContext() {
086: return endpoint.getMuleContext();
087: }
088:
089: public String getName() {
090: return endpoint.getName();
091: }
092:
093: public Map getProperties() {
094: return endpoint.getProperties();
095: }
096:
097: public Object getProperty(Object key) {
098: return endpoint.getProperty(key);
099: }
100:
101: public String getProtocol() {
102: return endpoint.getProtocol();
103: }
104:
105: public int getRemoteSyncTimeout() {
106: return endpoint.getRemoteSyncTimeout();
107: }
108:
109: public List getResponseTransformers() {
110: return endpoint.getResponseTransformers();
111: }
112:
113: public EndpointSecurityFilter getSecurityFilter() {
114: return endpoint.getSecurityFilter();
115: }
116:
117: public TransactionConfig getTransactionConfig() {
118: return endpoint.getTransactionConfig();
119: }
120:
121: public List getTransformers() {
122: return endpoint.getTransformers();
123: }
124:
125: public boolean isDeleteUnacceptedMessages() {
126: return endpoint.isDeleteUnacceptedMessages();
127: }
128:
129: public boolean isReadOnly() {
130: return endpoint.isReadOnly();
131: }
132:
133: public boolean isRemoteSync() {
134: return endpoint.isRemoteSync();
135: }
136:
137: public boolean isSynchronous() {
138: return endpoint.isSynchronous();
139: }
140:
141: public MuleMessage send(MuleEvent event) throws DispatchException {
142: return endpoint.send(event);
143: }
144:
145: public int hashCode() {
146: final int prime = 31;
147: int result = 1;
148: result = prime
149: * result
150: + ((dynamicEndpointURI == null) ? 0
151: : dynamicEndpointURI.hashCode());
152: result = prime * result
153: + ((endpoint == null) ? 0 : endpoint.hashCode());
154: return result;
155: }
156:
157: public boolean equals(Object obj) {
158: if (this == obj)
159: return true;
160: if (obj == null)
161: return false;
162: if (getClass() != obj.getClass())
163: return false;
164: final DynamicURIOutboundEndpoint other = (DynamicURIOutboundEndpoint) obj;
165: if (dynamicEndpointURI == null) {
166: if (other.dynamicEndpointURI != null)
167: return false;
168: } else if (!dynamicEndpointURI.equals(other.dynamicEndpointURI))
169: return false;
170: if (endpoint == null) {
171: if (other.endpoint != null)
172: return false;
173: } else if (!endpoint.equals(other.endpoint))
174: return false;
175: return true;
176: }
177:
178: }
|