|
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.MessageBuilder
public class MessageBuilder
The MessageBuilder API provides a fluent method of building Messages.
Message m = MessageBuilder .createMessage() .toSubject("TheMessageSubject") .withValue("Hello everyone").done();
You can transmit a message using the the sendNowWith(RequestDispatcher) method by providing an instance of
MessageBus
.
Messages can be constructed using user-defined standard protocols through the use of enumerations. Both commandType and message parts can be defined through the use of enumerations. This helps create strongly-defined protocols for communicating with services. For instance:
public enum LoginParts { Username, Password }.. and ..
public enum LoginCommands { Login, Logout }A service can then use these enumerations to build and decode messages. For example:
MessageBuilder .createMessage() .toSubject("LoginService") .command(LoginCommands.Login) .set(LoginParts.Username, "foo") .set(LoginParts.Password, "bar") .sendNowWith(busInstance);Messages may contain serialized objects that are annotated with
Portable
and can be marshalled by the built-in Errai
marshallers or by user-provided marshallers that have been registered with the system.
Constructor Summary | |
---|---|
MessageBuilder()
|
Method Summary | ||
---|---|---|
static DefaultRemoteCallBuilder |
createCall()
Creates an AbstractRemoteCallBuilder to construct a call. |
|
static
|
createCall(RemoteCallback<R> callback,
BusErrorCallback errorCallback,
Class<T> service)
Creates an RPC call with error handling. |
|
static
|
createCall(RemoteCallback<R> callback,
Class<T> service)
Creates an RPC call, with no error handling. |
|
static MessageBuildSubject<MessageReplySendable> |
createConversation(Message message)
Creates a conversational message. |
|
static MessageBuildCommand<MessageReplySendable> |
createConversation(Message message,
String subject)
Creates a conversational message for the provided subject. |
|
static MessageBuildSubject<MessageBuildSendableWithReply> |
createMessage()
Creates a new message. |
|
static MessageBuildCommand<MessageBuildSendableWithReply> |
createMessage(String subject)
Creates a new message for the provided subject. |
|
static MessageProvider |
getMessageProvider()
Returns the message provider. |
|
static void |
setMessageProvider(MessageProvider provider)
Sets the message provider for this instance of MessageBuilder. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MessageBuilder()
Method Detail |
---|
public static MessageBuildSubject<MessageBuildSendableWithReply> createMessage()
public static MessageBuildCommand<MessageBuildSendableWithReply> createMessage(String subject)
subject
- the subject the message should be sent to
public static MessageBuildSubject<MessageReplySendable> createConversation(Message message)
message
- reference message to create conversation from
public static MessageBuildCommand<MessageReplySendable> createConversation(Message message, String subject)
message
- reference message to create conversation fromsubject
- the subject the message should be sent to
public static DefaultRemoteCallBuilder createCall()
public static <R,T> T createCall(RemoteCallback<R> callback, Class<T> service)
T
- The type of the remote service.R
- The return type of the invoked method.callback
- The remote callback that receives the return value from the call. Cannot not be null.service
- The remote interface.
public static <R,T> T createCall(RemoteCallback<R> callback, BusErrorCallback errorCallback, Class<T> service)
T
- The type of the remote service.R
- The return type of the invoked method.callback
- The remote callback that receives the return value from the call. Cannot not be null.errorCallback
- The error callback that receives transmission errors and exceptions thrown by the remote service. Cannot not be null.service
- The remote interface.
public static void setMessageProvider(MessageProvider provider)
provider
- to set this' provider topublic static MessageProvider getMessageProvider()
|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |