Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mule
Class DefaultMuleEventContext

    java.lang.Object
      org.mule.DefaultMuleEventContext

All Implemented Interfaces:
  MuleEventContext

    public class DefaultMuleEventContext

extends Object
implements MuleEventContext

`DefaultMuleEventContext` is the context object for the current request. Using the context, developers can send/dispatch/receive events programmatically as well as manage transactions.

Field Summary
`protected static Log` | `logger` logger used by this class

Constructor Summary
`DefaultMuleEventContext(MuleEvent event)`

Method Summary
`void` | `dispatchEvent(MuleMessage message)` This will dispatch an event asynchronously via the configured outbound endpoint on the service for this session
`void` | `dispatchEvent(MuleMessage message, EndpointURI endpointUri)` Depending on the session state this methods either Passes an event asynchronously to the next available Mule component in the pool or via the endpointUri configured for the event
`void` | `dispatchEvent(MuleMessage message, OutboundEndpoint endpoint)` Depending on the session state this methods either Passes an event asynchronously to the next available Mule component in the pool or via the endpoint configured for the event
`void` | `dispatchEvent(MuleMessage message, String endpointName)` Depending on the session state this methods either Passes an event asynchronously to the next available Mule component in the pool or via the endpoint configured for the event
`void` | `dispatchEvent(Object message)` This will dispatch an event asynchronously via the configured outbound endpoint on the service for this session
`Transaction` | `getCurrentTransaction()` Returns the current transaction (if any) for the session
`String` | `getEncoding()` Gets the encoding for the current message.
`EndpointURI` | `getEndpointURI()` Returns a reference to the Endpoint Uri for this context This is the endpoint on which the event was received
`MessageExchangePattern` | `getExchangePattern()`
`FlowConstruct` | `getFlowConstruct()`
`MuleMessage` | `getMessage()` Returns the message payload for this event
`byte[]` | `getMessageAsBytes()` Reterns the conents of the message as a byte array.
`String` | `getMessageAsString()` Returns the message contents as a string This method will use the default encoding on the event
`String` | `getMessageAsString(String encoding)` Returns the message contents as a string
`MuleContext` | `getMuleContext()`
`OutputStream` | `getOutputStream()` An outputstream the can optionally be used write response data to an incoming message.
`MuleSession` | `getSession()`
`int` | `getTimeout()` Get the timeout value associated with the event
`Transaction` | `getTransaction()` Returns the transaction for the current event or null if there is no transaction in progresss
`boolean` | `isStopFurtherProcessing()` Determines whether the default processing for this event will be executed.
`void` | `markTransactionForRollback()` Mark the current transaction (if any) for rollback
`MuleMessage` | `requestEvent(EndpointURI endpointUri, long timeout)` Requests a synchronous receive of an event on the service
`MuleMessage` | `requestEvent(InboundEndpoint endpoint, long timeout)` Requests a synchronous receive of an event on the service
`MuleMessage` | `requestEvent(String endpointName, long timeout)` Requests a synchronous receive of an event on the service
`MuleMessage` | `sendEvent(MuleMessage message)` Depending on the session state this methods either Passes an event synchronously to the next available Mule component in the pool or via the endpoint configured for the event
`MuleMessage` | `sendEvent(MuleMessage message, EndpointURI endpointUri)` Depending on the session state this methods either Passes an event synchronously to the next available Mule component in the pool or via the endpointUri configured for the event
`MuleMessage` | `sendEvent(MuleMessage message, OutboundEndpoint endpoint)` Depending on the session state this methods either Passes an event synchronously to the next available Mule component in the pool or via the endpoint configured for the event
`MuleMessage` | `sendEvent(MuleMessage message, String endpointName)` Depending on the session state this methods either Passes an event synchronously to the next available Mule component in the pool or via the endpoint configured for the event
`MuleMessage` | `sendEvent(Object message)` This will send an event via the configured outbound router on the service
`FutureMessageResult` | `sendEventAsync(MuleMessage message, EndpointURI endpointUri, int timeout)` sends an event request via the configured outbound router for this service.
`FutureMessageResult` | `sendEventAsync(MuleMessage message, int timeout)` sends an event request via the configured outbound router for this service.
`FutureMessageResult` | `sendEventAsync(MuleMessage message, String endpointName, int timeout)` sends an event request via the configured outbound router for this service.
`FutureMessageResult` | `sendEventAsync(Object message, int timeout)` sends an event request via the configured outbound router for this service.
`void` | `setStopFurtherProcessing(boolean stopFurtherProcessing)` Determines whether the default processing for this event will be executed.
`String` | `toString()`
`Object` | `transformMessage(Class expectedType)` Returns the message transformed into its recognised or expected format.
`Object` | `transformMessage(DataType dataType)` Returns the message transformed into its recognised or expected format.
`byte[]` | `transformMessageToBytes()` Deprecated. use `transformMessage(org.mule.api.transformer.DataType)` instead
`String` | `transformMessageToString()` Returns the message transformed into it's recognised or expected format and then into a String.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### logger

    protected static final Log logger

  logger used by this class

