1 10 11 package org.mule.impl.endpoint; 12 13 import org.mule.config.i18n.Message; 14 import org.mule.config.i18n.Messages; 15 import org.mule.impl.ImmutableMuleEndpoint; 16 import org.mule.providers.service.ConnectorFactory; 17 import org.mule.umo.UMOException; 18 import org.mule.umo.UMOFilter; 19 import org.mule.umo.UMOTransactionConfig; 20 import org.mule.umo.endpoint.EndpointException; 21 import org.mule.umo.endpoint.UMOEndpoint; 22 import org.mule.umo.endpoint.UMOEndpointURI; 23 import org.mule.umo.endpoint.UMOImmutableEndpoint; 24 import org.mule.umo.lifecycle.InitialisationException; 25 import org.mule.umo.provider.UMOConnector; 26 import org.mule.umo.security.UMOEndpointSecurityFilter; 27 import org.mule.umo.transformer.UMOTransformer; 28 29 import java.util.Map ; 30 31 38 public class MuleEndpoint extends ImmutableMuleEndpoint implements UMOEndpoint 39 { 40 43 private static final long serialVersionUID = 2028442057178326047L; 44 45 public static final String ALWAYS_CREATE_STRING = "ALWAYS_CREATE"; 46 public static final String NEVER_CREATE_STRING = "NEVER_CREATE"; 47 48 52 public MuleEndpoint() 53 { 54 super(null, null, null, null, ENDPOINT_TYPE_SENDER_AND_RECEIVER, 0, null, null); 55 } 56 57 public MuleEndpoint(String name, 58 UMOEndpointURI endpointUri, 59 UMOConnector connector, 60 UMOTransformer transformer, 61 String type, 62 int createConnector, 63 String endpointEncoding, 64 Map props) 65 { 66 super(name, endpointUri, connector, transformer, type, createConnector, endpointEncoding, props); 67 } 68 69 public MuleEndpoint(UMOImmutableEndpoint endpoint) 70 { 71 super(endpoint); 72 } 73 74 public MuleEndpoint(String uri, boolean receiver) throws UMOException 75 { 76 super(uri, receiver); 77 } 78 79 public Object clone() 80 { 81 UMOEndpoint clone = new MuleEndpoint(name, endpointUri, connector, transformer, type, 82 createConnector, endpointEncoding, properties); 83 84 clone.setTransactionConfig(transactionConfig); 85 clone.setFilter(filter); 86 clone.setSecurityFilter(securityFilter); 87 88 if (remoteSync != null) 89 { 90 clone.setRemoteSync(isRemoteSync()); 91 } 92 if (remoteSyncTimeout != null) 93 { 94 clone.setRemoteSyncTimeout(getRemoteSyncTimeout()); 95 } 96 97 if (synchronous != null) 98 { 99 clone.setSynchronous(synchronous.booleanValue()); 100 } 101 102 clone.setDeleteUnacceptedMessages(deleteUnacceptedMessages); 103 104 clone.setInitialState(initialState); 105 if (initialised.get()) 106 { 107 try 108 { 109 clone.initialise(); 110 } 111 catch (InitialisationException e) 112 { 113 logger.error(e.getMessage(), e); 116 } 117 } 118 119 return clone; 120 } 121 122 127 public void setEndpointURI(UMOEndpointURI endpointUri) throws EndpointException 128 { 129 if (connector != null && endpointUri != null 130 && !connector.supportsProtocol(endpointUri.getFullScheme())) 131 { 132 throw new IllegalArgumentException (new Message( 133 Messages.CONNECTOR_SCHEME_X_INCOMPATIBLE_WITH_ENDPOINT_SCHEME_X, connector.getProtocol(), 134 endpointUri).getMessage()); 135 } 136 this.endpointUri = endpointUri; 137 if (endpointUri != null) 138 { 139 properties.putAll(endpointUri.getParams()); 140 } 141 } 142 143 public void setEncoding(String endpointEncoding) 144 { 145 this.endpointEncoding = endpointEncoding; 146 } 147 148 153 public void setType(String type) 154 { 155 this.type = type; 156 } 157 158 163 public void setConnector(UMOConnector connector) 164 { 165 if (connector != null && endpointUri != null 166 && !connector.supportsProtocol(endpointUri.getFullScheme())) 167 { 168 throw new IllegalArgumentException (new Message( 169 Messages.CONNECTOR_SCHEME_X_INCOMPATIBLE_WITH_ENDPOINT_SCHEME_X, connector.getProtocol(), 170 endpointUri).getMessage()); 171 } 172 this.connector = connector; 173 } 174 175 180 public void setName(String name) 181 { 182 this.name = name; 183 } 184 185 190 public void setTransformer(UMOTransformer trans) 191 { 192 transformer = trans; 193 if (transformer != null) 194 { 195 transformer.setEndpoint(this); 196 } 197 } 198 199 204 public void setProperties(Map props) 205 { 206 properties.clear(); 207 properties.putAll(props); 208 } 209 210 215 public boolean isReadOnly() 216 { 217 return false; 218 } 219 220 225 public void setTransactionConfig(UMOTransactionConfig config) 226 { 227 transactionConfig = config; 228 } 229 230 public void setFilter(UMOFilter filter) 231 { 232 this.filter = filter; 233 } 234 235 241 public void setDeleteUnacceptedMessages(boolean delete) 242 { 243 deleteUnacceptedMessages = delete; 244 } 245 246 254 public void setSecurityFilter(UMOEndpointSecurityFilter filter) 255 { 256 securityFilter = filter; 257 if (securityFilter != null) 258 { 259 securityFilter.setEndpoint(this); 260 } 261 } 262 263 272 public void setSynchronous(boolean synchronous) 273 { 274 this.synchronous = Boolean.valueOf(synchronous); 275 } 276 277 public void setCreateConnector(int action) 278 { 279 createConnector = action; 280 } 281 282 public void setCreateConnectorAsString(String action) 283 { 284 if (ALWAYS_CREATE_STRING.equals(action)) 285 { 286 createConnector = ConnectorFactory.ALWAYS_CREATE_CONNECTOR; 287 } 288 else if (NEVER_CREATE_STRING.equals(action)) 289 { 290 createConnector = ConnectorFactory.NEVER_CREATE_CONNECTOR; 291 } 292 else 293 { 294 createConnector = ConnectorFactory.GET_OR_CREATE_CONNECTOR; 295 } 296 } 297 298 306 public void setRemoteSync(boolean value) 307 { 308 this.remoteSync = Boolean.valueOf(value); 309 if (value) 310 { 311 this.synchronous = Boolean.TRUE; 312 } 313 } 314 315 320 public void setRemoteSyncTimeout(int timeout) 321 { 322 this.remoteSyncTimeout = new Integer (timeout); 323 } 324 325 331 public void setInitialState(String state) 332 { 333 this.initialState = state; 334 } 335 336 public void setResponseTransformer(UMOTransformer trans) 337 { 338 responseTransformer = trans; 339 } 340 341 346 public void setStreaming(boolean stream) 347 { 348 this.streaming = stream; 349 } 350 351 357 public void setProperty(String key, Object value) 358 { 359 properties.put(key, value); 360 } 361 } 362 | Popular Tags |