|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.errai.bus.client.api.base.CommandMessage
public class CommandMessage
The default implementation of the Message interface. The usual way to create a CommandMessage is through the
MessageBuilder
API.
ConversationMessage
,
MessageBuilder
Constructor Summary | |
---|---|
CommandMessage(Map<String,Object> parts,
int routingFlags)
|
Method Summary | ||
---|---|---|
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. |
|
|
get(Class<T> type,
Enum<?> part)
Gets the specified message part in the specified type. |
|
|
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. |
|
|
getResource(Class<T> type,
String key)
Obtains a transient resource based on the specified key. |
|
String |
getSubject()
Returns the message's subject. |
|
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CommandMessage(Map<String,Object> parts, int routingFlags)
Method Detail |
---|
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
toSubject
in interface Message
subject
- the intended recipient of the message.
public Message command(Enum<?> type)
Message
command
in interface Message
type
- Enum representation of a command type.
public Message command(String type)
Message
command
in interface Message
type
- String representation of a command type.
public Message set(Enum<?> part, Object value)
Message
set
in interface Message
part
- The Enum representation of the message part.value
- the value to set the part to.
public Message set(String part, Object value)
Message
set
in interface Message
part
- The String name of the message part.value
- The value to set the part to.
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
remove
in interface Message
part
- the part to remove.public void remove(Enum<?> part)
Message
remove
in interface Message
part
- the part to remove.public Message copy(Enum<?> part, Message message)
Message
copy
in interface Message
part
- the part of this message to copy.message
- the message to copy the part to. Must not be null.
public Message copy(String part, Message message)
Message
copy
in interface Message
part
- the part of this message to copy.message
- the message to copy the part to. Must not be null.
public Message setFlag(RoutingFlag flag)
Message
setFlag
in interface Message
flag
- message routing flagpublic void unsetFlag(RoutingFlag flag)
Message
unsetFlag
in interface Message
flag
- message routing flagpublic boolean isFlagSet(RoutingFlag flag)
Message
isFlagSet
in interface Message
flag
- message routing flag.
public <T> T getValue(Class<T> type)
getValue
in interface Message
public <T> T get(Class<T> type, Enum<?> part)
Message
get
in interface Message
T
- Type to be returned.type
- Type to be returned.part
- Message part.
public <T> T get(Class<T> type, String part)
Message
get
in interface Message
T
- Type to be returned.type
- Type to be returned.part
- Message part.
public boolean hasPart(Enum<?> part)
Message
hasPart
in interface Message
part
- Enum part to check for.
part
.public boolean hasPart(String part)
Message
hasPart
in interface Message
part
- String part to check for.
part
.public Map<String,Object> getParts()
Message
getParts
in interface 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.
setParts
in interface Message
parts
- Parts to be used in the message. Must not be null.
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 message
public 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 resource
public 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
commit
in interface 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 topublic String toString()
toString
in class Object
|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |