View Javadoc
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;
8   
9   import org.mule.api.FutureMessageResult;
10  import org.mule.api.MessagingException;
11  import org.mule.api.MuleContext;
12  import org.mule.api.MuleEvent;
13  import org.mule.api.MuleEventContext;
14  import org.mule.api.MuleException;
15  import org.mule.api.MuleMessage;
16  import org.mule.api.MuleSession;
17  import org.mule.api.client.LocalMuleClient;
18  import org.mule.api.config.MuleProperties;
19  import org.mule.api.construct.FlowConstruct;
20  import org.mule.api.endpoint.EndpointBuilder;
21  import org.mule.api.endpoint.EndpointNotFoundException;
22  import org.mule.api.endpoint.EndpointURI;
23  import org.mule.api.endpoint.InboundEndpoint;
24  import org.mule.api.endpoint.OutboundEndpoint;
25  import org.mule.api.processor.MessageProcessor;
26  import org.mule.api.service.Service;
27  import org.mule.api.transaction.Transaction;
28  import org.mule.api.transaction.TransactionException;
29  import org.mule.api.transformer.DataType;
30  import org.mule.api.transformer.TransformerException;
31  import org.mule.config.i18n.CoreMessages;
32  import org.mule.endpoint.EndpointURIEndpointBuilder;
33  import org.mule.endpoint.URIBuilder;
34  import org.mule.transaction.TransactionCoordination;
35  import org.mule.transformer.types.DataTypeFactory;
36  
37  import java.io.OutputStream;
38  
39  import edu.emory.mathcs.backport.java.util.concurrent.Callable;
40  
41  import org.apache.commons.logging.Log;
42  import org.apache.commons.logging.LogFactory;
43  
44  /**
45   * <code>DefaultMuleEventContext</code> is the context object for the current
46   * request. Using the context, developers can send/dispatch/receive events
47   * programmatically as well as manage transactions.
48   */
49  public class DefaultMuleEventContext implements MuleEventContext
50  {
51      /**
52       * logger used by this class
53       */
54      protected static final Log logger = LogFactory.getLog(DefaultMuleEventContext.class);
55  
56      private final MuleEvent event;
57      private final MuleSession session;
58      private final MuleContext muleContext;
59      private final LocalMuleClient clientInterface;
60  
61      public DefaultMuleEventContext(MuleEvent event)
62      {
63          this.event = event;
64          this.session = event.getSession();
65          this.muleContext = event.getMuleContext();
66          this.clientInterface = muleContext.getClient();
67      }
68  
69      /**
70       * Returns the message payload for this event
71       *
72       * @return the message payload for this event
73       */
74      public MuleMessage getMessage()
75      {
76          return event.getMessage();
77      }
78  
79      /**
80       * Reterns the conents of the message as a byte array.
81       *
82       * @return the conents of the message as a byte array
83       * @throws org.mule.api.MuleException if the message cannot be converted into an
84       *             array of bytes
85       */
86      public byte[] getMessageAsBytes() throws MuleException
87      {
88          return event.getMessageAsBytes();
89      }
90  
91      /**
92       * Returns the message transformed into its recognised or expected format. The
93       * transformer used is the one configured on the endpoint through which this
94       * event was received.
95       *
96       * @param dataType The dataType  required for the return object. This param
97       *            just provides a convienient way to manage type casting of
98       *            transformed objects
99       * @return the message transformed into it's recognised or expected format.
100      * @throws org.mule.api.transformer.TransformerException if a failure occurs or
101      *             if the return type is not the same as the expected type in the
102      *             transformer
103      * @see org.mule.api.transformer.Transformer
104      */
105     public Object transformMessage(DataType dataType) throws TransformerException
106     {
107         return event.transformMessage(dataType);
108     }
109 
110     /**
111      * Returns the message transformed into its recognised or expected format. The
112      * transformer used is the one configured on the endpoint through which this
113      * event was received.
114      *
115      * @param expectedType The class type required for the return object. This param
116      *            just provides a convienient way to manage type casting of
117      *            transformed objects
118      * @return the message transformed into it's recognised or expected format.
119      * @throws org.mule.api.transformer.TransformerException if a failure occurs or
120      *             if the return type is not the same as the expected type in the
121      *             transformer
122      * @see org.mule.api.transformer.Transformer
123      */
124     public Object transformMessage(Class expectedType) throws TransformerException
125     {
126         return event.transformMessage(DataTypeFactory.create(expectedType));
127     }
128 
129     /**
130      * Returns the message transformed into it's recognised or expected format and
131      * then into an array of bytes. The transformer used is the one configured on the
132      * endpoint through which this event was received.
133      *
134      * @return the message transformed into it's recognised or expected format as an
135      *         array of bytes.
136      * @throws org.mule.api.transformer.TransformerException if a failure occurs in
137      *             the transformer
138      * @see org.mule.api.transformer.Transformer
139      * @deprecated use {@link #transformMessage(org.mule.api.transformer.DataType)} instead
140      */
141     @Deprecated
142     public byte[] transformMessageToBytes() throws TransformerException
143     {
144         return event.transformMessage(DataType.BYTE_ARRAY_DATA_TYPE);
145     }
146 
147     /**
148      * Returns the message contents as a string
149      *
150      * @return the message contents as a string
151      * @throws org.mule.api.MuleException if the message cannot be converted into a
152      *             string
153      */
154     public String getMessageAsString(String encoding) throws MuleException
155     {
156         return event.getMessageAsString(encoding);
157     }
158 
159     /**
160      * Returns the message transformed into it's recognised or expected format and
161      * then into a String. The transformer used is the one configured on the endpoint
162      * through which this event was received. This method will use the default
163      * encoding on the event
164      *
165      * @return the message transformed into it's recognised or expected format as a
166      *         Strings.
167      * @throws org.mule.api.transformer.TransformerException if a failure occurs in
168      *             the transformer
169      * @see org.mule.api.transformer.Transformer
170      */
171     public String transformMessageToString() throws TransformerException
172     {
173         return event.transformMessageToString();
174     }
175 
176     /**
177      * Returns the message contents as a string This method will use the default
178      * encoding on the event
179      *
180      * @return the message contents as a string
181      * @throws org.mule.api.MuleException if the message cannot be converted into a
182      *             string
183      */
184     public String getMessageAsString() throws MuleException
185     {
186         return event.getMessageAsString();
187     }
188 
189     /**
190      * Returns the current transaction (if any) for the session
191      *
192      * @return the current transaction for the session or null if there is no
193      *         transaction in progress
194      */
195     public Transaction getCurrentTransaction()
196     {
197         return TransactionCoordination.getInstance().getTransaction();
198     }
199 
200     public void markTransactionForRollback() throws TransactionException
201     {
202         if (getCurrentTransaction() != null)
203         {
204             getCurrentTransaction().setRollbackOnly();
205         }
206     }
207 
208     /**
209      * This will send an event via the configured outbound router on the service
210      *
211      * @param message the message to send
212      * @return the result of the send if any
213      * @throws org.mule.api.MuleException if there is no outbound endpoint configured
214      *             on the service or the events fails during dispatch
215      */
216     public MuleMessage sendEvent(Object message) throws MuleException
217     {
218         return sendEvent(new DefaultMuleMessage(message, event.getMessage(), event.getMuleContext()));
219     }
220 
221     /**
222      * Depending on the session state this methods either Passes an event
223      * synchronously to the next available Mule component in the pool or via the
224      * endpoint configured for the event
225      *
226      * @param message the event message payload to send
227      * @param endpoint The endpoint to disptch the event through.
228      * @return the return Message from the call or null if there was no result
229      * @throws org.mule.api.MuleException if the event fails to be processed by the
230      *             service or the transport for the endpoint
231      */
232     public MuleMessage sendEvent(MuleMessage message, OutboundEndpoint endpoint) throws MuleException
233     {
234         return clientInterface.process(endpoint, message);
235     }
236 
237     /**
238      * Depending on the session state this methods either Passes an event
239      * synchronously to the next available Mule component in the pool or via the
240      * endpoint configured for the event
241      *
242      * @param message the message payload to send
243      * @return the return Message from the call or null if there was no result
244      * @throws org.mule.api.MuleException if the event fails to be processed by the
245      *             service or the transport for the endpoint
246      */
247     public MuleMessage sendEvent(MuleMessage message) throws MuleException
248     {
249         if (event.getEndpoint() instanceof OutboundEndpoint)
250         {
251             return clientInterface.process((OutboundEndpoint) event.getEndpoint(), message);
252         }
253         else if (session.getFlowConstruct() instanceof Service)
254         {
255             Service service = (Service) session.getFlowConstruct();
256             DefaultMuleEvent eventToSend = new DefaultMuleEvent(message, event.getEndpoint(), session);
257             MuleEvent event = service.sendEvent(eventToSend);
258             return event == null ? null : event.getMessage();
259         }
260         else
261         {
262             throw new MessagingException(
263                 CoreMessages.createStaticMessage("Current event has 'inbound' endpoint and FlowConstuct is not a 'Service', MuleEventContext cannot  this message"),
264                 event);
265         }
266     }
267 
268     /**
269      * Depending on the session state this methods either Passes an event
270      * synchronously to the next available Mule component in the pool or via the
271      * endpointUri configured for the event
272      *
273      * @param message the event message payload to send
274      * @param endpointUri The endpointUri to disptch the event through
275      * @return the return Message from the call or null if there was no result
276      * @throws org.mule.api.MuleException if the event fails to be processed by the
277      *             service or the transport for the endpointUri
278      */
279     public MuleMessage sendEvent(MuleMessage message, EndpointURI endpointUri) throws MuleException
280     {
281         EndpointBuilder builder = null;
282         if (endpointUri.getEndpointName() != null)
283         {
284             builder = muleContext.getRegistry().lookupEndpointBuilder(endpointUri.getEndpointName());
285         }
286         if (builder == null)
287         {
288             builder = new EndpointURIEndpointBuilder(new URIBuilder(endpointUri));
289         }
290 
291         builder.setExchangePattern(MessageExchangePattern.REQUEST_RESPONSE);
292 
293         OutboundEndpoint endpoint = getMuleContext().getEndpointFactory().getOutboundEndpoint(builder);
294         return clientInterface.process(endpoint, message);
295     }
296 
297     /**
298      * sends an event request via the configured outbound router for this service.
299      * This method return immediately, but the result of the event invocation
300      * available from the returned a Future result that can be accessed later by the
301      * the returned FutureMessageResult. the Future messageResult can be queried at
302      * any time to check that the invocation has completed. A timeout is associated
303      * with the invocation, which is the maximum time in milli-seconds that the
304      * invocation should take to complete
305      *
306      * @param message the object that is the payload of the event
307      * @param timeout how long to block in milliseconds waiting for a result
308      * @return the result message if any of the invocation
309      * @throws org.mule.api.MuleException if the dispatch fails or the components or
310      *             transfromers cannot be found
311      * @see org.mule.api.FutureMessageResult
312      */
313     public FutureMessageResult sendEventAsync(final Object message, final int timeout) throws MuleException
314     {
315         Callable callable = new Callable()
316         {
317             public Object call() throws Exception
318             {
319                 MuleMessage muleMessage = new DefaultMuleMessage(message, event.getMessage(),
320                     event.getMuleContext());
321                 muleMessage.setOutboundProperty(MuleProperties.MULE_EVENT_TIMEOUT_PROPERTY, timeout);
322                 return sendEvent(muleMessage);
323             }
324         };
325 
326         FutureMessageResult result = new FutureMessageResult(callable, event.getMuleContext());
327         result.execute();
328         return result;
329     }
330 
331     /**
332      * sends an event request via the configured outbound router for this service.
333      * This method return immediately, but the result of the event invocation
334      * available from the returned a Future result that can be accessed later by the
335      * the returned FutureMessageResult. the Future messageResult can be queried at
336      * any time to check that the invocation has completed. A timeout is associated
337      * with the invocation, which is the maximum time in milli-seconds that the
338      * invocation should take to complete
339      *
340      * @param message the MuleMessage of the event
341      * @param timeout how long to block in milliseconds waiting for a result
342      * @return the result message if any of the invocation
343      * @throws org.mule.api.MuleException if the dispatch fails or the components or
344      *             transfromers cannot be found
345      * @see org.mule.api.FutureMessageResult
346      */
347     public FutureMessageResult sendEventAsync(final MuleMessage message, final int timeout)
348         throws MuleException
349     {
350         Callable callable = new Callable()
351         {
352             public Object call() throws Exception
353             {
354                 message.setOutboundProperty(MuleProperties.MULE_EVENT_TIMEOUT_PROPERTY, timeout);
355                 return sendEvent(message);
356             }
357         };
358 
359         FutureMessageResult result = new FutureMessageResult(callable, event.getMuleContext());
360         result.execute();
361         return result;
362     }
363 
364     /**
365      * sends an event request via the configured outbound router for this service.
366      * This method return immediately, but the result of the event invocation
367      * available from the returned a Future result that can be accessed later by the
368      * the returned FutureMessageResult. the Future messageResult can be queried at
369      * any time to check that the invocation has completed. A timeout is associated
370      * with the invocation, which is the maximum time in milli-seconds that the
371      * invocation should take to complete
372      *
373      * @param message the MuleMessage of the event
374      * @param endpointUri the endpointUri to dispatch to
375      * @param timeout how long to block in milliseconds waiting for a result
376      * @return the result message if any of the invocation
377      * @throws org.mule.api.MuleException if the dispatch fails or the components or
378      *             transfromers cannot be found
379      * @see org.mule.api.FutureMessageResult
380      */
381     public FutureMessageResult sendEventAsync(final MuleMessage message,
382                                               final EndpointURI endpointUri,
383                                               final int timeout) throws MuleException
384     {
385         Callable callable = new Callable()
386         {
387             public Object call() throws Exception
388             {
389                 message.setOutboundProperty(MuleProperties.MULE_EVENT_TIMEOUT_PROPERTY, timeout);
390                 return sendEvent(message, endpointUri);
391             }
392         };
393 
394         FutureMessageResult result = new FutureMessageResult(callable, event.getMuleContext());
395         result.execute();
396         return result;
397     }
398 
399     /**
400      * sends an event request via the configured outbound router for this service.
401      * This method return immediately, but the result of the event invocation
402      * available from the returned a Future result that can be accessed later by the
403      * the returned FutureMessageResult. the Future messageResult can be queried at
404      * any time to check that the invocation has completed. A timeout is associated
405      * with the invocation, which is the maximum time in milli-seconds that the
406      * invocation should take to complete
407      *
408      * @param message the MuleMessage of the event
409      * @param endpointName The endpoint name to disptch the event through. This will
410      *            be looked up first on the service configuration and then on the
411      *            mule manager configuration
412      * @param timeout how long to block in milliseconds waiting for a result
413      * @return the result message if any of the invocation
414      * @throws org.mule.api.MuleException if the dispatch fails or the components or
415      *             transfromers cannot be found
416      * @see org.mule.api.FutureMessageResult
417      */
418     public FutureMessageResult sendEventAsync(final MuleMessage message,
419                                               final String endpointName,
420                                               final int timeout) throws MuleException
421     {
422         Callable callable = new Callable()
423         {
424             public Object call() throws Exception
425             {
426                 message.setOutboundProperty(MuleProperties.MULE_EVENT_TIMEOUT_PROPERTY, timeout);
427                 return sendEvent(message, endpointName);
428             }
429         };
430 
431         FutureMessageResult result = new FutureMessageResult(callable, event.getMuleContext());
432         result.execute();
433         return result;
434     }
435 
436     /**
437      * Depending on the session state this methods either Passes an event
438      * synchronously to the next available Mule component in the pool or via the
439      * endpoint configured for the event
440      *
441      * @param message the event message payload to send
442      * @param endpointName The endpoint name to disptch the event through. This will
443      *            be looked up first on the service configuration and then on the
444      *            mule manager configuration
445      * @return the return Message from the call or null if there was no result
446      * @throws org.mule.api.MuleException if the event fails to be processed by the
447      *             service or the transport for the endpoint
448      */
449     public MuleMessage sendEvent(MuleMessage message, String endpointName) throws MuleException
450     {
451         return clientInterface.send(endpointName, message);
452     }
453 
454     /**
455      * This will dispatch an event asynchronously via the configured outbound
456      * endpoint on the service for this session
457      *
458      * @param message payload to dispatch
459      * @throws org.mule.api.MuleException if there is no outbound endpoint configured
460      *             on the service or the events fails during dispatch
461      */
462     public void dispatchEvent(Object message) throws MuleException
463     {
464         dispatchEvent(new DefaultMuleMessage(message, muleContext));
465     }
466 
467     /**
468      * This will dispatch an event asynchronously via the configured outbound
469      * endpoint on the service for this session
470      *
471      * @param message the message to send
472      * @throws org.mule.api.MuleException if there is no outbound endpoint configured
473      *             on the service or the events fails during dispatch
474      */
475     public void dispatchEvent(MuleMessage message) throws MuleException
476     {
477         FlowConstruct flowConstruct = session.getFlowConstruct();
478         if (flowConstruct == null)
479         {
480             throw new IllegalStateException(CoreMessages.objectIsNull("flowConstruct").getMessage());
481         }
482         else if (!(flowConstruct instanceof Service))
483         {
484             throw new UnsupportedOperationException(
485                 "EventContext.dispatchEvent is only supported when flow constuct is a Service");
486         }
487         else
488         {
489             MessageProcessor processor = ((Service) flowConstruct).getOutboundMessageProcessor();
490             if (processor == null)
491             {
492                 throw new EndpointNotFoundException(
493                     CoreMessages.noOutboundRouterSetOn(flowConstruct.getName()));
494             }
495             processor.process(new DefaultMuleEvent(message, RequestContext.getEvent()));
496         }
497     }
498 
499     /**
500      * Depending on the session state this methods either Passes an event
501      * asynchronously to the next available Mule component in the pool or via the
502      * endpointUri configured for the event
503      *
504      * @param message the event message payload to send
505      * @param endpointUri the endpointUri to dispatc the event to first on the
506      *            service configuration and then on the mule manager configuration
507      * @throws org.mule.api.MuleException if the event fails to be processed by the
508      *             service or the transport for the endpointUri
509      */
510     public void dispatchEvent(MuleMessage message, EndpointURI endpointUri) throws MuleException
511     {
512         EndpointBuilder builder = null;
513         if (endpointUri.getEndpointName() != null)
514         {
515             builder = muleContext.getRegistry().lookupEndpointBuilder(endpointUri.getEndpointName());
516         }
517         if (builder == null)
518         {
519             builder = new EndpointURIEndpointBuilder(new URIBuilder(endpointUri));
520         }
521 
522         builder.setExchangePattern(MessageExchangePattern.ONE_WAY);
523 
524         OutboundEndpoint endpoint = getMuleContext().getEndpointFactory().getOutboundEndpoint(builder);
525         clientInterface.process(endpoint, message);    }
526 
527     /**
528      * Depending on the session state this methods either Passes an event
529      * asynchronously to the next available Mule component in the pool or via the
530      * endpoint configured for the event
531      *
532      * @param message the event message payload to send
533      * @param endpointName The endpoint name to disptch the event through. This will
534      *            be looked up first on the service configuration and then on the
535      *            mule manager configuration
536      * @throws org.mule.api.MuleException if the event fails to be processed by the
537      *             service or the transport for the endpoint
538      */
539     public void dispatchEvent(MuleMessage message, String endpointName) throws MuleException
540     {
541         EndpointBuilder builder = muleContext.getRegistry().lookupEndpointBuilder(endpointName);
542 
543         if (builder == null)
544         {
545             builder = new EndpointURIEndpointBuilder(new URIBuilder(endpointName, muleContext));
546         }
547 
548         builder.setExchangePattern(MessageExchangePattern.ONE_WAY);
549 
550         OutboundEndpoint endpoint = getMuleContext().getEndpointFactory().getOutboundEndpoint(builder);
551         clientInterface.process(endpoint, message);
552     }
553 
554     /**
555      * Depending on the session state this methods either Passes an event
556      * asynchronously to the next available Mule component in the pool or via the
557      * endpoint configured for the event
558      *
559      * @param message the event message payload to send
560      * @param endpoint The endpoint name to disptch the event through.
561      * @throws org.mule.api.MuleException if the event fails to be processed by the
562      *             service or the transport for the endpoint
563      */
564     public void dispatchEvent(MuleMessage message, OutboundEndpoint endpoint) throws MuleException
565     {
566         clientInterface.process(endpoint, message);
567     }
568 
569     /**
570      * Requests a synchronous receive of an event on the service
571      *
572      * @param endpoint the endpoint identifing the endpointUri on ewhich the event
573      *            will be received
574      * @param timeout time in milliseconds before the request timesout
575      * @return The requested event or null if the request times out
576      * @throws org.mule.api.MuleException if the request operation fails
577      */
578     public MuleMessage requestEvent(InboundEndpoint endpoint, long timeout) throws MuleException
579     {
580         return clientInterface.request(endpoint, timeout);
581     }
582 
583     /**
584      * Requests a synchronous receive of an event on the service
585      *
586      * @param endpointName the endpoint identifing the endpointUri on ewhich the
587      *            event will be received
588      * @param timeout time in milliseconds before the request timesout
589      * @return The requested event or null if the request times out
590      * @throws org.mule.api.MuleException if the request operation fails
591      */
592     public MuleMessage requestEvent(String endpointName, long timeout) throws MuleException
593     {
594         return clientInterface.request(endpointName, timeout);
595     }
596 
597     /**
598      * Requests a synchronous receive of an event on the service
599      *
600      * @param endpointUri the endpointUri on which the event will be received
601      * @param timeout time in milliseconds before the request timesout
602      * @return The requested event or null if the request times out
603      * @throws org.mule.api.MuleException if the request operation fails
604      */
605     public MuleMessage requestEvent(EndpointURI endpointUri, long timeout) throws MuleException
606     {
607         InboundEndpoint endpoint = getMuleContext().getEndpointFactory().getInboundEndpoint(
608             endpointUri);
609         return requestEvent(endpoint, timeout);
610     }
611 
612     /**
613      * @return the service descriptor of the service that received this event
614      */
615     public FlowConstruct getFlowConstruct()
616     {
617         return event.getFlowConstruct();
618     }
619 
620     /**
621      * Determines whether the default processing for this event will be executed. By
622      * default, the Mule server will route events according to a components
623      * configuration. The user can override this behaviour by obtaining a reference
624      * to the MuleEvent context, either by implementing
625      * <code>org.mule.api.lifecycle.Callable</code> or calling
626      * <code>RequestContext.getEventContext</code> to obtain the MuleEventContext for
627      * the current thread. The user can programmatically control how events are
628      * dispatched.
629      *
630      * @return Returns true is the user has set stopFurtherProcessing.
631      * @see org.mule.api.MuleEventContext
632      * @see org.mule.api.lifecycle.Callable
633      */
634     public boolean isStopFurtherProcessing()
635     {
636         return RequestContext.getEvent().isStopFurtherProcessing();
637     }
638 
639     /**
640      * Determines whether the default processing for this event will be executed. By
641      * default, the Mule server will route events according to a components
642      * configuration. The user can override this behaviour by obtaining a reference
643      * to the MuleEvent context, either by implementing
644      * <code>org.mule.api.lifecycle.Callable</code> or calling
645      * <code>RequestContext.getEventContext</code> to obtain the MuleEventContext for
646      * the current thread. The user can programmatically control how events are
647      * dispached.
648      *
649      * @param stopFurtherProcessing the value to set.
650      */
651     public void setStopFurtherProcessing(boolean stopFurtherProcessing)
652     {
653         event.setStopFurtherProcessing(stopFurtherProcessing);
654     }
655 
656     /**
657      * An outputstream the can optionally be used write response data to an incoming
658      * message.
659      *
660      * @return an output stream if one has been made available by the message
661      *         receiver that received the message
662      */
663     public OutputStream getOutputStream()
664     {
665         return event.getOutputStream();
666     }
667 
668     public EndpointURI getEndpointURI()
669     {
670         return event.getEndpoint().getEndpointURI();
671     }
672 
673     public MessageExchangePattern getExchangePattern()
674     {
675         return event.getEndpoint().getExchangePattern();
676     }
677 
678     /**
679      * Returns the transaction for the current event or null if there is no
680      * transaction in progresss
681      *
682      * @return the transaction for the current event or null if there is no
683      *         transaction in progresss
684      */
685     public Transaction getTransaction()
686     {
687         return TransactionCoordination.getInstance().getTransaction();
688     }
689 
690     /**
691      * Get the timeout value associated with the event
692      *
693      * @return the timeout for the event
694      */
695     public int getTimeout()
696     {
697         return event.getTimeout();
698     }
699 
700     /**
701      * Gets the encoding for the current message. For potocols that send encoding
702      * Information with the message, this method should be overriden to expose the
703      * transport encoding, otherwise the default encoding in the Mule configuration
704      * will be used
705      *
706      * @return the encoding for this message. This method must never return null
707      */
708     public String getEncoding()
709     {
710         return event.getEncoding();
711     }
712 
713     public MuleSession getSession()
714     {
715         return event.getSession();
716     }
717 
718     @Override
719     public String toString()
720     {
721         return event.toString();
722     }
723 
724     public MuleContext getMuleContext()
725     {
726         return event.getMuleContext();
727     }
728 
729 }