View Javadoc

1   /*
2    * $Id: ImmutableMuleEndpoint.java 7976 2007-08-21 14:26:13Z 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.impl;
12  
13  import org.mule.MuleException;
14  import org.mule.MuleManager;
15  import org.mule.config.i18n.CoreMessages;
16  import org.mule.impl.endpoint.MuleEndpoint;
17  import org.mule.impl.endpoint.MuleEndpointURI;
18  import org.mule.providers.AbstractConnector;
19  import org.mule.providers.service.TransportFactory;
20  import org.mule.providers.service.TransportFactoryException;
21  import org.mule.umo.UMOEvent;
22  import org.mule.umo.UMOException;
23  import org.mule.umo.UMOFilter;
24  import org.mule.umo.UMOMessage;
25  import org.mule.umo.UMOTransactionConfig;
26  import org.mule.umo.endpoint.UMOEndpoint;
27  import org.mule.umo.endpoint.UMOEndpointURI;
28  import org.mule.umo.endpoint.UMOImmutableEndpoint;
29  import org.mule.umo.lifecycle.InitialisationException;
30  import org.mule.umo.provider.DispatchException;
31  import org.mule.umo.provider.UMOConnector;
32  import org.mule.umo.security.UMOEndpointSecurityFilter;
33  import org.mule.umo.transformer.UMOTransformer;
34  import org.mule.util.ClassUtils;
35  import org.mule.util.MuleObjectHelper;
36  import org.mule.util.ObjectNameHelper;
37  import org.mule.util.StringUtils;
38  
39  import java.net.URI;
40  import java.util.Collections;
41  import java.util.Map;
42  import java.util.regex.Matcher;
43  import java.util.regex.Pattern;
44  
45  import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
46  import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
47  import org.apache.commons.logging.Log;
48  import org.apache.commons.logging.LogFactory;
49  
50  /**
51   * <code>ImmutableMuleEndpoint</code> describes a Provider in the Mule Server. A
52   * endpoint is a grouping of an endpoint, an endpointUri and a transformer.
53   */
54  public class ImmutableMuleEndpoint implements UMOImmutableEndpoint
55  {
56      /**
57       * Serial version
58       */
59      private static final long serialVersionUID = -2431378111247771909L;
60  
61      /**
62       * logger used by this class
63       */
64      protected static final Log logger = LogFactory.getLog(ImmutableMuleEndpoint.class);
65  
66      /**
67       * The endpoint used to communicate with the external system
68       */
69      protected UMOConnector connector = null;
70  
71      /**
72       * The endpointUri on which to send or receive information
73       */
74      protected UMOEndpointURI endpointUri = null;
75  
76      /**
77       * The transformer used to transform the incoming or outgoing data
78       */
79      protected UMOTransformer transformer = null;
80  
81      /**
82       * The transformer used to transform the incoming or outgoing data
83       */
84      protected UMOTransformer responseTransformer = null;
85  
86      /**
87       * The name for the endpoint
88       */
89      protected String name = null;
90  
91      /**
92       * Determines whether the endpoint is a receiver or sender or both
93       */
94      protected String type = ENDPOINT_TYPE_SENDER_AND_RECEIVER;
95  
96      /**
97       * Any additional properties for the endpoint
98       */
99      protected Map properties = null;
100 
101     /**
102      * The transaction configuration for this endpoint
103      */
104     protected UMOTransactionConfig transactionConfig = null;
105 
106     /**
107      * event filter for this endpoint
108      */
109     protected UMOFilter filter = null;
110 
111     /**
112      * determines whether unaccepted filtered events should be removed from the
113      * source. If they are not removed its up to the Message receiver to handle
114      * recieving the same message again
115      */
116     protected boolean deleteUnacceptedMessages = false;
117 
118     /**
119      * has this endpoint been initialised
120      */
121     protected AtomicBoolean initialised = new AtomicBoolean(false);
122 
123     /**
124      * The security filter to apply to this endpoint
125      */
126     protected UMOEndpointSecurityFilter securityFilter = null;
127 
128     /**
129      * whether events received by this endpoint should execute in a single thread
130      */
131     protected Boolean synchronous = null;
132 
133     /**
134      * Determines whether a synchronous call should block to obtain a response from a
135      * remote server (if the transport supports it). For example for Jms endpoints,
136      * setting remote sync will cause a temporary destination to be set up as a
137      * replyTo destination and will send the message a wait for a response on the
138      * replyTo destination. If the JMSReplyTo is already set on the message that
139      * destination will be used instead.
140      */
141     protected Boolean remoteSync = null;
142 
143     /**
144      * How long to block when performing a remote synchronisation to a remote host.
145      * This property is optional and will be set to the default Synchonous Event time
146      * out value if not set
147      */
148     protected Integer remoteSyncTimeout = null;
149 
150     /**
151      * Determines whether the endpoint should deal with requests as streams
152      */
153     protected boolean streaming = false;
154 
155     /**
156      * The state that the endpoint is initialised in such as started or stopped
157      */
158     protected String initialState = INITIAL_STATE_STARTED;
159 
160     protected String endpointEncoding = null;
161 
162     /**
163      * determines if a new connector should be created for this endpoint
164      */
165     protected int createConnector = TransportFactory.GET_OR_CREATE_CONNECTOR;
166 
167     /**
168      * Default constructor.
169      */
170     private ImmutableMuleEndpoint()
171     {
172         super();
173     }
174 
175     public ImmutableMuleEndpoint(String name,
176                                  UMOEndpointURI endpointUri,
177                                  UMOConnector connector,
178                                  UMOTransformer transformer,
179                                  String type,
180                                  int createConnector,
181                                  String endpointEncoding,
182                                  Map props)
183     {
184         this.name = name;
185         this.connector = connector;
186         this.createConnector = createConnector;
187         this.endpointEncoding = endpointEncoding;
188         this.type = type;
189 
190         if (endpointUri != null)
191         {
192             this.endpointUri = new MuleEndpointURI(endpointUri);
193         }
194 
195         if (transformer != null)
196         {
197             transformer.setEndpoint(this);
198             this.transformer = transformer;
199         }
200 
201         this.properties = new ConcurrentHashMap();
202 
203         if (props != null)
204         {
205             this.properties.putAll(props);
206         }
207 
208         if (endpointUri != null)
209         {
210             properties.putAll(endpointUri.getParams());
211         }
212 
213         // seal the properties if we are immutable to avoid
214         // write-through aliasing problems with the exposed Map
215         if (!(this instanceof MuleEndpoint))
216         {
217             this.properties = Collections.unmodifiableMap(this.properties);
218         }
219 
220         // Create a default transaction config
221         transactionConfig = new MuleTransactionConfig();
222     }
223 
224     public ImmutableMuleEndpoint(UMOImmutableEndpoint source)
225     {
226         this();
227         this.initFromDescriptor(source);
228     }
229 
230     public ImmutableMuleEndpoint(String endpointName, boolean receiver) throws UMOException
231     {
232         this();
233         String type = (receiver ? UMOEndpoint.ENDPOINT_TYPE_RECEIVER : UMOEndpoint.ENDPOINT_TYPE_SENDER);
234         UMOEndpoint p = getOrCreateEndpointForUri(new MuleEndpointURI(endpointName), type);
235         this.initFromDescriptor(p);
236     }
237 
238     protected void initFromDescriptor(UMOImmutableEndpoint source)
239     {
240         if (this.name == null)
241         {
242             this.name = source.getName();
243         }
244 
245         if (this.endpointUri == null && source.getEndpointURI() != null)
246         {
247             this.endpointUri = new MuleEndpointURI(source.getEndpointURI());
248         }
249 
250         if (this.endpointEncoding == null)
251         {
252             this.endpointEncoding = source.getEncoding();
253         }
254 
255         if (this.connector == null)
256         {
257             this.connector = source.getConnector();
258         }
259 
260         if (this.transformer == null)
261         {
262             this.transformer = source.getTransformer();
263         }
264 
265         if (this.transformer != null)
266         {
267             this.transformer.setEndpoint(this);
268         }
269 
270         if (this.responseTransformer == null)
271         {
272             this.responseTransformer = source.getResponseTransformer();
273         }
274 
275         if (responseTransformer != null)
276         {
277             this.responseTransformer.setEndpoint(this);
278         }
279 
280         this.properties = new ConcurrentHashMap();
281 
282         if (source.getProperties() != null)
283         {
284             this.properties.putAll(source.getProperties());
285         }
286 
287         if (endpointUri != null && endpointUri.getParams() != null)
288         {
289             this.properties.putAll(endpointUri.getParams());
290         }
291 
292         // seal the properties if we are immutable to avoid
293         // write-through aliasing problems with the exposed Map
294         if (!(this instanceof MuleEndpoint))
295         {
296             this.properties = Collections.unmodifiableMap(this.properties);
297         }
298 
299         this.type = source.getType();
300         this.transactionConfig = source.getTransactionConfig();
301         this.deleteUnacceptedMessages = source.isDeleteUnacceptedMessages();
302         this.initialState = source.getInitialState();
303 
304         remoteSyncTimeout = new Integer(source.getRemoteSyncTimeout());
305         remoteSync = Boolean.valueOf(source.isRemoteSync());
306 
307         filter = source.getFilter();
308         securityFilter = source.getSecurityFilter();
309     }
310 
311     /*
312      * (non-Javadoc)
313      *
314      * @see org.mule.umo.endpoint.UMOEndpoint#getEndpointURI()
315      */
316     public UMOEndpointURI getEndpointURI()
317     {
318         return endpointUri;
319     }
320 
321     public String getEncoding()
322     {
323         return endpointEncoding;
324     }
325 
326     /*
327      * (non-Javadoc)
328      *
329      * @see org.mule.umo.endpoint.UMOImmutableEndpoint#getType()
330      */
331     public String getType()
332     {
333         return type;
334     }
335 
336     /*
337      * (non-Javadoc)
338      *
339      * @see org.mule.umo.endpoint.UMOImmutableEndpoint#getConnectorName()
340      */
341     public UMOConnector getConnector()
342     {
343         return connector;
344     }
345 
346     /*
347      * (non-Javadoc)
348      *
349      * @see org.mule.umo.endpoint.UMOImmutableEndpoint#getName()
350      */
351     public String getName()
352     {
353         return name;
354     }
355 
356     /*
357      * (non-Javadoc)
358      *
359      * @see org.mule.umo.endpoint.UMOEndpoint#getTransformer()
360      */
361     public UMOTransformer getTransformer()
362     {
363         return transformer;
364     }
365 
366     /*
367      * (non-Javadoc)
368      *
369      * @see org.mule.umo.endpoint.UMOImmutableEndpoint#getParams()
370      */
371     public Map getProperties()
372     {
373         return properties;
374     }
375 
376     /*
377      * (non-Javadoc)
378      *
379      * @see java.lang.Object#clone()
380      */
381     // TODO this is the 'old' implementation of the clone() method which returns
382     // a MUTABLE endpoint! We need to clarify what endpoint mutability and
383     // cloning actually means
384     public Object clone()
385     {
386         UMOEndpoint clone = new MuleEndpoint(name, endpointUri, connector, transformer, type,
387             createConnector, endpointEncoding, properties);
388 
389         clone.setTransactionConfig(transactionConfig);
390         clone.setFilter(filter);
391         clone.setSecurityFilter(securityFilter);
392 
393         if (remoteSync != null)
394         {
395             clone.setRemoteSync(isRemoteSync());
396         }
397         if (remoteSyncTimeout != null)
398         {
399             clone.setRemoteSyncTimeout(getRemoteSyncTimeout());
400         }
401 
402         if (synchronous != null)
403         {
404             clone.setSynchronous(synchronous.booleanValue());
405         }
406 
407         clone.setDeleteUnacceptedMessages(deleteUnacceptedMessages);
408 
409         clone.setInitialState(initialState);
410         if (initialised.get())
411         {
412             try
413             {
414                 clone.initialise();
415             }
416             catch (InitialisationException e)
417             {
418                 // this really should never happen as the endpoint is already
419                 // initialised
420                 logger.error(e.getMessage(), e);
421             }
422         }
423 
424         return clone;
425     }
426 
427     /*
428      * (non-Javadoc)
429      *
430      * @see org.mule.umo.endpoint.UMOImmutableEndpoint#isReadOnly()
431      */
432     public boolean isReadOnly()
433     {
434         return true;
435     }
436 
437     public String toString()
438     {
439         // Use the interface to retrieve the string and set
440         // the endpoint uri to a default value
441         String sanitizedEndPointUri = null;
442         URI uri = null;
443         if (endpointUri != null)
444         {
445             sanitizedEndPointUri = endpointUri.toString();
446             uri = endpointUri.getUri();
447         }
448         //
449         // The following will further sanitize the endpointuri by removing
450         // the embedded password. This will only remove the password if the
451         // uri contains all the necessary information to successfully rebuild the url
452         if (uri != null && (uri.getRawUserInfo() != null) && (uri.getScheme() != null) 
453             && (uri.getHost() != null) && (uri.getRawPath() != null)) 
454         {
455             // build a pattern up that matches what we need tp strip out the password
456             Pattern sanitizerPattern = Pattern.compile("(.*):.*");
457             Matcher sanitizerMatcher = sanitizerPattern.matcher(uri.getRawUserInfo());
458             if (sanitizerMatcher.matches()) 
459             {
460                sanitizedEndPointUri = new StringBuffer(uri.getScheme())
461                    .append("://").append(sanitizerMatcher.group(1))
462                    .append(":<password>").append("@")
463                    .append(uri.getHost()).append(uri.getRawPath()).toString();
464             }
465             if ( uri.getRawQuery() != null)
466             {
467                sanitizedEndPointUri = sanitizedEndPointUri + "?" + uri.getRawQuery();
468             }
469 
470         }
471 
472         return ClassUtils.getClassName(this.getClass()) + "{endpointUri=" + sanitizedEndPointUri
473                + ", connector=" + connector +  ", transformer=" + transformer + ", name='" + name + "'" 
474                + ", type='" + type + "'" + ", properties=" + properties + ", transactionConfig=" 
475                + transactionConfig + ", filter=" + filter + ", deleteUnacceptedMessages=" 
476                + deleteUnacceptedMessages + ", initialised=" + initialised + ", securityFilter=" 
477                + securityFilter + ", synchronous=" + synchronous + ", initialState=" + initialState 
478                + ", createConnector=" + createConnector + ", remoteSync=" + remoteSync 
479                + ", remoteSyncTimeout=" + remoteSyncTimeout + ", endpointEncoding=" + endpointEncoding + "}";
480     }
481 
482     /*
483      * (non-Javadoc)
484      *
485      * @see org.mule.umo.endpoint.UMOImmutableEndpoint#getProtocol()
486      */
487     public String getProtocol()
488     {
489         return connector.getProtocol();
490     }
491 
492     /*
493      * (non-Javadoc)
494      *
495      * @see org.mule.umo.endpoint.UMOImmutableEndpoint#canReceive()
496      */
497     public boolean canReceive()
498     {
499         return (getType().equals(ENDPOINT_TYPE_RECEIVER) || getType().equals(
500             ENDPOINT_TYPE_SENDER_AND_RECEIVER));
501     }
502 
503     /*
504      * (non-Javadoc)
505      *
506      * @see org.mule.umo.endpoint.UMOImmutableEndpoint#canSend()
507      */
508     public boolean canSend()
509     {
510         return (getType().equals(ENDPOINT_TYPE_SENDER) || getType().equals(ENDPOINT_TYPE_SENDER_AND_RECEIVER));
511     }
512 
513     /*
514      * (non-Javadoc)
515      *
516      * @see org.mule.umo.endpoint.UMOEndpoint#getTransactionConfig()
517      */
518     public UMOTransactionConfig getTransactionConfig()
519     {
520         return transactionConfig;
521     }
522 
523     public boolean equals(Object o)
524     {
525         if (this == o)
526         {
527             return true;
528         }
529         if (!(o instanceof ImmutableMuleEndpoint))
530         {
531             return false;
532         }
533 
534         final ImmutableMuleEndpoint immutableMuleProviderDescriptor = (ImmutableMuleEndpoint) o;
535 
536         if (!connector.getName().equals(immutableMuleProviderDescriptor.connector.getName()))
537         {
538             return false;
539         }
540         if (endpointUri != null && immutableMuleProviderDescriptor.endpointUri != null
541                         ? !endpointUri.getAddress().equals(
542                             immutableMuleProviderDescriptor.endpointUri.getAddress())
543                         : immutableMuleProviderDescriptor.endpointUri != null)
544         {
545             return false;
546         }
547         if (!name.equals(immutableMuleProviderDescriptor.name))
548         {
549             return false;
550         }
551         // MULE-1551
552 //        if (transformer != null
553 //                        ? !transformer.equals(immutableMuleProviderDescriptor.transformer)
554 //                        : immutableMuleProviderDescriptor.transformer != null)
555 //        {
556 //            return false;
557 //        }
558         if (!type.equals(immutableMuleProviderDescriptor.type))
559         {
560             return false;
561         }
562 
563         return true;
564     }
565 
566     public int hashCode()
567     {
568         int result = appendHash(0, connector);
569         result = appendHash(result, endpointUri);
570         // MULE-1551
571 //        result = appendHash(result, transformer);
572         result = appendHash(result, name);
573         result = appendHash(result, type);
574 //        if (logger.isDebugEnabled())
575 //        {
576 //            logger.debug("hashCode: " + result);
577 //        }
578         return result;
579     }
580 
581     private int appendHash(int hash, Object component)
582     {
583         int delta = component != null ? component.hashCode() : 0;
584 //        if (logger.isDebugEnabled())
585 //        {
586 //            logger.debug(component + ": " + delta);
587 //        }
588         return 29 * hash + delta;
589     }
590 
591     public UMOFilter getFilter()
592     {
593         return filter;
594     }
595 
596     public static UMOEndpoint createEndpointFromUri(UMOEndpointURI uri, String type) throws UMOException
597     {
598         return TransportFactory.createEndpoint(uri, type);
599     }
600 
601     public static UMOEndpoint getEndpointFromUri(String uri)
602     {
603         UMOEndpoint endpoint = null;
604         if (uri != null)
605         {
606             String endpointString = MuleManager.getInstance().lookupEndpointIdentifier(uri, uri);
607             endpoint = MuleManager.getInstance().lookupEndpoint(endpointString);
608         }
609         return endpoint;
610     }
611 
612     public static UMOEndpoint getEndpointFromUri(UMOEndpointURI uri) throws UMOException
613     {
614         String endpointName = uri.getEndpointName();
615         if (endpointName != null)
616         {
617             String endpointString = MuleManager.getInstance().lookupEndpointIdentifier(endpointName,
618                 endpointName);
619             UMOEndpoint endpoint = MuleManager.getInstance().lookupEndpoint(endpointString);
620             if (endpoint != null)
621             {
622                 if (StringUtils.isNotEmpty(uri.getAddress()))
623                 {
624                     endpoint.setEndpointURI(uri);
625                 }
626             }
627             return endpoint;
628         }
629 
630         return null;
631     }
632 
633     public static UMOEndpoint getOrCreateEndpointForUri(String uriIdentifier, String type)
634         throws UMOException
635     {
636         UMOEndpoint endpoint = getEndpointFromUri(uriIdentifier);
637         if (endpoint == null)
638         {
639             endpoint = createEndpointFromUri(new MuleEndpointURI(uriIdentifier), type);
640         }
641         else
642         {
643             if (endpoint.getType().equals(UMOEndpoint.ENDPOINT_TYPE_SENDER_AND_RECEIVER))
644             {
645                 endpoint.setType(type);
646             }
647             else if (!endpoint.getType().equals(type))
648             {
649                 throw new IllegalArgumentException("Endpoint matching: " + uriIdentifier
650                                                    + " is not of type: " + type + ". It is of type: "
651                                                    + endpoint.getType());
652 
653             }
654         }
655         return endpoint;
656     }
657 
658     public static UMOEndpoint getOrCreateEndpointForUri(UMOEndpointURI uri, String type) throws UMOException
659     {
660         UMOEndpoint endpoint = getEndpointFromUri(uri);
661         if (endpoint == null)
662         {
663             endpoint = createEndpointFromUri(uri, type);
664         }
665         return endpoint;
666     }
667 
668     public boolean isDeleteUnacceptedMessages()
669     {
670         return deleteUnacceptedMessages;
671     }
672 
673     public void initialise() throws InitialisationException
674     {
675         if (initialised.get())
676         {
677             logger.debug("Already initialised: " + toString());
678             return;
679         }
680         if (connector == null)
681         {
682             if (endpointUri.getConnectorName() != null)
683             {
684                 connector = MuleManager.getInstance().lookupConnector(endpointUri.getConnectorName());
685                 if (connector == null)
686                 {
687                     throw new IllegalArgumentException("Connector not found: "
688                                                        + endpointUri.getConnectorName());
689                 }
690             }
691             else
692             {
693                 try
694                 {
695                     connector = TransportFactory.getOrCreateConnectorByProtocol(this);
696                     if (connector == null)
697                     {
698                         throw new InitialisationException(
699                             CoreMessages.connectorWithProtocolNotRegistered(endpointUri.getScheme()), this);
700                     }
701                 }
702                 catch (TransportFactoryException e)
703                 {
704                     throw new InitialisationException(
705                         CoreMessages.failedToCreateConnectorFromUri(endpointUri), e, this);
706                 }
707             }
708 
709             if (endpointUri.getEndpointName() != null && name == null)
710             {
711                 name = endpointUri.getEndpointName();
712             }
713         }
714         name = ObjectNameHelper.getEndpointName(this);
715 
716         String sync = endpointUri.getParams().getProperty("synchronous", null);
717         if (sync != null)
718         {
719             synchronous = Boolean.valueOf(sync);
720         }
721         if (properties != null && endpointUri.getParams() != null)
722         {
723             properties.putAll(endpointUri.getParams());
724         }
725 
726         if (endpointUri.getTransformers() != null)
727         {
728             try
729             {
730                 transformer = MuleObjectHelper.getTransformer(endpointUri.getTransformers(), ",");
731             }
732             catch (MuleException e)
733             {
734                 throw new InitialisationException(e, this);
735             }
736         }
737 
738         if (transformer == null)
739         {
740             if (connector instanceof AbstractConnector)
741             {
742                 if (UMOEndpoint.ENDPOINT_TYPE_SENDER.equals(type))
743                 {
744                     transformer = ((AbstractConnector) connector).getDefaultOutboundTransformer();
745                 }
746                 else if (UMOEndpoint.ENDPOINT_TYPE_SENDER_AND_RECEIVER.equals(type))
747                 {
748                     transformer = ((AbstractConnector) connector).getDefaultOutboundTransformer();
749                     responseTransformer = ((AbstractConnector) connector).getDefaultInboundTransformer();
750                 }
751                 else
752                 {
753                     transformer = ((AbstractConnector) connector).getDefaultInboundTransformer();
754                 }
755             }
756         }
757         if (transformer != null)
758         {
759             transformer.setEndpoint(this);
760         }
761 
762         if (endpointUri.getResponseTransformers() != null)
763         {
764             try
765             {
766                 responseTransformer =
767                         MuleObjectHelper.getTransformer(endpointUri.getResponseTransformers(), ",");
768             }
769             catch (MuleException e)
770             {
771                 throw new InitialisationException(e, this);
772             }
773         }
774         if (responseTransformer == null)
775         {
776             if (connector instanceof AbstractConnector)
777             {
778                 responseTransformer = ((AbstractConnector) connector).getDefaultResponseTransformer();
779             }
780         }
781         if (responseTransformer != null)
782         {
783             responseTransformer.setEndpoint(this);
784         }
785 
786         if (securityFilter != null)
787         {
788             securityFilter.setEndpoint(this);
789             securityFilter.initialise();
790         }
791 
792         // Allow remote sync values to be set as params on the endpoint URI
793         String rs = (String) endpointUri.getParams().remove("remoteSync");
794         if (rs != null)
795         {
796             remoteSync = Boolean.valueOf(rs);
797         }
798 
799         String rsTimeout = (String) endpointUri.getParams().remove("remoteSyncTimeout");
800         if (rsTimeout != null)
801         {
802             remoteSyncTimeout = Integer.valueOf(rsTimeout);
803         }
804 
805         initialised.set(true);
806     }
807 
808     /**
809      * Returns an UMOEndpointSecurityFilter for this endpoint. If one is not set,
810      * there will be no authentication on events sent via this endpoint
811      *
812      * @return UMOEndpointSecurityFilter responsible for authenticating message flow
813      *         via this endpoint.
814      * @see org.mule.umo.security.UMOEndpointSecurityFilter
815      */
816     public UMOEndpointSecurityFilter getSecurityFilter()
817     {
818         return securityFilter;
819     }
820 
821     /**
822      * Determines if requests originating from this endpoint should be synchronous
823      * i.e. execute in a single thread and possibly return an result. This property
824      * is only used when the endpoint is of type 'receiver'
825      *
826      * @return whether requests on this endpoint should execute in a single thread.
827      *         This property is only used when the endpoint is of type 'receiver'
828      */
829     public boolean isSynchronous()
830     {
831         if (synchronous == null)
832         {
833             return MuleManager.getConfiguration().isSynchronous();
834         }
835         return synchronous.booleanValue();
836     }
837 
838     public boolean isSynchronousSet()
839     {
840         return (synchronous != null);
841     }
842 
843     public int getCreateConnector()
844     {
845         return createConnector;
846     }
847 
848     /**
849      * For certain providers that support the notion of a backchannel such as sockets
850      * (outputStream) or Jms (ReplyTo) Mule can automatically wait for a response
851      * from a backchannel when dispatching over these protocols. This is different
852      * for synchronous as synchronous behavior only applies to in
853      *
854      * @return
855      */
856     public boolean isRemoteSync()
857     {
858         if (remoteSync == null)
859         {
860             if (connector == null || connector.isRemoteSyncEnabled())
861             {
862                 remoteSync = Boolean.valueOf(MuleManager.getConfiguration().isRemoteSync());
863             }
864             else
865             {
866                 remoteSync = Boolean.FALSE;
867             }
868         }
869         return remoteSync.booleanValue();
870     }
871 
872     /**
873      * The timeout value for remoteSync invocations
874      *
875      * @return the timeout in milliseconds
876      */
877     public int getRemoteSyncTimeout()
878     {
879         if (remoteSyncTimeout == null)
880         {
881             remoteSyncTimeout = new Integer(MuleManager.getConfiguration().getSynchronousEventTimeout());
882         }
883         return remoteSyncTimeout.intValue();
884     }
885 
886     /**
887      * Sets the state the endpoint will be loaded in. The States are 'stopped' and
888      * 'started' (default)
889      *
890      * @return the endpoint starting state
891      */
892     public String getInitialState()
893     {
894         return initialState;
895     }
896 
897     public UMOTransformer getResponseTransformer()
898     {
899         return responseTransformer;
900     }
901 
902     /**
903      * Determines whether the endpoint should deal with requests as streams
904      *
905      * @return true if the request should be streamed
906      */
907     public boolean isStreaming()
908     {
909         return streaming;
910     }
911 
912     public Object getProperty(Object key)
913     {
914         Object value = properties.get(key);
915         if (value == null)
916         {
917             value = endpointUri.getParams().get(key);
918         }
919         return value;
920     }
921 
922 
923     // TODO the following methods should most likely be lifecycle-enabled
924 
925     public void dispatch(UMOEvent event) throws DispatchException
926     {
927         if (connector != null)
928         {
929             connector.dispatch(this, event);
930         }
931         else
932         {
933             //TODO: Either remove because this should never happen or i18n the message
934             throw new IllegalStateException("The connector on the endpoint: " + toString() + "is null. Please contact dev@mule.codehaus.org");
935         }
936     }
937 
938     public UMOMessage receive(long timeout) throws Exception
939     {
940         if (connector != null)
941         {
942             return connector.receive(this, timeout);
943         }
944         else
945         {
946             //TODO: Either remove because this should never happen or i18n the message
947             throw new IllegalStateException("The connector on the endpoint: " + toString() + "is null. Please contact dev@mule.codehaus.org");
948         }
949     }
950 
951     public UMOMessage send(UMOEvent event) throws DispatchException
952     {
953         if (connector != null)
954         {
955             return connector.send(this, event);
956         }
957         else
958         {
959             //TODO: Either remove because this should never happen or i18n the message
960             throw new IllegalStateException("The connector on the endpoint: " + toString() + "is null. Please contact dev@mule.codehaus.org");
961         }
962     }
963 
964 }