|
AppControllersAndGinModules
Overview of what is an app controller and gin modules and how to declare them
IntroductionIn 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 AppControllerTo declare and add a new controller you need to:
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 moduleIf 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. | |