concept message in category gwt

appears as: message, messages, messages, The message, The messages, message
GWT in Action

This is an excerpt from Manning's book GWT in Action.

An event bus works similarly to Internet Relay Chat (IRC), where you send a message to the channel and everyone else connected to the channel will see your message. Figure 1.4 shows how the event bus works using the paradigm of pipes to illustrate how producers and recipients know about the pipe (message bus), but not each other.

Messages are those strings of texts that are inserted at runtime into placeholders. To use them, you extend the Messages interface and provide the required methods. The differences from constants are as follows:

  • The messages in properties files will contain zero or more placeholders.
  • public interface ExampleMessages extends Messages{
       public String locale(String locale);
    }
    Figure 13.8. Displaying a list of items in a message
    GWT in Practice

    This is an excerpt from Manning's book GWT in Practice.

    The last step is to define a generator class. Here it tells the compiler to generate implementations of all classes that extend or implement Localizable with the LocalizableGenerator . This class writes out Java files that implement the appropriate interfaces for each of the user���s defined Constants, Messages, or Dictionary classes.

    Listing 11.7. ConversationServiceLocal.java, part 6: sending messages

    This final bit of code shows the basics of sending messages. There is the standard chat message and a special message containing an update to the screen image display . Finally it shows the basic messages for signing a user on and off from the service , .

    Doing our polling this way has some advantages and disadvantages that you should take into consideration when you use Comet streaming. The user’s outbound message could have been implemented as another Observable, which the servlet could block on and then send the messages as they are ready to go out. This would have the advantage of reducing the possible half-second delay between the time a message hits the conversation and the time it’s sent to the user. For our purposes, however, a half-second delay isn’t too bad. The disadvantage would be that once a message is ready to go out, like messages in our keep-alive conversation, all the outbound stream servlet threads will want to wake up at once. Add heavy user load to this burst behavior, and you can see how this design could cause problems on the server. The staggered sleep() cycle of all the threads calling into StreamServlet #6 reduces this risk. It also gives your servlet container the option to be a little smarter about how it handles thread pooling and I/O operations to the clients. The send workers monitoring the output stream can be recycled across connections while the executions sleep. If they all woke up at once, it might flood the send workers that are translating the ServletOutputStream into java.nio calls. At any rate, your mileage may vary, so keep this in mind when designing your applications.