org.mule.impl
Class MuleEvent

java.lang.Object
  extended byjava.util.EventObject
      extended byorg.mule.impl.MuleEvent
All Implemented Interfaces:
Serializable, UMOEvent

public class MuleEvent
extends EventObject
implements UMOEvent

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

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

See Also:
Serialized Form

Field Summary
protected  String[] ignoredPropertyOverrides
           
protected  Log logger
          logger used by this class
 
Fields inherited from class java.util.EventObject
source
 
Fields inherited from interface org.mule.umo.UMOEvent
TIMEOUT_DO_NOT_WAIT, TIMEOUT_NOT_SET_VALUE, TIMEOUT_WAIT_FOREVER
 
Constructor Summary
MuleEvent(UMOMessage message, UMOEvent rewriteEvent)
          A helper constructor used to rewrite an event payload
MuleEvent(UMOMessage message, UMOImmutableEndpoint endpoint, UMOComponent component, UMOEvent previousEvent)
          Properties cache that only reads properties once from the inbound message and merges them with any properties on the endpoint.
MuleEvent(UMOMessage message, UMOImmutableEndpoint endpoint, UMOSession session, boolean synchronous)
           
MuleEvent(UMOMessage message, UMOImmutableEndpoint endpoint, UMOSession session, boolean synchronous, ResponseOutputStream outputStream)
          Contructor.
MuleEvent(UMOMessage message, UMOImmutableEndpoint endpoint, UMOSession session, String eventId, boolean synchronous)
          Contructor.
 
Method Summary
 boolean equals(Object o)
           
protected  void fillProperties(UMOEvent previousEvent)
           
protected  String generateEventId()
           
 boolean getBooleanProperty(String name, boolean defaultValue)
          Gets a boolean property on the nessage
 UMOComponent getComponent()
          Gets the recipient component of this event
 UMOCredentials getCredentials()
           
 double getDoubleProperty(String name, double defaultValue)
          Gets a double property on the nessage
 String getEncoding()
          Gets the encoding for this message.
 UMOImmutableEndpoint getEndpoint()
          Gets the endpoint associated with this event
 String getId()
          Every event in the system is assigned a universally unique id (UUID).
 int getIntProperty(String name, int defaultValue)
          Gets an int property on the nessage
 long getLongProperty(String name, long defaultValue)
          Gets a long property on the nessage
 UMOMessage 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 If necessary this will use the encoding set on the event
 String getMessageAsString(String encoding)
          Returns the message contents as a string
 OutputStream getOutputStream()
          An outputstream the can optionally be used write response data to an incoming message.
 Object getProperty(String name)
          Gets a property associated with the current event.
 Object getProperty(String name, boolean exhaustiveSearch)
          Gets a property associated with the current event.
 Object getProperty(String name, Object defaultValue)
          Gets a property associated with the current event.
 Object getProperty(String name, Object defaultValue, boolean exhaustiveSearch)
          Gets a property associated with the current event.
 UMOSession getSession()
          Retrieves the component session for the current event
 String getStringProperty(String name, String defaultValue)
          Will retrieve a string proerty form the event.
 int getTimeout()
          The number of milliseconds to wait for a return event when running synchronously.
 Object getTransformedMessage()
          Returns the message transformed into it's recognised or expected format.
 byte[] getTransformedMessageAsBytes()
          This method will attempt to convert the transformed message into an array of bytes It will first check if the result of the transformation is a byte array and return that.
 String getTransformedMessageAsString()
          Returns the message transformed into it's recognised or expected format and then into a String.
 String getTransformedMessageAsString(String encoding)
          Returns the message transformed into it's recognised or expected format and then into a String.
 int hashCode()
           
protected  boolean ignoreProperty(String key)
          This method is used to determine if a property on the previous event should be ignorred for the next event.
 boolean isStopFurtherProcessing()
          Determines whether the default processing for this event will be executed
 boolean isStreaming()
          Determines whether the event flow is being streamed
 boolean isSynchronous()
          Determines whether the was sent synchrounously or not
 Object removeProperty(String key)
          Removes a property from the event
 void setBooleanProperty(String name, boolean value)
          Sets a boolean property on the nessage
