org.mule.api
Interface MuleEvent

All Superinterfaces:
Serializable
All Known Implementing Classes:
DefaultMuleEvent, VoidMuleEvent

public interface MuleEvent
extends Serializable

MuleEvent represents any data event occuring in the Mule environment. All data sent or received within the mule environment will be passed between components as an MuleEvent.

The MuleEvent holds a MuleMessage payload and provides helper methods for obtaining the data in a format that the receiving Mule component understands. The event can also maintain any number of properties that can be set and retrieved by Mule components.

See Also:
MuleMessage

Field Summary
static int TIMEOUT_DO_NOT_WAIT
           
static int TIMEOUT_NOT_SET_VALUE
           
static int TIMEOUT_WAIT_FOREVER
           
 
Method Summary
 void captureReplyToDestination()
          Set the reply-to destination from the current message, and remove it from the message, to prevent any further propagation.
 void clearFlowVariables()
           
 void clearSessionVariables()
           
 Credentials getCredentials()
           
 String getEncoding()
          Gets the encoding for this message.
 MessageExchangePattern getExchangePattern()
          Returns the message exchange pattern for this event
 FlowConstruct getFlowConstruct()
          Retrieves the service for the current event
<T> T
getFlowVariable(String key)
           
 Set<String> getFlowVariableNames()
           
 String getId()
          Every event in the system is assigned a universally unique id (UUID).
 MuleMessage getMessage()
          Returns the message payload for this event
 byte[] getMessageAsBytes()
          Returns the contents of the message as a byte array.
 String getMessageAsString()
          Returns the message contents as a string If necessary this will use the encoding set on the event
 String getMessageAsString(String encoding)
          Returns the message contents as a string
 String getMessageSourceName()
          Returns the message source name if it has one, otherwise returns toString() of the URI returned be getMessageSourceURI()
 URI getMessageSourceURI()
          Returns the URI of the MessageSource that recieved or generated the message being processed.
 MuleContext getMuleContext()
          Returns the muleContext for the Mule node that this event was received in
 OutputStream getOutputStream()
          An outputstream the can optionally be used write response data to an incoming message.
 ProcessingTime getProcessingTime()
          Returns the times spent processing this event (so far)
 Object getProperty(String name)
          Deprecated.  
 Object getProperty(String name, Object defaultValue)
          Deprecated.  
 Object getReplyToDestination()
          Return the destination (if any) that will be passed to the reply-to handler.
 ReplyToHandler getReplyToHandler()
          Return the replyToHandler (if any) that will be used to perform async reply
 MuleSession getSession()
          Retrieves the service session for the current event
<T> T
getSessionVariable(String key)
           
 Set<String> getSessionVariableNames()
           
 int getTimeout()
          The number of milliseconds to wait for a return event when running synchronously.
 boolean isStopFurtherProcessing()
          Determines whether the default processing for this event will be executed.
 boolean isSynchronous()
           
 boolean isTransacted()
          Returns true is this event is being processed in a transaction
 void removeFlowVariable(String key)
           
 void removeSessionVariable(String key)
           
 void setFlowVariable(String key, Object value)
           
 void setMessage(MuleMessage message)
           
 void setSessionVariable(String key, Object value)
           
 void setStopFurtherProcessing(boolean stopFurtherProcessing)
          Determines whether the default processing for this event will be executed.
 void setTimeout(int timeout)
          The number of milliseconds to wait for a return event when running synchronously.
 Object transformMessage()
          Deprecated. Since Mule 3.0 this method does nothing. The message is already transformed before the event reaches a component IF you need to have access to the original message, the must be no transformations before the component, this means that any 'connector-level' transfromers will have to be explicitly overriden via the service overrides on the connector.
<T> T
transformMessage(Class<T> outputType)
          Transforms the message into the requested format.
<T> T
transformMessage(DataType<T> outputType)
          Transforms the message into the requested 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.
 

Field Detail

TIMEOUT_WAIT_FOREVER

static final int TIMEOUT_WAIT_FOREVER
See Also:
Constant Field Values

TIMEOUT_DO_NOT_WAIT

static final int TIMEOUT_DO_NOT_WAIT
See Also:
Constant Field Values

TIMEOUT_NOT_SET_VALUE

static final int TIMEOUT_NOT_SET_VALUE
See Also:
Constant Field Values
Method Detail

getMessage

MuleMessage getMessage()
Returns the message payload for this event

Returns:
the message payload for this event

getCredentials

Credentials getCredentials()

getMessageAsBytes

byte[] getMessageAsBytes()
                         throws MuleException
Returns the contents of the message as a byte array.

Returns:
the contents of the message as a byte array
Throws:
MuleException - if the message cannot be converted into an array of bytes

transformMessage

@Deprecated
Object transformMessage()
                        throws TransformerException
Deprecated. Since Mule 3.0 this method does nothing. The message is already transformed before the event reaches a component IF you need to have access to the original message, the must be no transformations before the component, this means that any 'connector-level' transfromers will have to be explicitly overriden via the service overrides on the connector.

Transforms the message into it's recognised or expected format. The transformer used is the one configured on the endpoint through which this event was received.

Returns:
the message transformed into it's recognised or expected format.
Throws:
TransformerException - if a failure occurs in the transformer
See Also:
Transformer

