KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > MuleEvent


1 /*
2  * $Id: MuleEvent.java 4259 2006-12-14 03:12:07Z aperepel $
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 MuleSource MPL
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.apache.commons.beanutils.PropertyUtils;
14 import org.apache.commons.collections.MapUtils;
15 import org.apache.commons.lang.SerializationUtils;
16 import org.apache.commons.logging.Log;
17 import org.apache.commons.logging.LogFactory;
18 import org.mule.MuleException;
19 import org.mule.MuleManager;
20 import org.mule.config.i18n.Message;
21 import org.mule.config.i18n.Messages;
22 import org.mule.config.MuleProperties;
23 import org.mule.impl.endpoint.MuleEndpoint;
24 import org.mule.impl.security.MuleCredentials;
25 import org.mule.umo.UMOComponent;
26 import org.mule.umo.UMOEvent;
27 import org.mule.umo.UMOException;
28 import org.mule.umo.UMOMessage;
29 import org.mule.umo.UMOSession;
30 import org.mule.umo.endpoint.UMOEndpoint;
31 import org.mule.umo.endpoint.UMOImmutableEndpoint;
32 import org.mule.umo.security.UMOCredentials;
33 import org.mule.umo.transformer.TransformerException;
34 import org.mule.umo.transformer.UMOTransformer;
35 import org.mule.util.UUID;
36
37 import java.io.IOException JavaDoc;
38 import java.io.ObjectInputStream JavaDoc;
39 import java.io.ObjectOutputStream JavaDoc;
40 import java.io.OutputStream JavaDoc;
41 import java.io.Serializable JavaDoc;
42 import java.io.UnsupportedEncodingException JavaDoc;
43 import java.util.EventObject JavaDoc;
44 import java.util.Iterator JavaDoc;
45
46 /**
47  * <code>MuleEvent</code> represents any data event occuring in the Mule
48  * environment. All data sent or received within the Mule environment will be passed
49  * between components as an UMOEvent. <p/> The UMOEvent holds some data and provides
50  * helper methods for obtaining the data in a format that the receiving Mule UMO
51  * understands. The event can also maintain any number of properties that can be set
52  * and retrieved by Mule UMO components.
53  */