protected  void setCredentials()
           
 void setDoubleProperty(String name, double value)
          Sets a double property on the nessage
 void setIntProperty(String name, int value)
          Sets an int property on the nessage
 void setLongProperty(String name, long value)
          Sets a long property on the nessage
 void setProperty(String name, Object value)
          Sets a property associated with the current event.
 void setStopFurtherProcessing(boolean stopFurtherProcessing)
          Setting this parameter will stop the Mule framework from processing this event in the standard way.
 void setStringProperty(String name, String value)
          Sets a String property associated with the current event.
 void setSynchronous(boolean value)
          Determines whether the was sent synchrounously or not
 void setTimeout(int timeout)
          The number of milliseconds to wait for a return event when running synchronously.
 String toString()
           
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected transient Log logger
logger used by this class


ignoredPropertyOverrides

protected String[] ignoredPropertyOverrides
Constructor Detail

MuleEvent

public MuleEvent(UMOMessage message,
                 UMOImmutableEndpoint endpoint,
                 UMOComponent component,
                 UMOEvent previousEvent)
Properties cache that only reads properties once from the inbound message and merges them with any properties on the endpoint. The message properties take precedence over the endpoint properties


MuleEvent

public MuleEvent(UMOMessage message,
                 UMOImmutableEndpoint endpoint,
                 UMOSession session,
                 boolean synchronous)

MuleEvent

public MuleEvent(UMOMessage message,
                 UMOImmutableEndpoint endpoint,
                 UMOSession session,
                 boolean synchronous,
                 ResponseOutputStream outputStream)
Contructor.

Parameters:
message - the event payload
endpoint - the endpoint to associate with the event
session - the previous event if any
See Also:
UMOMessageAdapter

MuleEvent

public MuleEvent(UMOMessage message,
                 UMOImmutableEndpoint endpoint,
                 UMOSession session,
                 String eventId,
                 boolean synchronous)
Contructor.

Parameters:
message - the event payload
endpoint - the endpoint to associate with the event
session - the previous event if any
See Also:
UMOMessageAdapter

MuleEvent

public MuleEvent(UMOMessage message,
                 UMOEvent rewriteEvent)
A helper constructor used to rewrite an event payload

Parameters:
message -
rewriteEvent -
Method Detail

fillProperties

protected void fillProperties(UMOEvent previousEvent)

ignoreProperty

protected boolean ignoreProperty(String key)
This method is used to determine if a property on the previous event should be ignorred for the next event. This method is here because we don't have proper scoped handlng of meta data yet The rules are - 1. If a property is already set on the currect event don't verwrite with the previous event value 2. If the propery name appears in the ignorredPropertyOverrides list, then we always set it on the new event

Parameters:
key -
Returns:

setCredentials

protected void setCredentials()

getCredentials

public UMOCredentials getCredentials()
Specified by:
getCredentials in interface UMOEvent

getMessage

public UMOMessage getMessage()
Description copied from interface: UMOEvent
Returns the message payload for this event

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

getMessageAsBytes

public byte[] getMessageAsBytes()
                         throws MuleException
Description copied from interface: UMOEvent
Reterns the conents of the message as a byte array.

Specified by:
getMessageAsBytes in interface UMOEvent
Returns:
the conents of the message as a byte array
Throws:
MuleException

getTransformedMessage

public Object getTransformedMessage()
                             throws TransformerException
Description copied from interface: UMOEvent
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 UMOEvent
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
This method will attempt to convert the transformed message into an array of bytes It will first check if the result of the transformation is a byte array and return that. Otherwise if the the result is a string it will serialized the CONTENTS of the string not the String object. finally it will check if the result is a Serializable object and convert that to an array of bytes.