transformMessage

<T> T transformMessage(Class<T> outputType)
                   throws TransformerException
Transforms the message into the requested format. The transformer used is the one configured on the endpoint through which this event was received.

Parameters:
outputType - The requested output type.
Returns:
the message transformed into it's recognised or expected format.
Throws:
TransformerException - if a failure occurs in the transformer
See Also:
if the transform fails or the outputtype is null

transformMessage

<T> T transformMessage(DataType<T> outputType)
                   throws TransformerException
Transforms the message into the requested format. The transformer used is the one configured on the endpoint through which this event was received.

Parameters:
outputType - The requested output type.
Returns:
the message transformed into it's recognised or expected format.
Throws:
TransformerException - if a failure occurs in the transformer
See Also:
if the transform fails or the outputtype is null

transformMessageToBytes

@Deprecated
byte[] transformMessageToBytes()
                               throws TransformerException
Deprecated. use transformMessage(org.mule.api.transformer.DataType) instead

Transforms the message 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.

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

transformMessageToString

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. If necessary this will use the encoding set on the event

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

String getMessageAsString()
                          throws MuleException
Returns the message contents as a string If necessary this will use the encoding set on the event

Returns:
the message contents as a string
Throws:
MuleException - if the message cannot be converted into a string

getMessageAsString

String getMessageAsString(String encoding)
                          throws MuleException
Returns the message contents as a string

Parameters:
encoding - the encoding to use when converting the message to string
Returns:
the message contents as a string
Throws:
MuleException - if the message cannot be converted into a string

getId

String getId()
Every event in the system is assigned a universally unique id (UUID).

Returns:
the unique identifier for the event

getProperty

@Deprecated
Object getProperty(String name)
Deprecated. 

Gets a property associated with the current event. This method will check all property scopes on the currnet message and the current session

Parameters:
name - the property name
Returns:
the property value or null if the property does not exist

getProperty

@Deprecated
Object getProperty(String name,
                              Object defaultValue)
Deprecated. 

Gets a property associated with the current event. This method will check all property scopes on the currnet message and the current session

Parameters:
name - the property name
defaultValue - a default value if the property doesn't exist in the event
Returns:
the property value or the defaultValue if the property does not exist

getSession

MuleSession getSession()
Retrieves the service session for the current event

Returns:
the service session for the event

getFlowConstruct

FlowConstruct getFlowConstruct()
Retrieves the service for the current event

Returns:
the service for the event

isStopFurtherProcessing

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 dispached.

Returns:
Returns true is the user has set stopFurtherProcessing.
See Also:
MuleContext, MuleEventContext, Callable

setStopFurtherProcessing

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.

Parameters:
stopFurtherProcessing - the value to set.

getTimeout

int getTimeout()
The number of milliseconds to wait for a return event when running synchronously. 0 wait forever -1 try and receive, but do not wait or a positive millisecond value

Returns:
the event timeout in milliseconds

setTimeout

void setTimeout(int timeout)
The number of milliseconds to wait for a return event when running synchronously. 0 wait forever -1 try and receive, but do not wait or a positive millisecod value

Parameters:
timeout - the event timeout in milliseconds

getOutputStream

OutputStream getOutputStream()
An outputstream the can optionally be used write response data to an incoming message.

Returns:
an output strem if one has been made available by the message receiver that received the message

getEncoding

String getEncoding()
Gets the encoding for this message.

Returns:
the encoding for the event. This must never return null.

getMuleContext

MuleContext getMuleContext()
Returns the muleContext for the Mule node that this event was received in

Returns:
the muleContext for the Mule node that this event was received in

getProcessingTime

ProcessingTime getProcessingTime()
Returns the times spent processing this event (so far)


getExchangePattern

MessageExchangePattern getExchangePattern()
Returns the message exchange pattern for this event


isTransacted

boolean isTransacted()
Returns true is this event is being processed in a transaction


getMessageSourceURI

URI getMessageSourceURI()
Returns the URI of the MessageSource that recieved or generated the message being processed.


getMessageSourceName

String getMessageSourceName()
Returns the message source name if it has one, otherwise returns toString() of the URI returned be getMessageSourceURI()


getReplyToHandler

ReplyToHandler getReplyToHandler()
Return the replyToHandler (if any) that will be used to perform async reply


getReplyToDestination

Object getReplyToDestination()
Return the destination (if any) that will be passed to the reply-to handler.


captureReplyToDestination

void captureReplyToDestination()
Set the reply-to destination from the current message, and remove it from the message, to prevent any further propagation.


isSynchronous

boolean isSynchronous()

setMessage

void setMessage(MuleMessage message)

getFlowVariable

<T> T getFlowVariable(String key)

setFlowVariable

void setFlowVariable(String key,
                     Object value)

removeFlowVariable

void removeFlowVariable(String key)

getFlowVariableNames

Set<String> getFlowVariableNames()

clearFlowVariables

void clearFlowVariables()

getSessionVariable

<T> T getSessionVariable(String key)

setSessionVariable

void setSessionVariable(String key,
                        Object value)

removeSessionVariable

void removeSessionVariable(String key)

getSessionVariableNames

Set<String> getSessionVariableNames()

clearSessionVariables

void clearSessionVariables()


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