org.mule.impl
Class MuleEventContext

java.lang.Object
  extended byorg.mule.impl.MuleEventContext
All Implemented Interfaces:
UMOEventContext

public class MuleEventContext
extends java.lang.Object
implements UMOEventContext

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

Version:
$Revision: 1.7 $
Author:
Ross Mason

Field Summary
protected static Log logger
          logger used by this class
 
Method Summary
 void dispatchEvent(java.lang.Object message)
          This will dispatch an event asynchronously via the configured outbound endpoint on the component for this session
 void dispatchEvent(UMOMessage message)
          This will dispatch an event asynchronously via the configured outbound endpoint on the component for this session
 void dispatchEvent(UMOMessage message, java.lang.String endpointName)
          Depending on the session state this methods either Passes an event asynchronously to the next available Mule UMO in the pool or via the endpoint configured for the event
 void dispatchEvent(UMOMessage message, UMOEndpoint endpoint)
          Depending on the session state this methods either Passes an event asynchronously to the next available Mule UMO in the pool or via the endpoint configured for the event
 void dispatchEvent(UMOMessage message, UMOEndpointURI endpointUri)
          Depending on the session state this methods either Passes an event asynchronously to the next available Mule UMO in the pool or via the endpointUri configured for the event
 boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
          Gets a Boolean property associated with the current event.
 UMODescriptor getComponentDescriptor()
           
 UMOTransaction getCurrentTransaction()
          Returns the current transaction (if any) for the session
 double getDoubleProperty(java.lang.String name, double defaultValue)
          Gets a Double property associated with the current event.
 UMOEndpointURI getEndpointURI()
          Returns a reference to the Endpoint Uri for this context This is the endpoint on which the event was received
 int getIntProperty(java.lang.String name, int defaultValue)
          Gets an Integer property associated with the current event.
 long getLongProperty(java.lang.String name, long defaultValue)
          Gets a Long property associated with the current event.
 UMOMessage getMessage()
          Returns the message payload for this event
 byte[] getMessageAsBytes()
          Reterns the conents of the message as a byte array.
 java.lang.String getMessageAsString()
          Returns the message contents as a string
 java.io.OutputStream getOutputStream()
          An outputstream the can optionally be used write response data to an incoming message.
 java.util.Map getProperties()
          Returns a map of properties associated with the event
 java.lang.Object getProperty(java.lang.String name)
          Gets a property associated with the current event.
 java.lang.Object getProperty(java.lang.String name, java.lang.Object defaultValue)
          Gets a property associated with the current event.
 UMOTransaction getTransaction()
          Returns the transaction for the current event or null if there is no transaction in progresss
 java.lang.Object getTransformedMessage()
          Returns the message transformed into it's recognised or expected format.
 byte[] getTransformedMessageAsBytes()
          Returns the message transformed into it's recognised or expected format and then into an array of bytes.
 java.lang.String getTransformedMessageAsString()
          Returns the message transformed into it's recognised or expected format and then into a String.
 boolean isStopFurtherProcessing()
          Determines whether the default processing for this event will be executed.
 boolean isSynchronous()
          Determines whether the was sent synchrounously or not
 void markTransactionForRollback()
          Mark the current transaction (if any) for rollback
 UMOMessage receiveEvent(java.lang.String endpointName, long timeout)
          Requests a synchronous receive of an event on the component
 UMOMessage receiveEvent(UMOEndpoint endpoint, long timeout)
          Requests a synchronous receive of an event on the component
 UMOMessage receiveEvent(UMOEndpointURI endpointUri, long timeout)
          Requests a synchronous receive of an event on the component
 UMOMessage sendEvent(java.lang.Object message)
          This will send an event via the configured outbound router on the component
 UMOMessage sendEvent(UMOMessage message)
          Depending on the session state this methods either Passes an event synchronously to the next available Mule UMO in the pool or via the endpoint configured for the event
 UMOMessage sendEvent(UMOMessage message, java.lang.String endpointName)
          Depending on the session state this methods either Passes an event synchronously to the next available Mule UMO in the pool or via the endpoint configured for the event
 UMOMessage sendEvent(UMOMessage message, UMOEndpoint endpoint)
          Depending on the session state this methods either Passes an event synchronously to the next available Mule UMO in the pool or via the endpoint configured for the event
 UMOMessage sendEvent(UMOMessage message, UMOEndpointURI endpointUri)
          Depending on the session state this methods either Passes an event synchronously to the next available Mule UMO in the pool or via the endpointUri configured for the event
 FutureMessageResult sendEventAsync(java.lang.Object message, int timeout)
          sends an event request via the configured outbound router for this component.
 FutureMessageResult sendEventAsync(UMOMessage message, int timeout)
          sends an event request via the configured outbound router for this component.
 FutureMessageResult sendEventAsync(UMOMessage message, java.lang.String endpointName, int timeout)
          sends an event request via the configured outbound router for this component.
 FutureMessageResult sendEventAsync(UMOMessage message, UMOEndpointURI endpointUri, int timeout)
          sends an event request via the configured outbound router for this component.
 void setBooleanProperty(java.lang.String name, boolean value)
          Sets a Boolean property associated with the current event.
 void setDoubleProperty(java.lang.String name, double value)
          Sets a Double property associated with the current event.
 void setIntProperty(java.lang.String name, int value)
          Sets an Integer property associated with the current event.
 void setLongProperty(java.lang.String name, long value)
          Sets a Long property associated with the current event.
 void setProperty(java.lang.String name, java.lang.Object value)
          Sets a property associated with the current event.
 void setStopFurtherProcessing(boolean stopFurtherProcessing)
          Determines whether the default processing for this event will be executed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static transient Log logger