Specified by:
getTransformedMessageAsBytes in interface UMOEvent
Returns:
a byte[] representation of the message
Throws:
TransformerException - if an unsupported encoding is being used or if the result message is not a String byte[] or Seializable object
See Also:
UMOTransformer

getTransformedMessageAsString

public 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 UMOEvent
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 String getMessageAsString()
                          throws UMOException
Description copied from interface: UMOEvent
Returns the message contents as a string If necessary this will use the encoding set on the event

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

getTransformedMessageAsString

public String getTransformedMessageAsString(String encoding)
                                     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 UMOEvent
Parameters:
encoding - the encoding to use when converting the message to string
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 String getMessageAsString(String encoding)
                          throws UMOException
Returns the message contents as a string

Specified by:
getMessageAsString in interface UMOEvent
Parameters:
encoding - the encoding to use when converting the message to string
Returns:
the message contents as a string
Throws:
UMOException - if the message cannot be converted into a string

getId

public String getId()
Description copied from interface: UMOEvent
Every event in the system is assigned a universally unique id (UUID).

Specified by:
getId in interface UMOEvent
Returns:
the unique identifier for the event

getProperty

public Object getProperty(String name)
Description copied from interface: UMOEvent
Gets a property associated with the current event. Calling this method is equivilent to calling event.getMessage().getProperty(...)

Specified by:
getProperty in interface UMOEvent
Parameters:
name -
Returns:

getProperty

public Object getProperty(String name,
                          boolean exhaustiveSearch)
Description copied from interface: UMOEvent
Gets a property associated with the current event. If exhaustiveSearch is true, the endpoint and connector associated with the event will also be searched for the property.

Specified by:
getProperty in interface UMOEvent
Parameters:
name - the property name
exhaustiveSearch - also search the endpoint and connector for the property
Returns:
the property value or null if the property does not exist
See Also:
UMOEvent.getProperty(java.lang.String, boolean)

getProperty

public Object getProperty(String name,
                          Object defaultValue)
Description copied from interface: UMOEvent
Gets a property associated with the current event. Calling this method is equivilent to calling event.getMessage().getProperty(..., ...)

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

getProperty

public Object getProperty(String name,
                          Object defaultValue,
                          boolean exhaustiveSearch)
Description copied from interface: UMOEvent
Gets a property associated with the current event. If exhaustiveSearch is true, the endpoint and connector associated with the event will also be searched for the property.

Specified by:
getProperty in interface UMOEvent
Parameters:
name - the property name
defaultValue - a default value if the property doesn't exist in the event
exhaustiveSearch - also search the endpoint and connector for the property
Returns:
the property value or the defaultValue if the property does not exist

setProperty

public void setProperty(String name,
                        Object value)
Description copied from interface: UMOEvent
Sets a property associated with the current event. Calling this method is equivilent to calling event.getMessage().setProperty(..., ...)

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

getEndpoint

public UMOImmutableEndpoint getEndpoint()
Description copied from interface: UMOEvent
Gets the endpoint associated with this event

Specified by:
getEndpoint in interface UMOEvent
Returns:
the endpoint associated with this event

toString

public String toString()

generateEventId

protected String generateEventId()

getSession

public UMOSession getSession()
Description copied from interface: UMOEvent
Retrieves the component session for the current event

Specified by:
getSession in interface UMOEvent
Returns:
the component session for the event

getComponent

public UMOComponent getComponent()
Gets the recipient component of this event

Specified by:
getComponent in interface UMOEvent
Returns:
the component for the event

isStopFurtherProcessing

public boolean isStopFurtherProcessing()
Determines whether the default processing for this event will be executed

Specified by:
isStopFurtherProcessing in interface UMOEvent
Returns:
Returns the stopFurtherProcessing.
See Also:
UMOManager, UMOEventContext, Callable

setStopFurtherProcessing

public void setStopFurtherProcessing(boolean stopFurtherProcessing)
Setting this parameter will stop the Mule framework from processing this event in the standard way. This allow for client code to override default behaviour. The common reasons for doing this are - 1. The UMO has more than one send endpoint configured; the component must dispatch to other prviders programatically by using the component on the current event 2. The UMO doesn't send the current event out through a endpoint. i.e. the processing of the event stops in the uMO.