Constructor Detail

### DefaultMuleEventContext

    public DefaultMuleEventContext(MuleEvent event)

Method Detail

### getMessage

    public MuleMessage getMessage()

  Returns the message payload for this event

  Specified by:
    `getMessage` in interface `MuleEventContext`
  Returns:
    the message payload for this event

### getMessageAsBytes

    public byte[] getMessageAsBytes()
                             throws MuleException

  Reterns the conents of the message as a byte array.

  Specified by:
    `getMessageAsBytes` in interface `MuleEventContext`
  Returns:
    the conents of the message as a byte array
  Throws:
    `MuleException` - if the message cannot be converted into an array of bytes

### transformMessage

    public Object transformMessage(DataType dataType)
                            throws TransformerException

  Returns the message transformed into its recognised or expected format. The transformer used is the one configured on the endpoint through which this event was received.

  Specified by:
    `transformMessage` in interface `MuleEventContext`
  Parameters:
    `dataType` - The dataType required for the return object. This param just provides a convienient way to manage type casting of transformed objects
  Returns:
    the message transformed into it's recognised or expected format.
  Throws:
    `TransformerException` - if a failure occurs or if the return type is not the same as the expected type in the transformer
  See Also:
    `Transformer`

### transformMessage

    public Object transformMessage(Class expectedType)
                            throws TransformerException

  Returns the message transformed into its recognised or expected format. The transformer used is the one configured on the endpoint through which this event was received.

  Specified by:
    `transformMessage` in interface `MuleEventContext`
  Parameters:
    `expectedType` - The class type required for the return object. This param just provides a convienient way to manage type casting of transformed objects
  Returns:
    the message transformed into it's recognised or expected format.
  Throws:
    `TransformerException` - if a failure occurs or if the return type is not the same as the expected type in the transformer
  See Also:
    `Transformer`

### transformMessageToBytes

    @Deprecated
    public byte[] transformMessageToBytes()
                                   throws TransformerException

  Deprecated. use `transformMessage(org.mule.api.transformer.DataType)` instead

  Returns the message transformed into it's recognised or expected format and then into an array of bytes. The transformer used is the one configured on the endpoint through which this event was received.

  Specified by:
    `transformMessageToBytes` in interface `MuleEventContext`
  Returns:
    the message transformed into it's recognised or expected format as an array of bytes.
  Throws:
    `TransformerException` - if a failure occurs in the transformer
  See Also:
    `Transformer`

### getMessageAsString

    public String getMessageAsString(String encoding)
                              throws MuleException

  Returns the message contents as a string

  Specified by:
    `getMessageAsString` in interface `MuleEventContext`
  Parameters:
    `encoding` - The encoding to use when transforming the message
  Returns:
    the message contents as a string
  Throws:
    `MuleException` - if the message cannot be converted into a string

### transformMessageToString

    public String transformMessageToString()
                                    throws TransformerException

  Returns the message transformed into it's recognised or expected format and then into a String. The transformer used is the one configured on the endpoint through which this event was received. This method will use the default encoding on the event

  Specified by:
    `transformMessageToString` in interface `MuleEventContext`
  Returns:
    the message transformed into it's recognised or expected format as a Strings.
  Throws:
    `TransformerException` - if a failure occurs in the transformer
  See Also:
    `Transformer`

### getMessageAsString

    public String getMessageAsString()
                              throws MuleException

  Returns the message contents as a string This method will use the default encoding on the event

  Specified by:
    `getMessageAsString` in interface `MuleEventContext`
  Returns:
    the message contents as a string
  Throws:
    `MuleException` - if the message cannot be converted into a string

### getCurrentTransaction

    public Transaction getCurrentTransaction()

  Returns the current transaction (if any) for the session

  Specified by:
    `getCurrentTransaction` in interface `MuleEventContext`
  Returns:
    the current transaction for the session or null if there is no transaction in progress