logger used by this class

Method Detail

getMessage

public UMOMessage getMessage()
Returns the message payload for this event

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

getMessageAsBytes

public byte[] getMessageAsBytes()
                         throws UMOException
Reterns the conents of the message as a byte array.

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

getTransformedMessage

public java.lang.Object getTransformedMessage()
                                       throws TransformerException
Returns the message transformed into it's recognised or expected format. The transformer used is the one configured on the endpoint through which this event was received.

Specified by:
getTransformedMessage in interface UMOEventContext
Returns:
the message transformed into it's recognised or expected format.
Throws:
TransformerException - if a failure occurs in the transformer
See Also:
UMOTransformer

getTransformedMessageAsBytes

public byte[] getTransformedMessageAsBytes()
                                    throws TransformerException
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:
getTransformedMessageAsBytes in interface UMOEventContext
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:
UMOTransformer

getTransformedMessageAsString

public java.lang.String getTransformedMessageAsString()
                                               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.

Specified by:
getTransformedMessageAsString in interface UMOEventContext
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:
UMOTransformer

getMessageAsString

public java.lang.String getMessageAsString()
                                    throws UMOException
Returns the message contents as a string

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

getCurrentTransaction

public UMOTransaction getCurrentTransaction()
Returns the current transaction (if any) for the session

Specified by:
getCurrentTransaction in interface UMOEventContext
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: UMOEventContext
Mark the current transaction (if any) for rollback

Specified by:
markTransactionForRollback in interface UMOEventContext
Throws:
TransactionException

sendEvent

public UMOMessage sendEvent(java.lang.Object message)
                     throws UMOException
This will send an event via the configured outbound router on the component

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

sendEvent

public UMOMessage sendEvent(UMOMessage message,
                            UMOEndpoint endpoint)
                     throws UMOException
Depending on the session state this methods either Passes an event synchronously to the next available Mule UMO in the pool or via the endpoint configured for the event

Specified by:
sendEvent in interface UMOEventContext
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:
UMOException - if the event fails to be processed by the component or the transport for the endpoint

sendEvent

public UMOMessage sendEvent(UMOMessage message)
                     throws UMOException
Depending on the session state this methods either Passes an event synchronously to the next available Mule UMO in the pool or via the endpoint configured for the event

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

sendEvent

public UMOMessage sendEvent(UMOMessage message,
                            UMOEndpointURI endpointUri)
                     throws UMOException
Depending on the session state this methods either Passes an event synchronously to the next available Mule UMO in the pool or via the endpointUri configured for the event

Specified by:
sendEvent in interface UMOEventContext
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:
UMOException - if the event fails to be processed by the component or the transport for the endpointUri

sendEventAsync

public FutureMessageResult sendEventAsync(java.lang.Object message,
                                          int timeout)
                                   throws UMOException
sends an event request via the configured outbound router for this component. 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 UMOEventContext
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:
UMOException - if the dispatch fails or the components or transfromers cannot be found
See Also:
FutureMessageResult

sendEventAsync

public FutureMessageResult sendEventAsync(UMOMessage message,
                                          int timeout)
                                   throws UMOException
