My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
AppControllersAndGinModules  
Overview of what is an app controller and gin modules and how to declare them
Updated Aug 19, 2010 by gal.dol...@gmail.com

Introduction

In guit you no longer need to declare EntryPoints, the framework take care of that for you. Instead, you declare AppControllers. An AppController is like an EntryPoint but with the difference that you are already in an injected context, that means that in the AppController constructor you can @Inject everything you need.

How to declare an AppController

To declare and add a new controller you need to:

  • Create a Controller or a Presenter.
  • Remember that you are already in an injected context, so you can @Inject anything you like into your controller
  • Go to your gwt xml module and remove all
    <entry-point>
    tags
  • Then include your controller in the gwt.xml module like this:
    <extend-configuration-property name="app.controller" value="com.demo.client.MyController">
    </extend-configuration-property>
  • You can have all the AppControllers that you want. All of them will be instantiated one after the other when your application gets loaded

package com.demo.client;

import com.google.inject.Inject;

import com.unnison.framework.client.eventbus.EventBus;

public class MyController {

    @Inject
    public MyController(EventBus eventBus) {
        ...
    }
}

How to declare a gin module

If you haven't used google-gin yet, go on and read the documentation because it is an essential part of Guit.

To add a gin module(Lets say: com.unnison.framework.client.gin.EventBusModule) to your app, you need to add in your gwt xml module:

<extend-configuration-property name="app.gin.module" value="com.unnison.framework.client.gin.EventBusModule">
</extend-configuration-property>

That module is actually a real module that guit add automatically. It looks like this:

public class EventBusModule extends AbstractGinModule {

    @Override
    protected void configure() {
        bind(EventBus.class).to(EventBusImpl.class).in(Singleton.class);
    }
}

Same as AppControllers you can add all the GinModules that you want.

Powered by Google Project Hosting