54
55 public class MuleEvent extends EventObject JavaDoc implements UMOEvent
56 {
57     /**
58      * Serial version
59      */

60     private static final long serialVersionUID = 7568207722883309919L;
61     /**
62      * logger used by this class
63      */

64     protected transient Log logger = LogFactory.getLog(getClass());
65     /**
66      * The endpoint associated with the event
67      */

68     private transient UMOImmutableEndpoint endpoint = null;
69
70     /**
71      * the Universally Unique ID for the event
72      */

73     private String JavaDoc id = null;
74
75     /**
76      * The payload message used to read the payload of the event
77      */

78     private UMOMessage message = null;
79
80     private transient UMOSession session;
81
82     private boolean stopFurtherProcessing = false;
83
84     private boolean synchronous = false;
85
86     private int timeout = TIMEOUT_NOT_SET_VALUE;
87
88     private transient ResponseOutputStream outputStream = null;
89
90     private transient Object JavaDoc transformedMessage = null;
91
92     private UMOCredentials credentials = null;
93
94     protected String JavaDoc[] ignoredPropertyOverrides = new String JavaDoc[]{MuleProperties.MULE_METHOD_PROPERTY};
95
96     /**
97      * Properties cache that only reads properties once from the inbound message and
98      * merges them with any properties on the endpoint. The message properties take
99      * precedence over the endpoint properties
100      */

101     public MuleEvent(UMOMessage message,
102                      UMOImmutableEndpoint endpoint,
103                      UMOComponent component,
104                      UMOEvent previousEvent)
105     {
106         super(message.getPayload());
107         this.message = message;
108         this.id = generateEventId();
109         this.session = previousEvent.getSession();
110         ((MuleSession)session).setComponent(component);
111         this.endpoint = endpoint;
112         this.synchronous = previousEvent.isSynchronous();
113         this.timeout = previousEvent.getTimeout();
114         this.outputStream = (ResponseOutputStream)previousEvent.getOutputStream();
115         fillProperties(previousEvent);
116     }
117
118     public MuleEvent(UMOMessage message,
119                      UMOImmutableEndpoint endpoint,
120                      UMOSession session,
121                      boolean synchronous)
122     {
123         this(message, endpoint, session, synchronous, null);
124     }
125
126     /**
127      * Contructor.
128      *
129      * @param message the event payload
130      * @param endpoint the endpoint to associate with the event
131      * @param session the previous event if any
132      * @see org.mule.umo.provider.UMOMessageAdapter
133      */

134     public MuleEvent(UMOMessage message,
135                      UMOImmutableEndpoint endpoint,
136                      UMOSession session,
137                      boolean synchronous,
138                      ResponseOutputStream outputStream)
139     {
140         super(message.getPayload());
141         this.message = message;
142         this.endpoint = endpoint;
143         this.session = session;
144         this.id = generateEventId();
145         this.synchronous = synchronous;
146         this.outputStream = outputStream;
147         fillProperties(null);
148     }
149
150     /**
151      * Contructor.
152      *
153      * @param message the event payload
154      * @param endpoint the endpoint to associate with the event
155      * @param session the previous event if any
156      * @see org.mule.umo.provider.UMOMessageAdapter
157      */

158     public MuleEvent(UMOMessage message,
159                      UMOImmutableEndpoint endpoint,
160                      UMOSession session,
161                      String JavaDoc eventId,
162                      boolean synchronous)
163     {
164         super(message.getPayload());
165         this.message = message;
166         this.endpoint = endpoint;
167         this.session = session;
168         this.id = eventId;
169         this.synchronous = synchronous;
170         fillProperties(null);
171     }
172
173     /**
174      * A helper constructor used to rewrite an event payload
175      *
176      * @param message
177      * @param rewriteEvent
178      */

179     public MuleEvent(UMOMessage message, UMOEvent rewriteEvent)
180     {
181         super(message.getPayload());
182         this.message = message;
183         this.id = rewriteEvent.getId();
184         this.session = rewriteEvent.getSession();
185         ((MuleSession)session).setComponent(rewriteEvent.getComponent());
186         this.endpoint = rewriteEvent.getEndpoint();
187         this.synchronous = rewriteEvent.isSynchronous();
188         this.timeout = rewriteEvent.getTimeout();
189         this.outputStream = (ResponseOutputStream)rewriteEvent.getOutputStream();
190         if (rewriteEvent instanceof MuleEvent)
191         {
192             this.transformedMessage = ((MuleEvent)rewriteEvent).getCachedMessage();
193         }
194         fillProperties(rewriteEvent);
195     }
196
197     protected void fillProperties(UMOEvent previousEvent)
198     {
199         if (previousEvent != null)
200         {
201             UMOMessage msg = previousEvent.getMessage();
202             synchronized (msg)
203             {
204                 for (Iterator JavaDoc iterator = msg.getPropertyNames().iterator(); iterator.hasNext();)
205                 {
206                     String JavaDoc prop = (String JavaDoc)iterator.next();
207                     Object JavaDoc value = msg.getProperty(prop);
208                     // don't overwrite property on the message
209
if (!ignoreProperty(prop))
210                     {
211                         message.setProperty(prop, value);
212                     }
213
214                     if (logger.isDebugEnabled())
215                     {
216                         Object JavaDoc currentValue = message.getProperty(prop);
217                         if (!value.equals(currentValue))
218                         {
219                             logger.warn("Property on the current message " + prop + "=" + currentValue
220                                         + " overrides property on the previous event: " + prop + "=" + value);
221                         }
222                     }
223                 }
224             }
225         }
226
227         if (endpoint != null && endpoint.getProperties() != null)
228         {
229             for (Iterator JavaDoc iterator = endpoint.getProperties().keySet().iterator(); iterator.hasNext();)
230             {
231                 String JavaDoc prop = (String JavaDoc)iterator.next();
232                 Object JavaDoc value = endpoint.getProperties().get(prop);
233                 // don't overwrite property on the message
234
if (!ignoreProperty(prop))
235                 {
236                     message.setProperty(prop, value);
237                 }
238
239                 if (logger.isDebugEnabled())
240                 {
241                     Object JavaDoc currentValue = message.getProperty(prop);
242                     if (!value.equals(currentValue))
243                     {
244                         logger.warn("Property on the current message " + prop + "=" + currentValue
245                                     + " overrides property on the endpoint: " + prop + "=" + value);
246                     }
247                 }
248             }
249         }
250
251         setCredentials();
252     }
253
254     /**
255      * This method is used to determine if a property on the previous event should be
256      * ignorred for the next event. This method is here because we don't have proper
257      * scoped handlng of meta data yet The rules are - 1. If a property is already
258      * set on the currect event don't verwrite with the previous event value 2. If
259      * the propery name appears in the ignorredPropertyOverrides list, then we always
260      * set it on the new event
261      *
262      * @param key
263      * @return
264      */

265     protected boolean ignoreProperty(String JavaDoc key)
266     {
267         if (key == null)
268         {
269             return true;
270         }
271
272         for (int i = 0; i < ignoredPropertyOverrides.length; i++)
273         {
274             if (key.equals(ignoredPropertyOverrides[i]))
275             {
276                 return false;
277             }
278         }
279         Object JavaDoc value = message.getProperty(key);
280
281         if (value != null)
282         {
283             return true;
284         }
285
286         return false;
287     }
288
289     protected void setCredentials()
290     {
291         if (endpoint.getEndpointURI().getUserInfo() != null)
292         {
293             final String JavaDoc userName = endpoint.getEndpointURI().getUsername();
294             final String JavaDoc password = endpoint.getEndpointURI().getPassword();
295             if (password != null && userName != null)
296             {
297                 credentials = new MuleCredentials(userName, password.toCharArray());
298             }
299         }
300     }
301
302     public UMOCredentials getCredentials()
303     {
304         return credentials;
305     }
306
307     Object JavaDoc getCachedMessage()
308     {
309         return transformedMessage;
310     }
311
312     /*
313      * (non-Javadoc)
314      *
315      * @see org.mule.umo.UMOEvent#getPayload()
316      */

317     public UMOMessage getMessage()
318     {
319         return message;
320     }
321
322     /*
323      * (non-Javadoc)
324      *
325      * @see org.mule.umo.UMOEvent#getPayloadAsBytes()
326      */

327     public byte[] getMessageAsBytes() throws MuleException
328     {
329         try
330         {
331             return message.getPayloadAsBytes();
332         }
333         catch (Exception JavaDoc e)
334         {
335             throw new MuleException(new Message(Messages.CANT_READ_PAYLOAD_AS_BYTES_TYPE_IS_X,
336                 message.getPayload().getClass().getName()), e);
337         }
338     }
339
340     /*
341      * (non-Javadoc)
342      *
343      * @see org.mule.umo.UMOEvent#getTransformedMessage()
344      */

345     public Object JavaDoc getTransformedMessage() throws TransformerException
346     {
347         if (isStreaming())
348         {
349             return message.getAdapter();
350         }
351         if (transformedMessage == null)
352         {
353             UMOTransformer tran = endpoint.getTransformer();
354             if (tran != null)
355             {
356                 transformedMessage = tran.transform(message.getPayload());
357             }
358             else
359             {
360                 transformedMessage = message.getPayload();
361             }
362         }
363         return transformedMessage;
364     }
365
366     /**
367      * This method will attempt to convert the transformed message into an array of
368      * bytes It will first check if the result of the transformation is a byte array
369      * and return that. Otherwise if the the result is a string it will serialized
370      * the CONTENTS of the string not the String object. finally it will check if the
371      * result is a Serializable object and convert that to an array of bytes.
372      *
373      * @return a byte[] representation of the message
374      * @throws TransformerException if an unsupported encoding is being used or if
375      * the result message is not a String byte[] or Seializable object
376      */

377     public byte[] getTransformedMessageAsBytes() throws TransformerException
378     {
379         Object JavaDoc msg = getTransformedMessage();
380         if (msg instanceof byte[])
381         {
382             return (byte[])msg;
383         }
384         else if (msg instanceof String JavaDoc)
385         {
386             try
387             {
388                 return msg.toString().getBytes(getEncoding());
389             }
390             catch (UnsupportedEncodingException JavaDoc e)
391             {
392                 throw new TransformerException(new Message(Messages.TRANSFORM_FAILED_FROM_X, msg.getClass()
393                     .getName(), e));
394             }
395         }
396         else if (msg instanceof Serializable JavaDoc)
397         {
398             try
399             {
400                 return SerializationUtils.serialize((Serializable JavaDoc)msg);
401             }
402             catch (Exception JavaDoc e)
403             {
404                 throw new TransformerException(new Message(Messages.TRANSFORM_FAILED_FROM_X_TO_X,
405                     msg.getClass().getName(), "byte[]"), e);
406             }
407         }
408         else
409         {
410             throw new TransformerException(new Message(Messages.TRANSFORM_ON_X_NOT_OF_SPECIFIED_TYPE_X,
411                 msg.getClass().getName(), "byte[] or " + Serializable JavaDoc.class.getName()));
412         }
413     }
414
415     /**
416      * Returns the message transformed into it's recognised or expected format and
417      * then into a String. The transformer used is the one configured on the endpoint
418      * through which this event was received.
419      *
420      * @return the message transformed into it's recognised or expected format as a
421      * Strings.
422      * @throws org.mule.umo.transformer.TransformerException if a failure occurs in
423      * the transformer
424      * @see org.mule.umo.transformer.UMOTransformer
425      */

426     public String JavaDoc getTransformedMessageAsString() throws TransformerException
427     {
428         return getTransformedMessageAsString(getEncoding());
429     }
430
431     /*
432      * (non-Javadoc)
433      *
434      * @see org.mule.umo.UMOEvent#getPayloadAsString()
435      */

436     public String JavaDoc getMessageAsString() throws UMOException
437     {
438         return getMessageAsString(getEncoding());
439     }
440
441     /**
442      * Returns the message transformed into it's recognised or expected format and
443      * then into a String. The transformer used is the one configured on the endpoint
444      * through which this event was received.
445      *
446      * @param encoding the encoding to use when converting the message to string
447      * @return the message transformed into it's recognised or expected format as a
448      * Strings.
449      * @throws org.mule.umo.transformer.TransformerException if a failure occurs in
450      * the transformer
451      * @see org.mule.umo.transformer.UMOTransformer
452      */

453     public String JavaDoc getTransformedMessageAsString(String JavaDoc encoding) throws TransformerException
454     {
455         try
456         {
457             return new String JavaDoc(getTransformedMessageAsBytes(), encoding);
458         }
459         catch (UnsupportedEncodingException JavaDoc e)
460         {
461             throw new TransformerException(endpoint.getTransformer(), e);
462         }
463     }
464
465     /**
466      * Returns the message contents as a string
467      *
468      * @param encoding the encoding to use when converting the message to string
469      * @return the message contents as a string
470      * @throws org.mule.umo.UMOException if the message cannot be converted into a
471      * string
472      */

473     public String JavaDoc getMessageAsString(String JavaDoc encoding) throws UMOException
474     {
475         try
476         {
477             return message.getPayloadAsString(encoding);
478         }
479         catch (Exception JavaDoc e)
480         {
481             throw new MuleException(new Message(Messages.CANT_READ_PAYLOAD_AS_STRING_TYPE_IS_X,
482                 message.getClass().getName()), e);
483         }
484     }
485
486     /*
487      * (non-Javadoc)
488      *
489      * @see org.mule.umo.UMOEvent#getId()
490      */

491     public String JavaDoc getId()
492     {
493         return id;
494     }
495
496     /**
497      * @param name
498      * @return
499      */

500     public Object JavaDoc getProperty(String JavaDoc name)
501     {
502         return message.getProperty(name);
503     }
504
505     /**
506      * @see org.mule.umo.UMOEvent#getProperty(java.lang.String, boolean)
507      */

508     public Object JavaDoc getProperty(String JavaDoc name, boolean exhaustiveSearch)
509     {
510         return getProperty(name, /* defaultValue */null, exhaustiveSearch);
511     }
512
513     /*
514      * (non-Javadoc)
515      *
516      * @see org.mule.umo.UMOEvent#getProperty(java.lang.String, java.lang.Object)
517      * @param name @param defaultValue @return
518      */

519     public Object JavaDoc getProperty(String JavaDoc name, Object JavaDoc defaultValue)
520     {
521         return message.getProperty(name, defaultValue);
522     }
523
524     /*
525      * (non-Javadoc)
526      *
527      * @see org.mule.umo.UMOEvent#getProperty(java.lang.String, java.lang.Object,
528      * boolean)
529      */

530     public Object JavaDoc getProperty(String JavaDoc name, Object JavaDoc defaultValue, boolean exhaustiveSearch)
531     {
532         Object JavaDoc property = getProperty(name);
533
534         if (exhaustiveSearch)
535         {
536             // Search the endpoint
537
if (property == null)
538             {
539                 property = MapUtils.getObject(getEndpoint().getEndpointURI().getParams(), name, null);
540             }
541
542             // Search the connector
543
if (property == null)
544             {
545                 try
546                 {
547                     property = PropertyUtils.getProperty(getEndpoint().getConnector(), name);
548                 }
549                 catch (Exception JavaDoc e)
550                 {
551                     // Ignore this exception, it just means that the connector has no
552
// such property.
553
}
554             }
555         }
556         return (property == null ? defaultValue : property);
557     }
558
559     /*
560      * (non-Javadoc)
561      *
562      * @see org.mule.umo.UMOEvent#setProperty(java.lang.String, java.lang.Object)
563      */

564     public void setProperty(String JavaDoc name, Object JavaDoc value)
565     {
566         message.setProperty(name, value);
567     }
568
569     /*
570      * (non-Javadoc)
571      *
572      * @see org.mule.umo.UMOEvent#getEndpoint()
573      */

574     public UMOImmutableEndpoint getEndpoint()
575     {
576         return endpoint;
577     }
578
579     /*
580      * (non-Javadoc)
581      *
582      * @see java.lang.Object#toString()
583      */

584     public String JavaDoc toString()
585     {
586         StringBuffer JavaDoc buf = new StringBuffer JavaDoc(64);
587         buf.append("Event: ").append(getId());
588         buf.append(", sync=").append(isSynchronous());
589         buf.append(", stop processing=").append(isStopFurtherProcessing());
590         buf.append(", ").append(endpoint);
591
592         return buf.toString();
593     }
594
595     protected String JavaDoc generateEventId()
596     {
597         return UUID.getUUID();
598     }
599
600     public UMOSession getSession()
601     {
602         return session;
603     }
604
605     void setSession(UMOSession session)
606     {
607         this.session = session;
608     }
609
610     /**
611      * Gets the recipient component of this event
612      */

613     public UMOComponent getComponent()
614     {
615         return session.getComponent();
616     }
617
618     /**
619      * Determines whether the default processing for this event will be executed
620      *
621      * @return Returns the stopFurtherProcessing.
622      */

623     public boolean isStopFurtherProcessing()
624     {
625         return stopFurtherProcessing;
626     }
627
628     /**
629      * Setting this parameter will stop the Mule framework from processing this event
630      * in the standard way. This allow for client code to override default behaviour.
631      * The common reasons for doing this are - 1. The UMO has more than one send
632      * endpoint configured; the component must dispatch to other prviders
633      * programatically by using the component on the current event 2. The UMO doesn't
634      * send the current event out through a endpoint. i.e. the processing of the
635      * event stops in the uMO.
636      *
637      * @param stopFurtherProcessing The stopFurtherProcessing to set.
638      */

639     public void setStopFurtherProcessing(boolean stopFurtherProcessing)
640     {
641         this.stopFurtherProcessing = stopFurtherProcessing;
642     }
643
644     public boolean equals(Object JavaDoc o)
645     {
646         if (this == o)
647         {
648             return true;
649         }
650         if (!(o instanceof MuleEvent))
651         {
652             return false;
653         }
654
655         final MuleEvent event = (MuleEvent)o;
656
657         if (message != null ? !message.equals(event.message) : event.message != null)
658         {
659             return false;
660         }
661         return id.equals(event.id);
662     }
663
664     public int hashCode()
665     {
666         return 29 * id.hashCode() + (message != null ? message.hashCode() : 0);
667     }
668
669     public boolean isSynchronous()
670     {
671         return synchronous;
672     }
673
674     public void setSynchronous(boolean value)
675     {
676         synchronous = value;
677     }
678
679     public int getTimeout()
680     {
681         if (timeout == TIMEOUT_NOT_SET_VALUE)
682         {
683             // If this is not set it will use the default timeout value
684
timeout = endpoint.getRemoteSyncTimeout();
685         }
686         return timeout;
687     }
688
689     public void setTimeout(int timeout)
690     {
691         this.timeout = timeout;
692     }
693
694     /**
695      * Gets an int property on the nessage
696      *
697      * @param name
698      */

699     public int getIntProperty(String JavaDoc name, int defaultValue)
700     {
701         return message.getIntProperty(name, defaultValue);
702     }
703
704     /**
705      * Gets a long property on the nessage
706      *
707      * @param name
708      */

709     public long getLongProperty(String JavaDoc name, long defaultValue)
710     {
711         return message.getLongProperty(name, defaultValue);
712     }
713
714     /**
715      * Gets a double property on the nessage
716      *
717      * @param name
718      */

719     public double getDoubleProperty(String JavaDoc name, double defaultValue)
720     {
721         return message.getDoubleProperty(name, defaultValue);
722     }
723
724     /**
725      * Gets a boolean property on the nessage
726      *
727      * @param name
728      */

729     public boolean getBooleanProperty(String JavaDoc name, boolean defaultValue)
730     {
731         return message.getBooleanProperty(name, defaultValue);
732     }
733
734     /**
735      * Sets a boolean property on the nessage
736      *
737      * @param name
738      * @param value
739      */

740     public void setBooleanProperty(String JavaDoc name, boolean value)
741     {
742         message.setBooleanProperty(name, value);
743     }
744
745     /**
746      * Sets an int property on the nessage
747      *
748      * @param name
749      * @param value
750      */

751     public void setIntProperty(String JavaDoc name, int value)
752     {
753         message.setIntProperty(name, value);
754     }
755
756     /**
757      * Sets a long property on the nessage
758      *
759      * @param name
760      * @param value
761      */

762     public void setLongProperty(String JavaDoc name, long value)
763     {
764         message.setLongProperty(name, value);
765     }
766
767     /**
768      * Sets a double property on the nessage
769      *
770      * @param name
771      * @param value
772      */

773     public void setDoubleProperty(String JavaDoc name, double value)
774     {
775         message.setDoubleProperty(name, value);
776     }
777
778     /**
779      * An outputstream the can optionally be used write response data to an incoming
780      * message.
781      *
782      * @return an output strem if one has been made available by the message receiver
783      * that received the message
784      */

785     public OutputStream JavaDoc getOutputStream()
786     {
787         return outputStream;
788     }
789
790     /**
791      * Removes a property from the event
792      *
793      * @param key the property key to remove
794      * @return the removed property or null if the property was not found or if the
795      * underlying message does not return the removed property
796      */

797     public Object JavaDoc removeProperty(String JavaDoc key)
798     {
799         return message.removeProperty(key);
800     }
801
802     private void writeObject(ObjectOutputStream JavaDoc out) throws IOException JavaDoc
803     {
804         out.defaultWriteObject();
805         out.writeObject(endpoint.getEndpointURI().toString());
806     }
807
808     private void readObject(ObjectInputStream JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc
809     {
810         in.defaultReadObject();
811         String JavaDoc uri = (String JavaDoc)in.readObject();
812         try
813         {
814             endpoint = MuleEndpoint.getOrCreateEndpointForUri(uri, UMOEndpoint.ENDPOINT_TYPE_SENDER);
815         }
816         catch (UMOException e)
817         {
818             throw (IOException JavaDoc)new IOException JavaDoc().initCause(e);
819         }
820     }
821
822     /**
823      * Will retrieve a string proerty form the event. If the property does not exist
824      * it will be substituted with the default value
825      *
826      * @param name the name of the proerty to get
827      * @param defaultValue the default value to return if the proerty is not set
828      * @return the property value or the defaultValue if the proerty is not set
829      */

830     public String JavaDoc getStringProperty(String JavaDoc name, String JavaDoc defaultValue)
831     {
832         return message.getStringProperty(name, defaultValue);
833     }
834
835     public void setStringProperty(String JavaDoc name, String JavaDoc value)
836     {
837         setProperty(name, value);
838     }
839
840     /**
841      * Determines whether the event flow is being streamed
842      *
843      * @return true if the request should be streamed
844      */

845     public boolean isStreaming()
846     {
847         return endpoint.isStreaming();
848     }
849
850     /**
851      * Gets the encoding for this message. First it looks to see if encoding has been
852      * set on the endpoint, if not it will check the message itself and finally it
853      * will fall back to the Mule global configuration for encoding which cannot be
854      * null.
855      *
856      * @return the encoding for the event
857      */

858     public String JavaDoc getEncoding()
859     {
860         String JavaDoc encoding = endpoint.getEncoding();
861         if (encoding == null)
862         {
863             encoding = message.getEncoding();
864         }
865         if (encoding == null)
866         {
867             encoding = MuleManager.getConfiguration().getEncoding();
868         }
869         return encoding;
870     }
871
872 }
873
Popular Tags