The ErraiBus framework provides a standardized mechanism using asyncronous messaging (AJAX) within GWT applications.

This package contains all of the necessary APIs to use the framework.

ErraiBus uses the CommandMessage/ConversationMessage paradigm for all communication across the bus. The programming model is essentially PubSub (publish/subscribe) at it's core. But one of the distinct aspects of ErraiBus is that the model is consistent on both the server and the client.

An Example Server-side Service:

    @Service
    public class HelloWorld implements MessageCallback {
        public void callback(CommandMessage message) {
            System.out.println("Hello, World!");
        }
    }

The above example service shows a very simple server-side service. The @Service annotation is used by the framework for auto-discovery of the service. By default, unless otherwise specified, the service will take on the name of the class it is annotating, in this case: HelloWorld.

Example client-side code, demonstrating use of HelloWorld service:

    public class HelloWorld implements EntryPoint {
        /**
         * Get an instance of the MessageBus
         */
        private MessageBus bus = ErraiBus.get();

        public void onModuleLoad() {
            Button clickMe = new Button("Click Me!");

            /**
             * Register a click handler for the button.
             */
            clickMe.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    /**
                     * Send a message to the 'HelloWorld' service.
                     */
                    CommandMessage.create()
                            .toSubject("HelloWorld")
                            .sendNowWith(bus);
               }
            });

            /**
             * Just add the button to the RootPanel in the DOM.
             */
            RootPanel.get().add(clickMe);
        }
    }