### markTransactionForRollback

    public void markTransactionForRollback()
                                    throws TransactionException

  Description copied from interface: `MuleEventContext`
  Mark the current transaction (if any) for rollback

  Specified by:
    `markTransactionForRollback` in interface `MuleEventContext`
  Throws:
    `TransactionException` - if operation failed

### sendEvent

    public MuleMessage sendEvent(Object message)
                          throws MuleException

  This will send an event via the configured outbound router on the service

  Specified by:
    `sendEvent` in interface `MuleEventContext`
  Parameters:
    `message` - the message to send
  Returns:
    the result of the send if any
  Throws:
    `MuleException` - if there is no outbound endpoint configured on the service or the events fails during dispatch

### sendEvent

    public MuleMessage sendEvent(MuleMessage message,
                                 OutboundEndpoint endpoint)
                          throws MuleException

  Depending on the session state this methods either Passes an event synchronously to the next available Mule component in the pool or via the endpoint configured for the event

  Specified by:
    `sendEvent` in interface `MuleEventContext`
  Parameters:
    `message` - the event message payload to send
    `endpoint` - The endpoint to disptch the event through.
  Returns:
    the return Message from the call or null if there was no result
  Throws:
    `MuleException` - if the event fails to be processed by the service or the transport for the endpoint

### sendEvent

    public MuleMessage sendEvent(MuleMessage message)
                          throws MuleException

  Depending on the session state this methods either Passes an event synchronously to the next available Mule component in the pool or via the endpoint configured for the event

  Specified by:
    `sendEvent` in interface `MuleEventContext`
  Parameters:
    `message` - the message payload to send
  Returns:
    the return Message from the call or null if there was no result
  Throws:
    `MuleException` - if the event fails to be processed by the service or the transport for the endpoint

### sendEvent

    public MuleMessage sendEvent(MuleMessage message,
                                 EndpointURI endpointUri)
                          throws MuleException

  Depending on the session state this methods either Passes an event synchronously to the next available Mule component in the pool or via the endpointUri configured for the event

  Specified by:
    `sendEvent` in interface `MuleEventContext`
  Parameters:
    `message` - the event message payload to send
    `endpointUri` - The endpointUri to disptch the event through
  Returns:
    the return Message from the call or null if there was no result
  Throws:
    `MuleException` - if the event fails to be processed by the service or the transport for the endpointUri

### sendEventAsync

    public FutureMessageResult sendEventAsync(Object message,
                                              int timeout)
                                       throws MuleException

  sends an event request via the configured outbound router for this service. This method return immediately, but the result of the event invocation available from the returned a Future result that can be accessed later by the the returned FutureMessageResult. the Future messageResult can be queried at any time to check that the invocation has completed. A timeout is associated with the invocation, which is the maximum time in milli-seconds that the invocation should take to complete

  Specified by:
    `sendEventAsync` in interface `MuleEventContext`
  Parameters:
    `message` - the object that is the payload of the event
    `timeout` - how long to block in milliseconds waiting for a result
  Returns:
    the result message if any of the invocation
  Throws:
    `MuleException` - if the dispatch fails or the components or transfromers cannot be found
  See Also:
    `FutureMessageResult`

### sendEventAsync

    public FutureMessageResult sendEventAsync(MuleMessage message,
                                              int timeout)
                                       throws MuleException

  sends an event request via the configured outbound router for this service. This method return immediately, but the result of the event invocation available from the returned a Future result that can be accessed later by the the returned FutureMessageResult. the Future messageResult can be queried at any time to check that the invocation has completed. A timeout is associated with the invocation, which is the maximum time in milli-seconds that the invocation should take to complete

  Specified by:
    `sendEventAsync` in interface `MuleEventContext`
  Parameters:
    `message` - the MuleMessage of the event
    `timeout` - how long to block in milliseconds waiting for a result
  Returns:
    the result message if any of the invocation
  Throws:
    `MuleException` - if the dispatch fails or the components or transfromers cannot be found
  See Also:
    `FutureMessageResult`

### sendEventAsync

    public FutureMessageResult sendEventAsync(MuleMessage message,
                                              EndpointURI endpointUri,
                                              int timeout)
                                       throws MuleException

  sends an event request via the configured outbound router for this service. This method return immediately, but the result of the event invocation available from the returned a Future result that can be accessed later by the the returned FutureMessageResult. the Future messageResult can be queried at any time to check that the invocation has completed. A timeout is associated with the invocation, which is the maximum time in milli-seconds that the invocation should take to complete

  Specified by:
    `sendEventAsync` in interface `MuleEventContext`
  Parameters:
    `message` - the MuleMessage of the event
    `endpointUri` - the endpointUri to dispatch to
    `timeout` - how long to block in milliseconds waiting for a result
  Returns:
    the result message if any of the invocation
  Throws:
    `MuleException` - if the dispatch fails or the components or transfromers cannot be found
  See Also:
    `FutureMessageResult`