sends an event request via the configured outbound router for this component. 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 UMOEventContext
Parameters:
message - the UMOMessage of the event
timeout - how long to block in milliseconds waiting for a result
Returns:
the result message if any of the invocation
Throws:
UMOException - if the dispatch fails or the components or transfromers cannot be found
See Also:
FutureMessageResult

sendEventAsync

public FutureMessageResult sendEventAsync(UMOMessage message,
                                          UMOEndpointURI endpointUri,
                                          int timeout)
                                   throws UMOException
sends an event request via the configured outbound router for this component. 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 UMOEventContext
Parameters:
message - the UMOMessage 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:
UMOException - if the dispatch fails or the components or transfromers cannot be found
See Also:
FutureMessageResult

sendEventAsync

public FutureMessageResult sendEventAsync(UMOMessage message,
                                          java.lang.String endpointName,
                                          int timeout)
                                   throws UMOException
sends an event request via the configured outbound router for this component. 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 UMOEventContext
Parameters:
message - the UMOMessage of the event
endpointName - The endpoint name to disptch the event through. This will be looked up first on the component 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:
UMOException - if the dispatch fails or the components or transfromers cannot be found
See Also:
FutureMessageResult

sendEvent

public UMOMessage sendEvent(UMOMessage message,
                            java.lang.String endpointName)
                     throws UMOException
Depending on the session state this methods either Passes an event synchronously to the next available Mule UMO in the pool or via the endpoint configured for the event

Specified by:
sendEvent in interface UMOEventContext
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 component configuration and then on the mule manager configuration
Returns:
the return Message from the call or null if there was no result
Throws:
UMOException - if the event fails to be processed by the component or the transport for the endpoint

dispatchEvent

public void dispatchEvent(java.lang.Object message)
                   throws UMOException
This will dispatch an event asynchronously via the configured outbound endpoint on the component for this session

Specified by:
dispatchEvent in interface UMOEventContext
Parameters:
message - payload to dispatch
Throws:
UMOException - if there is no outbound endpoint configured on the component or the events fails during dispatch

dispatchEvent

public void dispatchEvent(UMOMessage message)
                   throws UMOException
This will dispatch an event asynchronously via the configured outbound endpoint on the component for this session

Specified by:
dispatchEvent in interface UMOEventContext
Parameters:
message - the message to send
Throws:
UMOException - if there is no outbound endpoint configured on the component or the events fails during dispatch

dispatchEvent

public void dispatchEvent(UMOMessage message,
                          UMOEndpointURI endpointUri)
                   throws UMOException
Depending on the session state this methods either Passes an event asynchronously to the next available Mule UMO in the pool or via the endpointUri configured for the event

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

dispatchEvent

public void dispatchEvent(UMOMessage message,
                          java.lang.String endpointName)
                   throws UMOException
Depending on the session state this methods either Passes an event asynchronously to the next available Mule UMO in the pool or via the endpoint configured for the event

Specified by:
dispatchEvent in interface UMOEventContext
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 component configuration and then on the mule manager configuration
Throws:
UMOException - if the event fails to be processed by the component or the transport for the endpoint

dispatchEvent

public void dispatchEvent(UMOMessage message,
                          UMOEndpoint endpoint)
                   throws UMOException
Depending on the session state this methods either Passes an event asynchronously to the next available Mule UMO in the pool or via the endpoint configured for the event

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

receiveEvent

public UMOMessage receiveEvent(UMOEndpoint endpoint,
                               long timeout)
                        throws UMOException
Requests a synchronous receive of an event on the component

Specified by:
receiveEvent in interface UMOEventContext
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:
UMOException - if the request operation fails

receiveEvent

public UMOMessage receiveEvent(java.lang.String endpointName,
                               long timeout)
                        throws UMOException
Requests a synchronous receive of an event on the component

Specified by:
receiveEvent in interface UMOEventContext
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:
UMOException - if the request operation fails

receiveEvent

public UMOMessage receiveEvent(UMOEndpointURI endpointUri,
                               long timeout)
                        throws UMOException
Requests a synchronous receive of an event on the component

Specified by:
receiveEvent in interface UMOEventContext
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:
UMOException - if the request operation fails

getComponentDescriptor

public UMODescriptor getComponentDescriptor()
Specified by:
getComponentDescriptor in interface UMOEventContext
Returns:

getProperty

