public abstract class AbstractMessageAdapter extends Object implements MessageAdapter, ThreadSafeAccess
AbstractMessageAdapter
provides a base implementation for simple
message types that maybe don't normally allow for meta information, such as a File
or TCP.ThreadSafeAccess.AccessControl
Modifier and Type | Field and Description |
---|---|
protected ConcurrentMap |
attachments
Collection of attachments associatated with this message
|
protected String |
encoding
The encoding used by this message.
|
protected ExceptionPayload |
exceptionPayload
If an excpetion occurs while processing this message an exception payload will be attached here
|
protected String |
id
the default UUID for the message.
|
protected static org.apache.commons.logging.Log |
logger
logger used by this class
|
protected MessagePropertiesContext |
properties
Scoped properties for this message
|
READ, WRITE
Modifier | Constructor and Description |
---|---|
protected |
AbstractMessageAdapter() |
protected |
AbstractMessageAdapter(MessageAdapter template)
Creates a message adapter copying values from an existing one
|
Modifier and Type | Method and Description |
---|---|
void |
addAttachment(String name,
javax.activation.DataHandler dataHandler)
Allows for arbitary data attachments to be associated with the Message.
|
protected void |
addInboundProperties(Map props)
A convenience method for extending classes to Set inbound scoped properties on the message
properties that arrive on the inbound message should be set as inbound-scoped properties.
|
void |
addProperties(Map props)
Adds a map of properties to be associated with this message
|
void |
addProperties(Map props,
PropertyScope scope)
Adds a map of properties to be associated with this message
|
void |
assertAccess(boolean write)
This method may be called before data in the object are accessed.
|
void |
clearProperties()
Removes all properties on this message
|
javax.activation.DataHandler |
getAttachment(String name)
Retrieve an attachment with the given name.
|
Set |
getAttachmentNames()
Returns a set of the names of the attachments on this message.
|
boolean |
getBooleanProperty(String name,
boolean defaultValue)
Gets a boolean property from the message
|
int |
getCorrelationGroupSize()
Determines how many messages are in the correlation group
|
String |
getCorrelationId()
Sets a correlationId for this message.
|
int |
getCorrelationSequence()
Gets the sequence or ordering number for this message in the the correlation
group (as defined by the correlationId)
|
double |
getDoubleProperty(String name,
double defaultValue)
Gets a double property from the message
|
String |
getEncoding()
Gets the encoding for the current message.
|
ExceptionPayload |
getExceptionPayload()
If an error occurred during the processing of this message this will return a
ErrorPayload that contains the root exception and Mule error code, plus any
other releated info
|
int |
getIntProperty(String name,
int defaultValue)
Gets an integer property from the message
|
long |
getLongProperty(String name,
long defaultValue)
Gets a long property from the message
|
Object |
getProperty(String key)
Gets a property of the message implementation
|
Object |
getProperty(String name,
Object defaultValue)
Gets a property from the message
|
Set |
getPropertyNames() |
Object |
getReplyTo()
Returns a replyTo address for this message.
|
String |
getStringProperty(String name,
String defaultValue)
Gets a String property from the message
|
String |
getUniqueId()
gets the unique identifier for the message.
|
protected boolean |
isDisabled() |
protected IllegalStateException |
newException(String message) |
ThreadSafeAccess |
newThreadCopy() |
void |
release()
Perform any clean up operations on the message resource.
|
void |
removeAttachment(String name)
Remove an attahcment form this message with the specifed name
|
Object |
removeProperty(String key)
Removes a property on this message
|
void |
resetAccessControl()
This method should ONLY be used in the construction of composite ThreadSafeAccess instances.
|
void |
setBooleanProperty(String name,
boolean value)
Sets a boolean property on the message
|
void |
setCorrelationGroupSize(int size)
Determines how many messages are in the correlation group
|
void |
setCorrelationId(String correlationId)
Sets a correlationId for this message.
|
void |
setCorrelationSequence(int sequence)
Gets the sequence or ordering number for this message in the the correlation
group (as defined by the correlationId)
|
void |
setDoubleProperty(String name,
double value)
Sets a double property on the message
|
void |
setEncoding(String encoding)
Sets the encoding for this message
|
void |
setExceptionPayload(ExceptionPayload payload)
If an error occurs while processing this message, a ErrorPayload is attached
which contains the root exception and Mule error code, plus any other releated
info.
|
void |
setIntProperty(String name,
int value)
Sets a integerproperty on the message
|
void |
setLongProperty(String name,
long value)
Sets a long property on the message
|
void |
setProperty(String key,
Object value)
Set a property on the message
|
void |
setProperty(String key,
Object value,
PropertyScope scope)
Set a property on the message
|
void |
setReplyTo(Object replyTo)
Sets a replyTo address for this message.
|
void |
setStringProperty(String name,
String value)
Sets a String property on the message
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getPayload
protected static transient org.apache.commons.logging.Log logger
protected MessagePropertiesContext properties
protected ConcurrentMap attachments
protected String encoding
protected ExceptionPayload exceptionPayload
protected String id
protected AbstractMessageAdapter()
protected AbstractMessageAdapter(MessageAdapter template)
template
- public void addProperties(Map props)
addProperties
in interface MessageAdapter
props
- the properties add to this messagepublic void addProperties(Map props, PropertyScope scope)
addProperties
in interface MessageAdapter
props
- the properties add to this messagescope
- the scope in which the proeprties should be addedprotected void addInboundProperties(Map props)
props
- the properties to setPropertyScope
public void clearProperties()
clearProperties
in interface MessageAdapter
public Object removeProperty(String key)
removeProperty
in interface MessageAdapter
key
- the property key to removepublic Object getProperty(String key)
getProperty
in interface MessageAdapter
key
- the key on which to lookup the property valuepublic Set getPropertyNames()
getPropertyNames
in interface MessageAdapter
public void setProperty(String key, Object value)
setProperty
in interface MessageAdapter
key
- the key on which to associate the valuevalue
- the property valuepublic void setProperty(String key, Object value, PropertyScope scope)
setProperty
in interface MessageAdapter
key
- the key on which to associate the valuevalue
- the property valuescope
- The scope at which to set the property atPropertyScope
public String getUniqueId()
getUniqueId
in interface MessageAdapter
public Object getProperty(String name, Object defaultValue)
getProperty
in interface MessageAdapter
name
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the eventpublic int getIntProperty(String name, int defaultValue)
getIntProperty
in interface MessageAdapter
name
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the eventpublic long getLongProperty(String name, long defaultValue)
getLongProperty
in interface MessageAdapter
name
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the eventpublic double getDoubleProperty(String name, double defaultValue)
getDoubleProperty
in interface MessageAdapter
name
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the eventpublic boolean getBooleanProperty(String name, boolean defaultValue)
getBooleanProperty
in interface MessageAdapter
name
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the eventpublic String getStringProperty(String name, String defaultValue)
getStringProperty
in interface MessageAdapter
name
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the eventpublic void setBooleanProperty(String name, boolean value)
setBooleanProperty
in interface MessageAdapter
name
- the property name or keyvalue
- the property valuepublic void setIntProperty(String name, int value)
setIntProperty
in interface MessageAdapter
name
- the property name or keyvalue
- the property valuepublic void setLongProperty(String name, long value)
MessageAdapter
setLongProperty
in interface MessageAdapter
name
- the property name or keyvalue
- the property valuepublic void setDoubleProperty(String name, double value)
MessageAdapter
setDoubleProperty
in interface MessageAdapter
name
- the property name or keyvalue
- the property valuepublic void setStringProperty(String name, String value)
setStringProperty
in interface MessageAdapter
name
- the property name or keyvalue
- the property valuepublic Object getReplyTo()
getReplyTo
in interface MessageAdapter
public void setReplyTo(Object replyTo)
setReplyTo
in interface MessageAdapter
replyTo
- the endpointUri url to reply topublic String getCorrelationId()
getCorrelationId
in interface MessageAdapter
public void setCorrelationId(String correlationId)
setCorrelationId
in interface MessageAdapter
correlationId
- the Id reference for this relationshippublic int getCorrelationSequence()
getCorrelationSequence
in interface MessageAdapter
public void setCorrelationSequence(int sequence)
setCorrelationSequence
in interface MessageAdapter
sequence
- the sequence number or -1 if the sequence is not importantpublic int getCorrelationGroupSize()
getCorrelationGroupSize
in interface MessageAdapter
public void setCorrelationGroupSize(int size)
setCorrelationGroupSize
in interface MessageAdapter
size
- the total messages in this group or -1 if the size is not knownpublic ExceptionPayload getExceptionPayload()
MessageAdapter
getExceptionPayload
in interface MessageAdapter
public void setExceptionPayload(ExceptionPayload payload)
setExceptionPayload
in interface MessageAdapter
payload
- The exception payload to attach to this messagepublic void addAttachment(String name, javax.activation.DataHandler dataHandler) throws Exception
addAttachment
in interface MessageAdapter
name
- the name to associate with the attachmentdataHandler
- The attachment datahandler to use. This will be used to interract with the attachment dataException
DataHandler
public void removeAttachment(String name) throws Exception
removeAttachment
in interface MessageAdapter
name
- the name of the attachment to remove. If the attachment does not exist, the request may be ignorredException
- different messaging systems handle attachments differnetly, as such some will throw an exception
if an attahcment does dot exist.public javax.activation.DataHandler getAttachment(String name)
getAttachment
in interface MessageAdapter
name
- the name of the attachment to retrieveDataHandler
public Set getAttachmentNames()
getAttachmentNames
in interface MessageAdapter
public String getEncoding()
getEncoding
in interface MessageAdapter
public void setEncoding(String encoding)
setEncoding
in interface MessageAdapter
encoding
- the encoding to usepublic void release()
release
in interface MessageAdapter
public void assertAccess(boolean write)
assertAccess
in interface ThreadSafeAccess
write
- True if the access will mutate values.protected IllegalStateException newException(String message)
protected boolean isDisabled()
public void resetAccessControl()
resetAccessControl
in interface ThreadSafeAccess
public ThreadSafeAccess newThreadCopy()
newThreadCopy
in interface ThreadSafeAccess
Copyright © 2003–2013 MuleSource, Inc.. All rights reserved.