### sendEventAsync

    public FutureMessageResult sendEventAsync(MuleMessage message,
                                              String endpointName,
                                              int timeout)
                                       throws MuleException

  sends an event request via the configured outbound router for this service. This method return immediately, but the result of the event invocation available from the returned a Future result that can be accessed later by the the returned FutureMessageResult. the Future messageResult can be queried at any time to check that the invocation has completed. A timeout is associated with the invocation, which is the maximum time in milli-seconds that the invocation should take to complete

  Specified by:
    `sendEventAsync` in interface `MuleEventContext`
  Parameters:
    `message` - the MuleMessage of the event
    `endpointName` - The endpoint name to disptch the event through. This will be looked up first on the service configuration and then on the mule manager configuration
    `timeout` - how long to block in milliseconds waiting for a result
  Returns:
    the result message if any of the invocation
  Throws:
    `MuleException` - if the dispatch fails or the components or transfromers cannot be found
  See Also:
    `FutureMessageResult`

### sendEvent

    public MuleMessage sendEvent(MuleMessage message,
                                 String endpointName)
                          throws MuleException

  Depending on the session state this methods either Passes an event synchronously to the next available Mule component in the pool or via the endpoint configured for the event

  Specified by:
    `sendEvent` in interface `MuleEventContext`
  Parameters:
    `message` - the event message payload to send
    `endpointName` - The endpoint name to disptch the event through. This will be looked up first on the service configuration and then on the mule manager configuration
  Returns:
    the return Message from the call or null if there was no result
  Throws:
    `MuleException` - if the event fails to be processed by the service or the transport for the endpoint

### dispatchEvent

    public void dispatchEvent(Object message)
                       throws MuleException

  This will dispatch an event asynchronously via the configured outbound endpoint on the service for this session

  Specified by:
    `dispatchEvent` in interface `MuleEventContext`
  Parameters:
    `message` - payload to dispatch
  Throws:
    `MuleException` - if there is no outbound endpoint configured on the service or the events fails during dispatch

### dispatchEvent

    public void dispatchEvent(MuleMessage message)
                       throws MuleException

  This will dispatch an event asynchronously via the configured outbound endpoint on the service for this session

  Specified by:
    `dispatchEvent` in interface `MuleEventContext`
  Parameters:
    `message` - the message to send
  Throws:
    `MuleException` - if there is no outbound endpoint configured on the service or the events fails during dispatch

### dispatchEvent

    public void dispatchEvent(MuleMessage message,
                              EndpointURI endpointUri)
                       throws MuleException

  Depending on the session state this methods either Passes an event asynchronously to the next available Mule component in the pool or via the endpointUri configured for the event

  Specified by:
    `dispatchEvent` in interface `MuleEventContext`
  Parameters:
    `message` - the event message payload to send
    `endpointUri` - the endpointUri to dispatc the event to first on the service configuration and then on the mule manager configuration
  Throws:
    `MuleException` - if the event fails to be processed by the service or the transport for the endpointUri

### dispatchEvent

    public void dispatchEvent(MuleMessage message,
                              String endpointName)
                       throws MuleException

  Depending on the session state this methods either Passes an event asynchronously to the next available Mule component in the pool or via the endpoint configured for the event

  Specified by:
    `dispatchEvent` in interface `MuleEventContext`
  Parameters:
    `message` - the event message payload to send
    `endpointName` - The endpoint name to disptch the event through. This will be looked up first on the service configuration and then on the mule manager configuration
  Throws:
    `MuleException` - if the event fails to be processed by the service or the transport for the endpoint

### dispatchEvent

    public void dispatchEvent(MuleMessage message,
                              OutboundEndpoint endpoint)
                       throws MuleException

  Depending on the session state this methods either Passes an event asynchronously to the next available Mule component in the pool or via the endpoint configured for the event

  Specified by:
    `dispatchEvent` in interface `MuleEventContext`
  Parameters:
    `message` - the event message payload to send
    `endpoint` - The endpoint name to disptch the event through.
  Throws:
    `MuleException` - if the event fails to be processed by the service or the transport for the endpoint