public java.lang.Object getProperty(java.lang.String name)
Gets a property associated with the current event. Calling this method is equivilent to calling event.getMessage().getProperty(...)

Specified by:
getProperty in interface UMOEventContext
Parameters:
name - the property name
Returns:
the property value or null if the property does not exist

getProperty

public java.lang.Object getProperty(java.lang.String name,
                                    java.lang.Object defaultValue)
Gets a property associated with the current event. Calling this method is equivilent to calling event.getMessage().getProperty(..., ...)

Specified by:
getProperty in interface UMOEventContext
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

getIntProperty

public int getIntProperty(java.lang.String name,
                          int defaultValue)
Gets an Integer property associated with the current event. Calling this method is equivilent to calling event.getMessage().getIntProperty(..., ...)

Specified by:
getIntProperty in interface UMOEventContext
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

getLongProperty

public long getLongProperty(java.lang.String name,
                            long defaultValue)
Gets a Long property associated with the current event. Calling this method is equivilent to calling event.getMessage().getLongProperty(..., ...)

Specified by:
getLongProperty in interface UMOEventContext
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

getDoubleProperty

public double getDoubleProperty(java.lang.String name,
                                double defaultValue)
Gets a Double property associated with the current event. Calling this method is equivilent to calling event.getMessage().getDoubleProperty(..., ...)

Specified by:
getDoubleProperty in interface UMOEventContext
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

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name,
                                  boolean defaultValue)
Gets a Boolean property associated with the current event. Calling this method is equivilent to calling event.getMessage().getbooleanProperty(..., ...)

Specified by:
getBooleanProperty in interface UMOEventContext
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

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Sets a property associated with the current event. Calling this method is equivilent to calling event.getMessage().setProperty(..., ...)

Specified by:
setProperty in interface UMOEventContext
Parameters:
name - the property name or key
value - the property value

setBooleanProperty

public void setBooleanProperty(java.lang.String name,
                               boolean value)
Sets a Boolean property associated with the current event. Calling this method is equivilent to calling event.getMessage().setBooleanProperty(..., ...)

Specified by:
setBooleanProperty in interface UMOEventContext
Parameters:
name - the property name or key
value - the property value

setIntProperty

public void setIntProperty(java.lang.String name,
                           int value)
Sets an Integer property associated with the current event. Calling this method is equivilent to calling event.getMessage().setIntProperty(..., ...)

Specified by:
setIntProperty in interface UMOEventContext
Parameters:
name - the property name or key
value - the property value

setLongProperty

public void setLongProperty(java.lang.String name,
                            long value)
Sets a Long property associated with the current event. Calling this method is equivilent to calling event.getMessage().setLongProperty(..., ...)

Specified by:
setLongProperty in interface UMOEventContext
Parameters:
name - the property name or key
value - the property value

setDoubleProperty

public void setDoubleProperty(java.lang.String name,
                              double value)
Sets a Double property associated with the current event. Calling this method is equivilent to calling event.getMessage().setDoubleProperty(..., ...)

Specified by:
setDoubleProperty in interface UMOEventContext
Parameters:
name - the property name or key
value - the property value

getProperties

public java.util.Map getProperties()
Returns a map of properties associated with the event

Specified by:
getProperties in interface UMOEventContext
Returns:
a map of properties on the 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 Event context, either by implementing org.mule.umo.lifecycle.Callable or calling UMOManager.getEventContext to obtain the UMOEventContext for the current thread. The user can programmatically control how events are dispached.

Specified by:
isStopFurtherProcessing in interface UMOEventContext
Returns:
Returns true is the user has set stopFurtherProcessing.
See Also:
UMOManager, UMOEventContext, 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 Event context, either by implementing org.mule.umo.lifecycle.Callable or calling UMOManager.getEventContext to obtain the UMOEventContext for the current thread. The user can programmatically control how events are dispached.

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

getOutputStream

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

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

isSynchronous

public boolean isSynchronous()
Determines whether the was sent synchrounously or not

Specified by:
isSynchronous in interface UMOEventContext
Returns:
true if the event is synchronous

getEndpointURI

public UMOEndpointURI getEndpointURI()
Description copied from interface: UMOEventContext
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 UMOEventContext
Returns:
the receive endpoint for this event context

getTransaction

public UMOTransaction getTransaction()
Returns the transaction for the current event or null if there is no transaction in progresss

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


Copyright © 2003-2005 SymphonySoft Limited. All Rights Reserved.