Specified by:
setStopFurtherProcessing in interface UMOEvent
Parameters:
stopFurtherProcessing - The stopFurtherProcessing to set.

equals

public boolean equals(Object o)

hashCode

public int hashCode()

isSynchronous

public boolean isSynchronous()
Description copied from interface: UMOEvent
Determines whether the was sent synchrounously or not

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

setSynchronous

public void setSynchronous(boolean value)
Description copied from interface: UMOEvent
Determines whether the was sent synchrounously or not

Specified by:
setSynchronous in interface UMOEvent
Parameters:
value - true if the event is synchronous

getTimeout

public int getTimeout()
Description copied from interface: UMOEvent
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

Specified by:
getTimeout in interface UMOEvent
Returns:
the event timeout in milliseconds

setTimeout

public void setTimeout(int timeout)
Description copied from interface: UMOEvent
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

Specified by:
setTimeout in interface UMOEvent
Parameters:
timeout - the event timeout in milliseconds

getIntProperty

public int getIntProperty(String name,
                          int defaultValue)
Gets an int property on the nessage

Specified by:
getIntProperty in interface UMOEvent
Parameters:
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(String name,
                            long defaultValue)
Gets a long property on the nessage

Specified by:
getLongProperty in interface UMOEvent
Parameters:
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(String name,
                                double defaultValue)
Gets a double property on the nessage

Specified by:
getDoubleProperty in interface UMOEvent
Parameters:
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(String name,
                                  boolean defaultValue)
Gets a boolean property on the nessage

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

setBooleanProperty

public void setBooleanProperty(String name,
                               boolean value)
Sets a boolean property on the nessage

Specified by:
setBooleanProperty in interface UMOEvent
Parameters:
name -
value -

setIntProperty

public void setIntProperty(String name,
                           int value)
Sets an int property on the nessage

Specified by:
setIntProperty in interface UMOEvent
Parameters:
name -
value -

setLongProperty

public void setLongProperty(String name,
                            long value)
Sets a long property on the nessage

Specified by:
setLongProperty in interface UMOEvent
Parameters:
name -
value -

setDoubleProperty

public void setDoubleProperty(String name,
                              double value)
Sets a double property on the nessage

Specified by:
setDoubleProperty in interface UMOEvent
Parameters:
name -
value -

getOutputStream

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

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

removeProperty

public Object removeProperty(String key)
Removes a property from the event

Specified by:
removeProperty in interface UMOEvent
Parameters:
key - the property key to remove
Returns:
the removed property or null if the property was not found or if the underlying message does not return the removed property

getStringProperty

public String getStringProperty(String name,
                                String defaultValue)
Will retrieve a string proerty form the event. If the property does not exist it will be substituted with the default value

Specified by:
getStringProperty in interface UMOEvent
Parameters:
name - the name of the proerty to get
defaultValue - the default value to return if the proerty is not set
Returns:
the property value or the defaultValue if the proerty is not set

setStringProperty

public void setStringProperty(String name,
                              String value)
Description copied from interface: UMOEvent
Sets a String property associated with the current event. Calling this method is equivilent to calling event.getMessage().setStringProperty(..., ...)

Specified by:
setStringProperty in interface UMOEvent
Parameters:
name - the property name or key
value - the property value

isStreaming

public boolean isStreaming()
Determines whether the event flow is being streamed

Specified by:
isStreaming in interface UMOEvent
Returns:
true if the request should be streamed

getEncoding

public String getEncoding()
Gets the encoding for this message. First it looks to see if encoding has been set on the endpoint, if not it will check the message itself and finally it will fall back to the Mule global configuration for encoding which cannot be null.

Specified by:
getEncoding in interface UMOEvent
Returns:
the encoding for the event


Copyright © 2003-2006 MuleSource Inc.. All Rights Reserved.