### requestEvent

    public MuleMessage requestEvent(InboundEndpoint endpoint,
                                    long timeout)
                             throws MuleException

  Requests a synchronous receive of an event on the service

  Specified by:
    `requestEvent` in interface `MuleEventContext`
  Parameters:
    `endpoint` - the endpoint identifing the endpointUri on ewhich the event will be received
    `timeout` - time in milliseconds before the request timesout
  Returns:
    The requested event or null if the request times out
  Throws:
    `MuleException` - if the request operation fails

### requestEvent

    public MuleMessage requestEvent(String endpointName,
                                    long timeout)
                             throws MuleException

  Requests a synchronous receive of an event on the service

  Specified by:
    `requestEvent` in interface `MuleEventContext`
  Parameters:
    `endpointName` - the endpoint identifing the endpointUri on ewhich the event will be received
    `timeout` - time in milliseconds before the request timesout
  Returns:
    The requested event or null if the request times out
  Throws:
    `MuleException` - if the request operation fails

### requestEvent

    public MuleMessage requestEvent(EndpointURI endpointUri,
                                    long timeout)
                             throws MuleException

  Requests a synchronous receive of an event on the service

  Specified by:
    `requestEvent` in interface `MuleEventContext`
  Parameters:
    `endpointUri` - the endpointUri on which the event will be received
    `timeout` - time in milliseconds before the request timesout
  Returns:
    The requested event or null if the request times out
  Throws:
    `MuleException` - if the request operation fails

### getFlowConstruct

    public FlowConstruct getFlowConstruct()

  Specified by:
    `getFlowConstruct` in interface `MuleEventContext`
  Returns:
    the service descriptor of the service that received this event

### isStopFurtherProcessing

    public boolean isStopFurtherProcessing()

  Determines whether the default processing for this event will be executed. By default, the Mule server will route events according to a components configuration. The user can override this behaviour by obtaining a reference to the MuleEvent context, either by implementing `org.mule.api.lifecycle.Callable` or calling `RequestContext.getEventContext` to obtain the MuleEventContext for the current thread. The user can programmatically control how events are dispatched.

  Specified by:
    `isStopFurtherProcessing` in interface `MuleEventContext`
  Returns:
    Returns true is the user has set stopFurtherProcessing.
  See Also:
    `MuleEventContext`, `Callable`

### setStopFurtherProcessing

    public void setStopFurtherProcessing(boolean stopFurtherProcessing)

  Determines whether the default processing for this event will be executed. By default, the Mule server will route events according to a components configuration. The user can override this behaviour by obtaining a reference to the MuleEvent context, either by implementing `org.mule.api.lifecycle.Callable` or calling `RequestContext.getEventContext` to obtain the MuleEventContext for the current thread. The user can programmatically control how events are dispached.

  Specified by:
    `setStopFurtherProcessing` in interface `MuleEventContext`
  Parameters:
    `stopFurtherProcessing` - the value to set.

### getOutputStream

    public OutputStream getOutputStream()

  An outputstream the can optionally be used write response data to an incoming message.

  Specified by:
    `getOutputStream` in interface `MuleEventContext`
  Returns:
    an output stream if one has been made available by the message receiver that received the message

### getEndpointURI

    public EndpointURI getEndpointURI()

  Description copied from interface: `MuleEventContext`
  Returns a reference to the Endpoint Uri for this context This is the endpoint on which the event was received

  Specified by:
    `getEndpointURI` in interface `MuleEventContext`
  Returns:
    the receive endpoint for this event context

### getExchangePattern

    public MessageExchangePattern getExchangePattern()

  Specified by:
    `getExchangePattern` in interface `MuleEventContext`

### getTransaction

    public Transaction getTransaction()

  Returns the transaction for the current event or null if there is no transaction in progresss

  Specified by:
    `getTransaction` in interface `MuleEventContext`
  Returns:
    the transaction for the current event or null if there is no transaction in progresss

### getTimeout

    public int getTimeout()

  Get the timeout value associated with the event

  Specified by:
    `getTimeout` in interface `MuleEventContext`
  Returns:
    the timeout for the event

### getEncoding

    public String getEncoding()

  Gets the encoding for the current message. For potocols that send encoding Information with the message, this method should be overriden to expose the transport encoding, otherwise the default encoding in the Mule configuration will be used

  Specified by:
    `getEncoding` in interface `MuleEventContext`
  Returns:
    the encoding for this message. This method must never return null

### getSession

    public MuleSession getSession()

  Specified by:
    `getSession` in interface `MuleEventContext`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### getMuleContext

    public MuleContext getMuleContext()

  Specified by:
    `getMuleContext` in interface `MuleEventContext`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.