1 /* 2 * $Id: DefaultMuleEventContext.java 22542 2011-07-22 20:50:01Z dfeist $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.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; 12 13 import org.mule.api.FutureMessageResult; 14 import org.mule.api.MessagingException; 15 import org.mule.api.MuleContext; 16 import org.mule.api.MuleEvent; 17 import org.mule.api.MuleEventContext; 18 import org.mule.api.MuleException; 19 import org.mule.api.MuleMessage; 20 import org.mule.api.MuleSession; 21 import org.mule.api.client.LocalMuleClient; 22 import org.mule.api.config.MuleProperties; 23 import org.mule.api.construct.FlowConstruct; 24 import org.mule.api.endpoint.EndpointBuilder; 25 import org.mule.api.endpoint.EndpointNotFoundException; 26 import org.mule.api.endpoint.EndpointURI; 27 import org.mule.api.endpoint.InboundEndpoint; 28 import org.mule.api.endpoint.OutboundEndpoint; 29 import org.mule.api.processor.MessageProcessor; 30 import org.mule.api.service.Service; 31 import org.mule.api.transaction.Transaction; 32 import org.mule.api.transaction.TransactionException; 33 import org.mule.api.transformer.DataType; 34 import org.mule.api.transformer.TransformerException; 35 import org.mule.config.i18n.CoreMessages; 36 import org.mule.endpoint.EndpointURIEndpointBuilder; 37 import org.mule.endpoint.URIBuilder; 38 import org.mule.transaction.TransactionCoordination; 39 import org.mule.transformer.types.DataTypeFactory; 40 41 import java.io.OutputStream; 42 import java.net.URI; 43 import java.util.concurrent.Callable; 44 45 import org.apache.commons.logging.Log; 46 import org.apache.commons.logging.LogFactory; 47 48 /** 49 * <code>DefaultMuleEventContext</code> is the context object for the current 50 * request. Using the context, developers can send/dispatch/receive events 51 * programmatically as well as manage transactions. 52 */ 53 public class DefaultMuleEventContext implements MuleEventContext 54 { 55 /** 56 * logger used by this class 57 */ 58 protected static final Log logger = LogFactory.getLog(DefaultMuleEventContext.class); 59 60 private final MuleEvent event; 61 private final MuleSession session; 62 private final MuleContext muleContext; 63 private final LocalMuleClient clientInterface; 64 65 public DefaultMuleEventContext(MuleEvent event) 66 { 67 this.event = event; 68 this.session = event.getSession(); 69 this.muleContext = event.getMuleContext(); 70 this.clientInterface = muleContext.getClient(); 71 } 72 73 /** 74 * Returns the message payload for this event 75 * 76 * @return the message payload for this event 77 */ 78 public MuleMessage getMessage() 79 { 80 return event.getMessage(); 81 } 82 83 /** 84 * Reterns the conents of the message as a byte array. 85 * 86 * @return the conents of the message as a byte array 87 * @throws org.mule.api.MuleException if the message cannot be converted into an 88 * array of bytes 89 */ 90 public byte[] getMessageAsBytes() throws MuleException 91 { 92 return event.getMessageAsBytes(); 93 } 94 95 /** 96 * Returns the message transformed into its recognised or expected format. The 97 * transformer used is the one configured on the endpoint through which this 98 * event was received. 99 * 100 * @param dataType The dataType required for the return object. This param 101 * just provides a convienient way to manage type casting of 102 * transformed objects 103 * @return the message transformed into it's recognised or expected format. 104 * @throws org.mule.api.transformer.TransformerException if a failure occurs or 105 * if the return type is not the same as the expected type in the 106 * transformer 107 * @see org.mule.api.transformer.Transformer 108 */ 109 public Object transformMessage(DataType dataType) throws TransformerException 110 { 111 return event.transformMessage(dataType); 112 } 113 114 /** 115 * Returns the message transformed into its recognised or expected format. The 116 * transformer used is the one configured on the endpoint through which this 117 * event was received. 118 * 119 * @param expectedType The class type required for the return object. This param 120 * just provides a convienient way to manage type casting of 121 * transformed objects 122 * @return the message transformed into it's recognised or expected format. 123 * @throws org.mule.api.transformer.TransformerException if a failure occurs or 124 * if the return type is not the same as the expected type in the 125 * transformer 126 * @see org.mule.api.transformer.Transformer 127 */ 128 public Object transformMessage(Class expectedType) throws TransformerException 129 { 130 return event.transformMessage(DataTypeFactory.create(expectedType)); 131 } 132 133 /** 134 * Returns the message transformed into it's recognised or expected format and 135 * then into an array of bytes. The transformer used is the one configured on the 136 * endpoint through which this event was received. 137 * 138 * @return the message transformed into it's recognised or expected format as an 139 * array of bytes. 140 * @throws org.mule.api.transformer.TransformerException if a failure occurs in 141 * the transformer 142 * @see org.mule.api.transformer.Transformer 143 * @deprecated use {@link #transformMessage(org.mule.api.transformer.DataType)} instead 144 */ 145 @Deprecated 146 public byte[] transformMessageToBytes() throws TransformerException 147 { 148 return event.transformMessage(DataType.BYTE_ARRAY_DATA_TYPE); 149 } 150 151 /** 152 * Returns the message contents as a string 153 * 154 * @return the message contents as a string 155 * @throws org.mule.api.MuleException if the message cannot be converted into a 156 * string 157 */ 158 public String getMessageAsString(String encoding) throws MuleException 159 { 160 return event.getMessageAsString(encoding); 161 } 162 163 /** 164 * Returns the message transformed into it's recognised or expected format and 165 * then into a String. The transformer used is the one configured on the endpoint 166 * through which this event was received. This method will use the default 167 * encoding on the event 168 * 169 * @return the message transformed into it's recognised or expected format as a 170 * Strings. 171 * @throws org.mule.api.transformer.TransformerException if a failure occurs in 172 * the transformer 173 * @see org.mule.api.transformer.Transformer 174 */ 175 public String transformMessageToString() throws TransformerException 176 { 177 return event.transformMessageToString(); 178 } 179 180 /** 181 * Returns the message contents as a string This method will use the default 182 * encoding on the event 183 * 184 * @return the message contents as a string 185 * @throws org.mule.api.MuleException if the message cannot be converted into a 186 * string 187 */ 188 public String getMessageAsString() throws MuleException 189 { 190 return event.getMessageAsString(); 191 } 192 193 /** 194 * Returns the current transaction (if any) for the session 195 * 196 * @return the current transaction for the session or null if there is no 197 * transaction in progress 198 */ 199 public Transaction getCurrentTransaction() 200 { 201 return TransactionCoordination.getInstance().getTransaction(); 202 } 203 204 public void markTransactionForRollback() throws TransactionException 205 { 206 if (getCurrentTransaction() != null) 207 { 208 getCurrentTransaction().setRollbackOnly(); 209 } 210 } 211 212 /** 213 * This will send an event via the configured outbound router on the service 214 * 215 * @param message the message to send 216 * @return the result of the send if any 217 * @throws org.mule.api.MuleException if there is no outbound endpoint configured 218 * on the service or the events fails during dispatch 219 */ 220 public MuleMessage sendEvent(Object message) throws MuleException 221 { 222 return sendEvent(new DefaultMuleMessage(message, event.getMessage(), event.getMuleContext())); 223 } 224 225 /** 226 * Depending on the session state this methods either Passes an event 227 * synchronously to the next available Mule component in the pool or via the 228 * endpoint configured for the event 229 * 230 * @param message the event message payload to send 231 * @param endpoint The endpoint to disptch the event through. 232 * @return the return Message from the call or null if there was no result 233 * @throws org.mule.api.MuleException if the event fails to be processed by the 234 * service or the transport for the endpoint 235 */ 236 public MuleMessage sendEvent(MuleMessage message, OutboundEndpoint endpoint) throws MuleException 237 { 238 return clientInterface.process(endpoint, message); 239 } 240 241 /** 242 * Depending on the session state this methods either Passes an event 243 * synchronously to the next available Mule component in the pool or via the 244 * endpoint configured for the event 245 * 246 * @param message the message payload to send 247 * @return the return Message from the call or null if there was no result 248 * @throws org.mule.api.MuleException if the event fails to be processed by the 249 * service or the transport for the endpoint 250 */ 251 public MuleMessage sendEvent(MuleMessage message) throws MuleException 252 { 253 if (session.getFlowConstruct() instanceof Service) 254 { 255 Service service = (Service) session.getFlowConstruct(); 256 DefaultMuleEvent eventToSend = new DefaultMuleEvent(message, MessageExchangePattern.REQUEST_RESPONSE, 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("FlowConstuct is not a 'Service', MuleEventContext cannot send 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 URI getEndpointURI() 669 { 670 return event.getMessageSourceURI(); 671 } 672 673 public MessageExchangePattern getExchangePattern() 674 { 675 return event.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 }