public class CommandMessage extends Object implements Message
MessageBuilder
API.ConversationMessage
,
MessageBuilder
Constructor and Description |
---|
CommandMessage(Map<String,Object> parts,
int routingFlags) |
Modifier and Type | Method and Description |
---|---|
Message |
addAllParts(Map<String,Object> parts)
Copies in a set of message parts from the provided map.
|
Message |
addAllProvidedParts(Map<String,ResourceProvider<?>> parts)
Copies in a set of provided message parts from the provided maps
|
void |
addResources(Map<String,?> resources)
Adds the Map of resources to the message.
|
Message |
command(Enum<?> type)
Set the command type for this message.
|
Message |
command(String type)
Sets the command type for this message.
|
void |
commit()
Commits the message in its current structure.
|
Message |
copy(Enum<?> part,
Message message)
Copies a part of this message to another message.
|
Message |
copy(String part,
Message message)
Copies a part of this message to another message.
|
Message |
copyResource(String key,
Message copyFrom)
Copies a transient resource to this message from the specified message.
|
static CommandMessage |
create()
Creates a new CommandMessage with no parts and no provided parts.
|
static CommandMessage |
createWithParts(Map<String,Object> parts)
Creates a new CommandMessage with the given parts and no provided parts.
|
static CommandMessage |
createWithParts(Map<String,Object> parts,
int flags) |
static CommandMessage |
createWithParts(Map<String,Object> parts,
Map<String,ResourceProvider<?>> provided)
Creates a new CommandMessage with the given parts and provided parts.
|
static CommandMessage |
createWithPartsFromRawMap(Map parts) |
Message |
errorsCall(ErrorCallback callback)
Sets the error callback for this message.
|
<T> T |
get(Class<T> type,
Enum<?> part)
Gets the specified message part in the specified type.
|
<T> T |
get(Class<T> type,
String part)
Gets the specified message part in the specified type.
|
String |
getCommandType()
Returns the command type for this message as a String.
|
ErrorCallback |
getErrorCallback()
Gets the error callback for this message.
|
Map<String,Object> |
getParts()
Returns a Map of all the specified parts.
|
Map<String,ResourceProvider<?>> |
getProvidedParts()
Returns a Map of all provided parts.
|
<T> T |
getResource(Class<T> type,
String key)
Obtains a transient resource based on the specified key.
|
String |
getSubject()
Returns the message's subject.
|
<T> T |
getValue(Class<T> type) |
boolean |
hasPart(Enum<?> part)
Checks if message contains the specified part.
|
boolean |
hasPart(String part)
Checks if message contains the specified part.
|
boolean |
hasResource(String key)
Returns true if the specified transient resource is present.
|
boolean |
isCommited()
Returns true if the message has been committed.
|
boolean |
isFlagSet(RoutingFlag flag)
Checks if the provided flag is set for this message.
|
void |
remove(Enum<?> part)
Removes specified part from the message.
|
void |
remove(String part)
Removes specified part from the message.
|
void |
sendNowWith(MessageBus viaThis)
Transmits this message to the specified
MessageBus instance. |
void |
sendNowWith(RequestDispatcher viaThis)
Transmits this message using the specified
RequestDispatcher . |
Message |
set(Enum<?> part,
Object value)
Sets a Message part to the specified value.
|
Message |
set(String part,
Object value)
Sets a Message part to the specified value.
|
Message |
setFlag(RoutingFlag flag)
Sets the provided flag for this message.
|
Message |
setParts(Map<String,Object> parts)
Sets the message to contain the specified parts.
|
Message |
setProvidedPart(Enum<?> part,
ResourceProvider<?> provider)
Adds or replaces a message part whose value is recomputed every time the message is sent.
|
Message |
setProvidedPart(String part,
ResourceProvider<?> provider)
Adds or replaces a message part whose value is recomputed every time the message is sent.
|
Message |
setResource(String key,
Object res)
Sets a transient resource.
|
String |
toString() |
Message |
toSubject(String subject)
Sets the subject of this message, which is the intended recipient, and returns the message.
|
void |
unsetFlag(RoutingFlag flag)
Unsets the provided flag for this message.
|
public static CommandMessage create()
public static CommandMessage createWithParts(Map<String,Object> parts)
Note that MessageBuilder
is the preferred API for creating Message
instances.
parts
- The parts that this message should have initially. This map is
taken as-is. No copy is made. Changes to the provided map will be
reflected in this message, and additional parts given to this
message will appear in the provided map.public static CommandMessage createWithPartsFromRawMap(Map parts)
public static CommandMessage createWithParts(Map<String,Object> parts, int flags)
public static CommandMessage createWithParts(Map<String,Object> parts, Map<String,ResourceProvider<?>> provided)
Note that MessageBuilder
is the preferred API for creating Message
instances.
parts
- The parts that this message should have initially. This map is
taken as-is. No copy is made. Changes to the provided map will be
reflected in this message, and additional parts given to this
message will appear in the provided map.provided
- The provided parts that this message should have initially. This
map is taken as-is. No copy is made. Changes to the provided map
will be reflected in this message, and additional parts given to
this message will appear in the provided map.public String getCommandType()
Message
getCommandType
in interface Message
public String getSubject()
Message
getSubject
in interface Message
public Message toSubject(String subject)
Message
public Message command(Enum<?> type)
Message
public Message command(String type)
Message
public Message set(Enum<?> part, Object value)
Message
public Message set(String part, Object value)
Message
public Message setProvidedPart(String part, ResourceProvider<?> provider)
Message
setProvidedPart
in interface Message
part
- The name of the message part.provider
- a callback that provides the value of the message part on demand. Will be called every time this message
is sent.public Message setProvidedPart(Enum<?> part, ResourceProvider<?> provider)
Message
setProvidedPart
in interface Message
part
- The Enum representation of the message part.provider
- a callback that provides the value of the message part on demand. Will be called every time this message
is sent.public void remove(String part)
Message
public void remove(Enum<?> part)
Message
public Message copy(Enum<?> part, Message message)
Message
public Message copy(String part, Message message)
Message
public Message setFlag(RoutingFlag flag)
Message
public void unsetFlag(RoutingFlag flag)
Message
public boolean isFlagSet(RoutingFlag flag)
Message
public <T> T get(Class<T> type, Enum<?> part)
Message
public <T> T get(Class<T> type, String part)
Message
public boolean hasPart(Enum<?> part)
Message
public boolean hasPart(String part)
Message
public Map<String,Object> getParts()
Message
public Map<String,ResourceProvider<?>> getProvidedParts()
Message
getProvidedParts
in interface Message
public Message setParts(Map<String,Object> parts)
Message
Implementations may or may not create a defensive copy of the given map. Check their documentation to be sure.
public Message addAllParts(Map<String,Object> parts)
Message
addAllParts
in interface Message
parts
- Parts to be added to the message. Must not be null.public Message addAllProvidedParts(Map<String,ResourceProvider<?>> parts)
Message
addAllProvidedParts
in interface Message
parts
- provided parts to be added to the messagepublic Message setResource(String key, Object res)
Message
setResource
in interface Message
key
- Name of resource.res
- Instance of resource.public <T> T getResource(Class<T> type, String key)
Message
getResource
in interface Message
type
- type of resource.key
- the name of the resourcepublic Message copyResource(String key, Message copyFrom)
Message
copyResource
in interface Message
key
- Name of resource.copyFrom
- Message to copy from.public Message errorsCall(ErrorCallback callback)
Message
errorsCall
in interface Message
callback
- error callback.public ErrorCallback getErrorCallback()
Message
getErrorCallback
in interface Message
public boolean hasResource(String key)
Message
hasResource
in interface Message
key
- Name of resource.public void addResources(Map<String,?> resources)
Message
addResources
in interface Message
resources
- Map of resourcepublic void commit()
Message
public boolean isCommited()
Message
isCommited
in interface Message
public void sendNowWith(MessageBus viaThis)
Message
MessageBus
instance.sendNowWith
in interface Message
viaThis
- MessageBus instance to send message topublic void sendNowWith(RequestDispatcher viaThis)
Message
RequestDispatcher
.sendNowWith
in interface Message
viaThis
- RequestDispatcher instance to send message toCopyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.