1 /* 2 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com 3 * The software in this package is published under the terms of the CPAL v1.0 4 * license, a copy of which has been included with this distribution in the 5 * LICENSE.txt file. 6 */ 7 package org.mule.api.endpoint; 8 9 import org.mule.MessageExchangePattern; 10 import org.mule.api.MuleContext; 11 import org.mule.api.processor.MessageProcessor; 12 import org.mule.api.retry.RetryPolicyTemplate; 13 import org.mule.api.routing.filter.Filter; 14 import org.mule.api.security.EndpointSecurityFilter; 15 import org.mule.api.transaction.TransactionConfig; 16 import org.mule.api.transformer.Transformer; 17 import org.mule.api.transport.Connector; 18 19 import java.io.Serializable; 20 import java.util.List; 21 import java.util.Map; 22 23 /** 24 * <code>ImmutableEndpoint</code> describes a Message endpoint where data is 25 * sent or received. An Enpoint is an Resource address (EndpointUri), with associated 26 * transformation, transaction and filtering rules. 27 */ 28 public interface ImmutableEndpoint extends Serializable 29 { 30 31 String INITIAL_STATE_STARTED = "started"; 32 String INITIAL_STATE_STOPPED = "stopped"; 33 34 /** 35 * This specifess the communication endpointUri. This will have a different format 36 * depending on the transport protocol being used i.e. 37 * <ul> 38 * <li>smtp -> admin@mycompany.com</li> 39 * <li>jms -> shipping.orders.topic</li> 40 * <li>sms -> +447910010010</li> 41 * </ul> 42 * <p/> if an endpointUri is not specifed it will be assumed that it will be 43 * determined at run-time by the calling application. The endpointUri can be 44 * aliteral endpointUri such as an email address or it can be a logical name for 45 * an endpointUri as long as it is declared in a <i>message-endpointUri</i> 46 * block. When the message-provider is created the endpointUri is first lookup in 47 * the endpointUri registry and if nothing is returned the endpointUri value 48 * itself is used. 49 * 50 * @return the endpointUri on which the endpoint sends or receives data 51 */ 52 EndpointURI getEndpointURI(); 53 54 /** 55 * This returns the address of the endpoint. When this contains a template, it may not be a URI 56 * 57 * @return the address on which the endpoint sends or receives data 58 */ 59 String getAddress(); 60 61 /** 62 * Decides the encoding to be used for events received by this endpoint 63 * 64 * @return the encoding set on the endpoint or null if no codin has been 65 * specified 66 */ 67 String getEncoding(); 68 69 /** 70 * The endpoint that will be used to send the message on. It is important that 71 * the endpointUri and the connection correlate i.e. if your endpointUri is a jms 72 * queue your connection must be a JMS endpoint. 73 * 74 * @return the endpoint associated with the endpoint 75 */ 76 Connector getConnector(); 77 78 /** 79 * The name is the identifier for the endpoint 80 * 81 * @return the endpoint name 82 */ 83 String getName(); 84 85 /** 86 * Transformers are responsible for transforming data when it is received or 87 * sent by the component (depending on whether this endpoint is a receiver or not). A 88 * tranformation for an inbound event can be forced by the user by calling the 89 * inbound event.getTransformedMessage(). A tranformation for an outbound event 90 * is called or when the Service dispatchEvent() or sendEvent() methods are called. 91 * If an endpoint has no transformers an empty list is returned. 92 * 93 * @return the transformers to use when receiving or sending data 94 * @deprecated use getMessageProcessors() instead 95 */ 96 List<Transformer> getTransformers(); 97 98 /** 99 * The transformers used when a response is returned from invoking this endpoint. 100 * If an endpoint has no response transformers an empty list is returned. 101 * 102 * @return the transformer to use when receiving the response data 103 * @deprecated use getResponseMessageProcessors() instead 104 */ 105 List<Transformer> getResponseTransformers(); 106 107 /** 108 * Returns any properties set on this endpoint 109 * 110 * @return a map of properties for this endpoint 111 */ 112 Map getProperties(); 113 114 /** 115 * Retrieves a property set on the endpoint 116 * 117 * @param key the name of the property 118 * @return the property value or null if it does not exist 119 */ 120 Object getProperty(Object key); 121 122 /** 123 * The transport protocol name that the message endpoint communicates over. i.e. 124 * jms, sms, smtp etc. The protocol must match that of the associated endpoint 125 * 126 * @return the protocol name 127 */ 128 String getProtocol(); 129 130 /** 131 * @return true if this endpoint is read-only and none of it's properties can 132 * change. Global endpoints should be read-only so that unexpected 133 * behaviour is avoided. 134 */ 135 boolean isReadOnly(); 136 137 /** 138 * Returns the transaction configuration for this endpoint 139 * 140 * @return the transaction configuration for this endpoint or null if the 141 * endpoint is not transactional 142 */ 143 TransactionConfig getTransactionConfig(); 144 145 /** 146 * The filter to apply to incoming messages. Only applies when the endpoint 147 * endpointUri is a receiver 148 * 149 * @return the Filter to use or null if one is not set 150 */ 151 Filter getFilter(); 152 153 /** 154 * If a filter is configured on this endpoint, this property will determine if 155 * message that are not excepted by the filter are deleted 156 * 157 * @return true if message should be deleted, false otherwise 158 */ 159 boolean isDeleteUnacceptedMessages(); 160 161 /** 162 * Returns an EndpointSecurityFilter for this endpoint. If one is not set, 163 * there will be no authentication on events sent via this endpoint 164 * 165 * @return EndpointSecurityFilter responsible for authenticating message flow 166 * via this endpoint. 167 * @see EndpointSecurityFilter 168 */ 169 @Deprecated 170 EndpointSecurityFilter getSecurityFilter(); 171 172 EndpointMessageProcessorChainFactory getMessageProcessorsFactory(); 173 174 List <MessageProcessor> getMessageProcessors(); 175 176 List <MessageProcessor> getResponseMessageProcessors(); 177 178 MessageExchangePattern getExchangePattern(); 179 180 /** 181 * The timeout value for waiting for a response from a remote invocation or back channel. Mule 182 * will only wait for a response if the endpoint's message exchange pattern requires a 183 * response. 184 * 185 * @return the timeout in milliseconds 186 */ 187 int getResponseTimeout(); 188 189 /** 190 * Sets the state the endpoint will be loaded in. The States are 'stopped' and 191 * 'started' (default) 192 * 193 * @return the endpoint starting state 194 */ 195 String getInitialState(); 196 197 MuleContext getMuleContext(); 198 199 /** 200 * The retry policy on the endpoint configures how retries are handled. The behaviour is slightly different 201 * for inbound and outbound endpoints. 202 * For inbound endpoints the Retry Policy determines how the connection to the underlying transport will be 203 * managed if the connection is lost. 204 * For outbound endpoints, the Retry Policy will attempt to retry dispatching, sending and receiving an event 205 * 206 * @return the Policy factory to use when retrying a connection or dispatching an event 207 */ 208 RetryPolicyTemplate getRetryPolicyTemplate(); 209 210 /** 211 * The name of the endpoint builder used to create this endpoint. May be used to 212 * an endpoints builder for example to recreate endpoints for deserialized events. 213 */ 214 String getEndpointBuilderName(); 215 216 boolean isProtocolSupported(String protocol); 217 218 /** 219 * Return the mime type defined for the endpoint, if any 220 */ 221 String getMimeType(); 222 223 boolean isDisableTransportTransformer(); 224 }