SlideShare a Scribd company logo
1 of 31
Download to read offline
GIN
A basic tutorial
       by

 anhquan.de
What the heck is Google GIN?

• GIN = GWT INjection
• Guice brings automatic dependency injection to server side
  code, while GIN is for client-side code.
• GIN is built on top of Guice and uses (a subset of) Guice's
  binding language
What the heck is Google GIN?

• GIN = GWT INjection
• Guice brings automatic dependency injection to server side
  code, while GIN is for client-side code.
• GIN is built on top of Guice and uses (a subset of) Guice's
  binding language

             GWT client-side
                 code




                  GIN
What the heck is Google GIN?

• GIN = GWT INjection
• Guice brings automatic dependency injection to server side
  code, while GIN is for client-side code.
• GIN is built on top of Guice and uses (a subset of) Guice's
  binding language

             GWT client-side           GWT server-side
                 code                      code




                  GIN                      Guice
This tutorial shows you


How to use GIN ?
5 Steps to remember
1. Design the application with Interfaces IA,IB,…
5 Steps to remember
1. Design the application with Interfaces IA,IB,…
2. Create concrete classes AImpl, BImpl,… to implement interfaces IA,IB,…
   Remember: use @Inject to mark the non-default constructor.
5 Steps to remember
1. Design the application with Interfaces IA,IB,…
2. Create concrete classes AImpl, BImpl,… to implement interfaces IA,IB,…
   Remember: use @Inject to mark the non-default constructor.
3. Create AppClientModule to configure which implementation is bound to which interface
5 Steps to remember
1. Design the application with Interfaces IA,IB,…
2. Create concrete classes AImpl, BImpl,… to implement interfaces IA,IB,…
   Remember: use @Inject to mark the non-default constructor.
3. Create AppClientModule to configure which implementation is bound to which interface
4. Create interface AppGinjector with the AppClientModule in the annotation @GinModules.

     @GinModules({AppClientModule.class, other modules …})
5 Steps to remember
1. Design the application with Interfaces IA,IB,…
2. Create concrete classes AImpl, BImpl,… to implement interfaces IA,IB,…
   Remember: use @Inject to mark the non-default constructor.
3. Create AppClientModule to configure which implementation is bound to which interface
4. Create interface AppGinjector with the AppClientModule in the annotation @GinModules.

     @GinModules({AppClientModule.class, other modules …})



5. Generate code for AppGinjector and use it


      private final AppGinjector injector = GWT.create(AppGinjector.class);

      AppPresenter aPres = injector.getAppPresenter();
      aPres.bind();

      RootPanel.get().add(aPres.getDisplay().asWidget());
Step 1: Design an Interface

public class ConfigPresenter extends WidgetPresenter<ConfigPresenter.Display>{

    public interface Display extends NameAwareWidgetDisplay, WidgetDisplay {
      public HasClickHandlers getSaveClick();
      public void updateConfig(Config config);
    }
…
}
Step 1: Design an Interface

public class ConfigPresenter extends WidgetPresenter<ConfigPresenter.Display>{

    public interface Display extends NameAwareWidgetDisplay, WidgetDisplay {
      public HasClickHandlers getSaveClick();
      public void updateConfig(Config config);
    }
…
}


                         For gwt-dispatch developers:
                         Normally, we create a Display interface as an inner interface of
                         a Presenter class
Step 2: Implement the interface


public class ConfigView extends Composite implements ConfigPresenter.Display {

    private VerticalPanel panel = new VerticalPanel();

    private AppConstants constants;

    @Inject
    public ConfigView(AppConstants constants, AppMessages messages) {
       this.constants = constants;
       panel.addStyleName(AppCSS.C_config_container);
       panel.add(new HTML("<h1>Config view: comming soon<h1>"));
       initWidget(panel);
    }
…
}
Step 2: Implement the interface
    If the class has no default constructor, then a @Inject annotation is required. Otherwise, you will get
    a RuntimeException (“No @Inject or default constructor found for class …. ”)




public class ConfigView extends Composite implements ConfigPresenter.Display {

      private VerticalPanel panel = new VerticalPanel();

      private AppConstants constants;

      @Inject
      public ConfigView(AppConstants constants, AppMessages messages) {
         this.constants = constants;
         panel.addStyleName(AppCSS.C_config_container);
         panel.add(new HTML("<h1>Config view: comming soon<h1>"));
         initWidget(panel);
      }
…
}
Step 3: Create class AppClientModule

public class AppClientModule extends AbstractPresenterModule {

@Override
protected void configure() {
bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class);
bind(PlaceManager.class).to(AppPlaceManager.class);
bindPresenter(LoginPresenter.class, LoginPresenter.Display.class, LoginView.class);
bindPresenter(MainPresenter.class, MainPresenter.Display.class, MainView.class);
bindPresenter(AppPresenter.class, AppPresenter.Display.class, AppView.class);
bind(LoginPresenterPlace.class).in(Singleton.class);
bind(ContactsPresenterPlace.class).in(Singleton.class);
…
bind(LoginPresenter.class).in(Singleton.class);
bind(LoginPresenter.Display.class).to(LoginView.class);



}
}
Step 3: Create class AppClientModule

public class AppClientModule extends AbstractPresenterModule {

@Override
protected void configure() {
bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class);
bind(PlaceManager.class).to(AppPlaceManager.class);
bindPresenter(LoginPresenter.class, LoginPresenter.Display.class, LoginView.class);
bindPresenter(MainPresenter.class, MainPresenter.Display.class, MainView.class);
bindPresenter(AppPresenter.class, AppPresenter.Display.class, AppView.class);
bind(LoginPresenterPlace.class).in(Singleton.class);
bind(ContactsPresenterPlace.class).in(Singleton.class);
…
bind(LoginPresenter.class).in(Singleton.class);
bind(LoginPresenter.Display.class).to(LoginView.class);



}
}                  Don’t need to bind LoginPresenter and LoginPresenter.Display
                   Because they are already “bind” above in the bindPresenter(…)


                         See the implementation of the bindPresenter() in the next slide …
Note: Implementation of bindPresenter()


public abstract class AbstractPresenterModule extends AbstractGinModule {

protected <D extends Display> void bindPresenter( Class<? extends Presenter> presenter,
Class<D> display, Class<? extends D> displayImpl )
{
        bind( presenter ).in( Singleton.class );
        bindDisplay( display, displayImpl );
}

protected <D extends Display> void bindDisplay( Class<D> display, Class<? extends D>
displayImpl )
{
        bind( display ).to( displayImpl );
}
…
}
Note: Implementation of bindPresenter()


public abstract class AbstractPresenterModule extends AbstractGinModule {

protected <D extends Display> void bindPresenter( Class<? extends Presenter> presenter,
Class<D> display, Class<? extends D> displayImpl )
{
        bind( presenter ).in( Singleton.class );
        bindDisplay( display, displayImpl );
}

protected <D extends Display> void bindDisplay( Class<D> display, Class<? extends D>
displayImpl )
{
        bind( display ).to( displayImpl );
}
…
}

      DisplayImpl class is bound to Display interface
Note: Implementation of bindPresenter()
             Presenter is bound as Singleton. It means there is no new instance
             created when you invoke AppGinjector.getPresenter()
public abstract class AbstractPresenterModule extends AbstractGinModule {

protected <D extends Display> void bindPresenter( Class<? extends Presenter> presenter,
Class<D> display, Class<? extends D> displayImpl )
{
        bind( presenter ).in( Singleton.class );
        bindDisplay( display, displayImpl );
}

protected <D extends Display> void bindDisplay( Class<D> display, Class<? extends D>
displayImpl )
{
        bind( display ).to( displayImpl );
}
…
}

      DisplayImpl class is bound to Display interface
Step 4: Define AppGinjector interface




@GinModules({ClientDispatchModule.class,AppClientModule.class})
public interface AppGinjector extends Ginjector {
    public AppPresenter getAppPresenter();
    public PlaceManager getPlaceManager();
    public EventBus      getEventBus();
}
Step 4: Define AppGinjector interface

 List of modules. Each module class contains only one
 configure() method to specify
 which implementation is bound to which interface.




@GinModules({ClientDispatchModule.class,AppClientModule.class})
public interface AppGinjector extends Ginjector {
    public AppPresenter getAppPresenter();
    public PlaceManager getPlaceManager();
    public EventBus      getEventBus();
}
Step 4: Define AppGinjector interface

 List of modules. Each module class contains only one
 configure() method to specify
 which implementation is bound to which interface.

                            A helper module provided by gwt-dispatch
                            (just ignore it for now)
@GinModules({ClientDispatchModule.class,AppClientModule.class})
public interface AppGinjector extends Ginjector {
    public AppPresenter getAppPresenter();
    public PlaceManager getPlaceManager();
    public EventBus      getEventBus();
}
Step 4: Define AppGinjector interface

 List of modules. Each module class contains only one
 configure() method to specify
 which implementation is bound to which interface.

                            A helper module provided by gwt-dispatch
                            (just ignore it for now)
@GinModules({ClientDispatchModule.class,AppClientModule.class})
public interface AppGinjector extends Ginjector {
    public AppPresenter getAppPresenter();
    public PlaceManager getPlaceManager();                        You create it
    public EventBus      getEventBus();
}
                                                                  in step 3!
Step 4: Define AppGinjector interface

 List of modules. Each module class contains only one
 configure() method to specify
 which implementation is bound to which interface.

                            A helper module provided by gwt-dispatch
                            (just ignore it for now)
@GinModules({ClientDispatchModule.class,AppClientModule.class})
public interface AppGinjector extends Ginjector {
    public AppPresenter getAppPresenter();
    public PlaceManager getPlaceManager();                        You create it
    public EventBus      getEventBus();
}
                                                                  in step 3!


                              Use whatever name you want!
Step 4: Define AppGinjector interface

 List of modules. Each module class contains only one
 configure() method to specify
 which implementation is bound to which interface.

                            A helper module provided by gwt-dispatch
                            (just ignore it for now)
@GinModules({ClientDispatchModule.class,AppClientModule.class})
public interface AppGinjector extends Ginjector {
    public AppPresenter getAppPresenter();
    public PlaceManager getPlaceManager();                        You create it
    public EventBus      getEventBus();
}
                                                                  in step 3!


                               Use whatever name you want!

         Return type is important. Injector will return the instance
         basing on type.
Step 5: Using Injector in the EntryPoint


public class App implements EntryPoint{

    private final AppGinjector injector = GWT.create(AppGinjector.class);

    public void onModuleLoad() {
          AppPresenter aPres = injector.getAppPresenter();

         aPres.bind();

         RootPanel.get().add(aPres.getDisplay().asWidget());

         PlaceManager placeManager = injector.getPlaceManager();

         placeManager.fireCurrentPlace();
    }

}
Step 5: Using Injector in the EntryPoint
                                                    GWT generates the implementation
                                                    of AppGinjector at compile time
public class App implements EntryPoint{

    private final AppGinjector injector = GWT.create(AppGinjector.class);

    public void onModuleLoad() {
          AppPresenter aPres = injector.getAppPresenter();

         aPres.bind();

         RootPanel.get().add(aPres.getDisplay().asWidget());

         PlaceManager placeManager = injector.getPlaceManager();

         placeManager.fireCurrentPlace();
    }

}
Step 5: Using Injector in the EntryPoint
                                                     GWT generates the implementation
                                                     of AppGinjector at compile time
 public class App implements EntryPoint{

     private final AppGinjector injector = GWT.create(AppGinjector.class);

     public void onModuleLoad() {
           AppPresenter aPres = injector.getAppPresenter();

           aPres.bind();

           RootPanel.get().add(aPres.getDisplay().asWidget());

           PlaceManager placeManager = injector.getPlaceManager();

           placeManager.fireCurrentPlace();
     }

 }



Here are all Interfaces. Their implementations are injected by GIN.
But which implementation is bound to which Interface? => See AppClientModule   .configure()
That’s it!
Learn more
Articles:
•   Google's MVP tutorial
•   Best Practices For Architecting Your GWT App session


Projects:
•   Project google-gin
•   Project google-guice
•   Project gwt-dispatch
•   Project gwt-presenter
•   Project gwt-platform
•   A project implement MVP patterns based on gwt-dispatch, gin, guice
•   Apache Hupa – a GWT based webmail (using maven+junit+eclipse, gwt-dispatch, gwt-
    presenter, gin, guin). Highly recommended!
•   TeampScape – Another tutorial projects about gwt+gae, gwt-dispatch, gwt-presenter,
    datastore/jdo
Thank you!
anhquan.de

More Related Content

What's hot

Dependency injection with dagger 2
Dependency injection with dagger 2Dependency injection with dagger 2
Dependency injection with dagger 2Nischal0101
 
Dependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functionalDependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functionalMarian Wamsiedel
 
React ES5 to ES6 | React ES5 vs ES6 | React Tutorial for Beginners | React on...
React ES5 to ES6 | React ES5 vs ES6 | React Tutorial for Beginners | React on...React ES5 to ES6 | React ES5 vs ES6 | React Tutorial for Beginners | React on...
React ES5 to ES6 | React ES5 vs ES6 | React Tutorial for Beginners | React on...Edureka!
 
AOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformAOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformPeter Pilgrim
 
3 Simple Steps to follow to Create React JS Components
3 Simple Steps to follow to Create React JS Components3 Simple Steps to follow to Create React JS Components
3 Simple Steps to follow to Create React JS ComponentsSurendra kumar
 
Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleMarian Wamsiedel
 
Visage Android Hands-on Lab
Visage Android Hands-on LabVisage Android Hands-on Lab
Visage Android Hands-on LabStephen Chin
 
Building android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...
Building  android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...Building  android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...
Building android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...Hammad Tariq
 
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...Peter Pilgrim
 
Neoito — Design patterns and depenedency injection
Neoito — Design patterns and depenedency injectionNeoito — Design patterns and depenedency injection
Neoito — Design patterns and depenedency injectionNeoito
 
Padroes Projeto
Padroes ProjetoPadroes Projeto
Padroes Projetolcbj
 
Java Graphics Programming
Java Graphics ProgrammingJava Graphics Programming
Java Graphics ProgrammingRiccardo Cardin
 
Dependency injection: koin vs dagger
Dependency injection: koin vs daggerDependency injection: koin vs dagger
Dependency injection: koin vs daggerMatteo Pasotti
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builderMaurizio Vitale
 
Level Up Your Android Build -Droidcon Berlin 2015
Level Up Your Android Build -Droidcon Berlin 2015Level Up Your Android Build -Droidcon Berlin 2015
Level Up Your Android Build -Droidcon Berlin 2015Friedger Müffke
 

What's hot (16)

Dependency injection with dagger 2
Dependency injection with dagger 2Dependency injection with dagger 2
Dependency injection with dagger 2
 
Dependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functionalDependency injection in Java, from naive to functional
Dependency injection in Java, from naive to functional
 
React ES5 to ES6 | React ES5 vs ES6 | React Tutorial for Beginners | React on...
React ES5 to ES6 | React ES5 vs ES6 | React Tutorial for Beginners | React on...React ES5 to ES6 | React ES5 vs ES6 | React Tutorial for Beginners | React on...
React ES5 to ES6 | React ES5 vs ES6 | React Tutorial for Beginners | React on...
 
Guice
GuiceGuice
Guice
 
AOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformAOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java Platform
 
3 Simple Steps to follow to Create React JS Components
3 Simple Steps to follow to Create React JS Components3 Simple Steps to follow to Create React JS Components
3 Simple Steps to follow to Create React JS Components
 
Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical example
 
Visage Android Hands-on Lab
Visage Android Hands-on LabVisage Android Hands-on Lab
Visage Android Hands-on Lab
 
Building android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...
Building  android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...Building  android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...
Building android apps with MVP, Dagger, Retrofit, Gson, JSON, Kotlin Data Cl...
 
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...
 
Neoito — Design patterns and depenedency injection
Neoito — Design patterns and depenedency injectionNeoito — Design patterns and depenedency injection
Neoito — Design patterns and depenedency injection
 
Padroes Projeto
Padroes ProjetoPadroes Projeto
Padroes Projeto
 
Java Graphics Programming
Java Graphics ProgrammingJava Graphics Programming
Java Graphics Programming
 
Dependency injection: koin vs dagger
Dependency injection: koin vs daggerDependency injection: koin vs dagger
Dependency injection: koin vs dagger
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builder
 
Level Up Your Android Build -Droidcon Berlin 2015
Level Up Your Android Build -Droidcon Berlin 2015Level Up Your Android Build -Droidcon Berlin 2015
Level Up Your Android Build -Droidcon Berlin 2015
 

Viewers also liked

Вебинар начало
Вебинар началоВебинар начало
Вебинар началоcatarus
 
Осознанность рефакторинга: Модель принятия инженерных решений
Осознанность рефакторинга: Модель принятия инженерных решенийОсознанность рефакторинга: Модель принятия инженерных решений
Осознанность рефакторинга: Модель принятия инженерных решенийEvgeniy Krivosheev
 
CodeFest 2013. Зиновьев А. — MyBatis & Hibernate, давайте жить дружно!
CodeFest 2013. Зиновьев А. — MyBatis & Hibernate, давайте жить дружно!CodeFest 2013. Зиновьев А. — MyBatis & Hibernate, давайте жить дружно!
CodeFest 2013. Зиновьев А. — MyBatis & Hibernate, давайте жить дружно!CodeFest
 
Введение в веб каркас Struts2
Введение в веб каркас Struts2Введение в веб каркас Struts2
Введение в веб каркас Struts2Evgeniy Krivosheev
 
Transactions and Concurrency Control Patterns
Transactions and Concurrency Control PatternsTransactions and Concurrency Control Patterns
Transactions and Concurrency Control PatternsVlad Mihalcea
 
High-Performance JDBC Voxxed Bucharest 2016
High-Performance JDBC Voxxed Bucharest 2016High-Performance JDBC Voxxed Bucharest 2016
High-Performance JDBC Voxxed Bucharest 2016Vlad Mihalcea
 
High-Performance Hibernate Devoxx France 2016
High-Performance Hibernate Devoxx France 2016High-Performance Hibernate Devoxx France 2016
High-Performance Hibernate Devoxx France 2016Vlad Mihalcea
 
High Performance Hibernate JavaZone 2016
High Performance Hibernate JavaZone 2016High Performance Hibernate JavaZone 2016
High Performance Hibernate JavaZone 2016Vlad Mihalcea
 
DeNAの分析を支える分析基盤
DeNAの分析を支える分析基盤DeNAの分析を支える分析基盤
DeNAの分析を支える分析基盤Kenshin Yamada
 

Viewers also liked (10)

Вебинар начало
Вебинар началоВебинар начало
Вебинар начало
 
Tdd Workshop Disscussions
Tdd Workshop DisscussionsTdd Workshop Disscussions
Tdd Workshop Disscussions
 
Осознанность рефакторинга: Модель принятия инженерных решений
Осознанность рефакторинга: Модель принятия инженерных решенийОсознанность рефакторинга: Модель принятия инженерных решений
Осознанность рефакторинга: Модель принятия инженерных решений
 
CodeFest 2013. Зиновьев А. — MyBatis & Hibernate, давайте жить дружно!
CodeFest 2013. Зиновьев А. — MyBatis & Hibernate, давайте жить дружно!CodeFest 2013. Зиновьев А. — MyBatis & Hibernate, давайте жить дружно!
CodeFest 2013. Зиновьев А. — MyBatis & Hibernate, давайте жить дружно!
 
Введение в веб каркас Struts2
Введение в веб каркас Struts2Введение в веб каркас Struts2
Введение в веб каркас Struts2
 
Transactions and Concurrency Control Patterns
Transactions and Concurrency Control PatternsTransactions and Concurrency Control Patterns
Transactions and Concurrency Control Patterns
 
High-Performance JDBC Voxxed Bucharest 2016
High-Performance JDBC Voxxed Bucharest 2016High-Performance JDBC Voxxed Bucharest 2016
High-Performance JDBC Voxxed Bucharest 2016
 
High-Performance Hibernate Devoxx France 2016
High-Performance Hibernate Devoxx France 2016High-Performance Hibernate Devoxx France 2016
High-Performance Hibernate Devoxx France 2016
 
High Performance Hibernate JavaZone 2016
High Performance Hibernate JavaZone 2016High Performance Hibernate JavaZone 2016
High Performance Hibernate JavaZone 2016
 
DeNAの分析を支える分析基盤
DeNAの分析を支える分析基盤DeNAの分析を支える分析基盤
DeNAの分析を支える分析基盤
 

Similar to Google GIN

Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Introduction to Google Guice
Introduction to Google GuiceIntroduction to Google Guice
Introduction to Google GuiceKnoldus Inc.
 
Creating a windowed program
Creating a windowed programCreating a windowed program
Creating a windowed programmyrajendra
 
Quick Start to iOS Development
Quick Start to iOS DevelopmentQuick Start to iOS Development
Quick Start to iOS DevelopmentJussi Pohjolainen
 
Building maintainable app #droidconzg
Building maintainable app #droidconzgBuilding maintainable app #droidconzg
Building maintainable app #droidconzgKristijan Jurković
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersJiaxuan Lin
 
Android architecture
Android architecture Android architecture
Android architecture Trong-An Bui
 
Integrating external products into eclipse
Integrating external products into eclipseIntegrating external products into eclipse
Integrating external products into eclipseGirish Balre
 
Hacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfHacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfShaiAlmog1
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andevMike Nakhimovich
 
Mobile Application Development with JUCE and Native API’s
Mobile Application Development with JUCE and Native API’sMobile Application Development with JUCE and Native API’s
Mobile Application Development with JUCE and Native API’sAdam Wilson
 
MEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr WlodekMEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr Wlodekinfusiondev
 
Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...naseeb20
 
Vaadin DevDay 2017 - DI your UI
Vaadin DevDay 2017 - DI your UIVaadin DevDay 2017 - DI your UI
Vaadin DevDay 2017 - DI your UIPeter Lehto
 

Similar to Google GIN (20)

Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Introduction to Google Guice
Introduction to Google GuiceIntroduction to Google Guice
Introduction to Google Guice
 
Creating a windowed program
Creating a windowed programCreating a windowed program
Creating a windowed program
 
GWT MVP Case Study
GWT MVP Case StudyGWT MVP Case Study
GWT MVP Case Study
 
Quick Start to iOS Development
Quick Start to iOS DevelopmentQuick Start to iOS Development
Quick Start to iOS Development
 
Building maintainable app
Building maintainable appBuilding maintainable app
Building maintainable app
 
Building maintainable app #droidconzg
Building maintainable app #droidconzgBuilding maintainable app #droidconzg
Building maintainable app #droidconzg
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
Rcp by example
Rcp by exampleRcp by example
Rcp by example
 
Android architecture
Android architecture Android architecture
Android architecture
 
Integrating external products into eclipse
Integrating external products into eclipseIntegrating external products into eclipse
Integrating external products into eclipse
 
Hacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfHacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdf
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
Mobile Application Development with JUCE and Native API’s
Mobile Application Development with JUCE and Native API’sMobile Application Development with JUCE and Native API’s
Mobile Application Development with JUCE and Native API’s
 
MEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr WlodekMEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr Wlodek
 
Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...
 
Visage fx
Visage fxVisage fx
Visage fx
 
Vaadin DevDay 2017 - DI your UI
Vaadin DevDay 2017 - DI your UIVaadin DevDay 2017 - DI your UI
Vaadin DevDay 2017 - DI your UI
 

Recently uploaded

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Google GIN

  • 1. GIN A basic tutorial by anhquan.de
  • 2. What the heck is Google GIN? • GIN = GWT INjection • Guice brings automatic dependency injection to server side code, while GIN is for client-side code. • GIN is built on top of Guice and uses (a subset of) Guice's binding language
  • 3. What the heck is Google GIN? • GIN = GWT INjection • Guice brings automatic dependency injection to server side code, while GIN is for client-side code. • GIN is built on top of Guice and uses (a subset of) Guice's binding language GWT client-side code GIN
  • 4. What the heck is Google GIN? • GIN = GWT INjection • Guice brings automatic dependency injection to server side code, while GIN is for client-side code. • GIN is built on top of Guice and uses (a subset of) Guice's binding language GWT client-side GWT server-side code code GIN Guice
  • 5. This tutorial shows you How to use GIN ?
  • 6. 5 Steps to remember 1. Design the application with Interfaces IA,IB,…
  • 7. 5 Steps to remember 1. Design the application with Interfaces IA,IB,… 2. Create concrete classes AImpl, BImpl,… to implement interfaces IA,IB,… Remember: use @Inject to mark the non-default constructor.
  • 8. 5 Steps to remember 1. Design the application with Interfaces IA,IB,… 2. Create concrete classes AImpl, BImpl,… to implement interfaces IA,IB,… Remember: use @Inject to mark the non-default constructor. 3. Create AppClientModule to configure which implementation is bound to which interface
  • 9. 5 Steps to remember 1. Design the application with Interfaces IA,IB,… 2. Create concrete classes AImpl, BImpl,… to implement interfaces IA,IB,… Remember: use @Inject to mark the non-default constructor. 3. Create AppClientModule to configure which implementation is bound to which interface 4. Create interface AppGinjector with the AppClientModule in the annotation @GinModules. @GinModules({AppClientModule.class, other modules …})
  • 10. 5 Steps to remember 1. Design the application with Interfaces IA,IB,… 2. Create concrete classes AImpl, BImpl,… to implement interfaces IA,IB,… Remember: use @Inject to mark the non-default constructor. 3. Create AppClientModule to configure which implementation is bound to which interface 4. Create interface AppGinjector with the AppClientModule in the annotation @GinModules. @GinModules({AppClientModule.class, other modules …}) 5. Generate code for AppGinjector and use it private final AppGinjector injector = GWT.create(AppGinjector.class); AppPresenter aPres = injector.getAppPresenter(); aPres.bind(); RootPanel.get().add(aPres.getDisplay().asWidget());
  • 11. Step 1: Design an Interface public class ConfigPresenter extends WidgetPresenter<ConfigPresenter.Display>{ public interface Display extends NameAwareWidgetDisplay, WidgetDisplay { public HasClickHandlers getSaveClick(); public void updateConfig(Config config); } … }
  • 12. Step 1: Design an Interface public class ConfigPresenter extends WidgetPresenter<ConfigPresenter.Display>{ public interface Display extends NameAwareWidgetDisplay, WidgetDisplay { public HasClickHandlers getSaveClick(); public void updateConfig(Config config); } … } For gwt-dispatch developers: Normally, we create a Display interface as an inner interface of a Presenter class
  • 13. Step 2: Implement the interface public class ConfigView extends Composite implements ConfigPresenter.Display { private VerticalPanel panel = new VerticalPanel(); private AppConstants constants; @Inject public ConfigView(AppConstants constants, AppMessages messages) { this.constants = constants; panel.addStyleName(AppCSS.C_config_container); panel.add(new HTML("<h1>Config view: comming soon<h1>")); initWidget(panel); } … }
  • 14. Step 2: Implement the interface If the class has no default constructor, then a @Inject annotation is required. Otherwise, you will get a RuntimeException (“No @Inject or default constructor found for class …. ”) public class ConfigView extends Composite implements ConfigPresenter.Display { private VerticalPanel panel = new VerticalPanel(); private AppConstants constants; @Inject public ConfigView(AppConstants constants, AppMessages messages) { this.constants = constants; panel.addStyleName(AppCSS.C_config_container); panel.add(new HTML("<h1>Config view: comming soon<h1>")); initWidget(panel); } … }
  • 15. Step 3: Create class AppClientModule public class AppClientModule extends AbstractPresenterModule { @Override protected void configure() { bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class); bind(PlaceManager.class).to(AppPlaceManager.class); bindPresenter(LoginPresenter.class, LoginPresenter.Display.class, LoginView.class); bindPresenter(MainPresenter.class, MainPresenter.Display.class, MainView.class); bindPresenter(AppPresenter.class, AppPresenter.Display.class, AppView.class); bind(LoginPresenterPlace.class).in(Singleton.class); bind(ContactsPresenterPlace.class).in(Singleton.class); … bind(LoginPresenter.class).in(Singleton.class); bind(LoginPresenter.Display.class).to(LoginView.class); } }
  • 16. Step 3: Create class AppClientModule public class AppClientModule extends AbstractPresenterModule { @Override protected void configure() { bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class); bind(PlaceManager.class).to(AppPlaceManager.class); bindPresenter(LoginPresenter.class, LoginPresenter.Display.class, LoginView.class); bindPresenter(MainPresenter.class, MainPresenter.Display.class, MainView.class); bindPresenter(AppPresenter.class, AppPresenter.Display.class, AppView.class); bind(LoginPresenterPlace.class).in(Singleton.class); bind(ContactsPresenterPlace.class).in(Singleton.class); … bind(LoginPresenter.class).in(Singleton.class); bind(LoginPresenter.Display.class).to(LoginView.class); } } Don’t need to bind LoginPresenter and LoginPresenter.Display Because they are already “bind” above in the bindPresenter(…) See the implementation of the bindPresenter() in the next slide …
  • 17. Note: Implementation of bindPresenter() public abstract class AbstractPresenterModule extends AbstractGinModule { protected <D extends Display> void bindPresenter( Class<? extends Presenter> presenter, Class<D> display, Class<? extends D> displayImpl ) { bind( presenter ).in( Singleton.class ); bindDisplay( display, displayImpl ); } protected <D extends Display> void bindDisplay( Class<D> display, Class<? extends D> displayImpl ) { bind( display ).to( displayImpl ); } … }
  • 18. Note: Implementation of bindPresenter() public abstract class AbstractPresenterModule extends AbstractGinModule { protected <D extends Display> void bindPresenter( Class<? extends Presenter> presenter, Class<D> display, Class<? extends D> displayImpl ) { bind( presenter ).in( Singleton.class ); bindDisplay( display, displayImpl ); } protected <D extends Display> void bindDisplay( Class<D> display, Class<? extends D> displayImpl ) { bind( display ).to( displayImpl ); } … } DisplayImpl class is bound to Display interface
  • 19. Note: Implementation of bindPresenter() Presenter is bound as Singleton. It means there is no new instance created when you invoke AppGinjector.getPresenter() public abstract class AbstractPresenterModule extends AbstractGinModule { protected <D extends Display> void bindPresenter( Class<? extends Presenter> presenter, Class<D> display, Class<? extends D> displayImpl ) { bind( presenter ).in( Singleton.class ); bindDisplay( display, displayImpl ); } protected <D extends Display> void bindDisplay( Class<D> display, Class<? extends D> displayImpl ) { bind( display ).to( displayImpl ); } … } DisplayImpl class is bound to Display interface
  • 20. Step 4: Define AppGinjector interface @GinModules({ClientDispatchModule.class,AppClientModule.class}) public interface AppGinjector extends Ginjector { public AppPresenter getAppPresenter(); public PlaceManager getPlaceManager(); public EventBus getEventBus(); }
  • 21. Step 4: Define AppGinjector interface List of modules. Each module class contains only one configure() method to specify which implementation is bound to which interface. @GinModules({ClientDispatchModule.class,AppClientModule.class}) public interface AppGinjector extends Ginjector { public AppPresenter getAppPresenter(); public PlaceManager getPlaceManager(); public EventBus getEventBus(); }
  • 22. Step 4: Define AppGinjector interface List of modules. Each module class contains only one configure() method to specify which implementation is bound to which interface. A helper module provided by gwt-dispatch (just ignore it for now) @GinModules({ClientDispatchModule.class,AppClientModule.class}) public interface AppGinjector extends Ginjector { public AppPresenter getAppPresenter(); public PlaceManager getPlaceManager(); public EventBus getEventBus(); }
  • 23. Step 4: Define AppGinjector interface List of modules. Each module class contains only one configure() method to specify which implementation is bound to which interface. A helper module provided by gwt-dispatch (just ignore it for now) @GinModules({ClientDispatchModule.class,AppClientModule.class}) public interface AppGinjector extends Ginjector { public AppPresenter getAppPresenter(); public PlaceManager getPlaceManager(); You create it public EventBus getEventBus(); } in step 3!
  • 24. Step 4: Define AppGinjector interface List of modules. Each module class contains only one configure() method to specify which implementation is bound to which interface. A helper module provided by gwt-dispatch (just ignore it for now) @GinModules({ClientDispatchModule.class,AppClientModule.class}) public interface AppGinjector extends Ginjector { public AppPresenter getAppPresenter(); public PlaceManager getPlaceManager(); You create it public EventBus getEventBus(); } in step 3! Use whatever name you want!
  • 25. Step 4: Define AppGinjector interface List of modules. Each module class contains only one configure() method to specify which implementation is bound to which interface. A helper module provided by gwt-dispatch (just ignore it for now) @GinModules({ClientDispatchModule.class,AppClientModule.class}) public interface AppGinjector extends Ginjector { public AppPresenter getAppPresenter(); public PlaceManager getPlaceManager(); You create it public EventBus getEventBus(); } in step 3! Use whatever name you want! Return type is important. Injector will return the instance basing on type.
  • 26. Step 5: Using Injector in the EntryPoint public class App implements EntryPoint{ private final AppGinjector injector = GWT.create(AppGinjector.class); public void onModuleLoad() { AppPresenter aPres = injector.getAppPresenter(); aPres.bind(); RootPanel.get().add(aPres.getDisplay().asWidget()); PlaceManager placeManager = injector.getPlaceManager(); placeManager.fireCurrentPlace(); } }
  • 27. Step 5: Using Injector in the EntryPoint GWT generates the implementation of AppGinjector at compile time public class App implements EntryPoint{ private final AppGinjector injector = GWT.create(AppGinjector.class); public void onModuleLoad() { AppPresenter aPres = injector.getAppPresenter(); aPres.bind(); RootPanel.get().add(aPres.getDisplay().asWidget()); PlaceManager placeManager = injector.getPlaceManager(); placeManager.fireCurrentPlace(); } }
  • 28. Step 5: Using Injector in the EntryPoint GWT generates the implementation of AppGinjector at compile time public class App implements EntryPoint{ private final AppGinjector injector = GWT.create(AppGinjector.class); public void onModuleLoad() { AppPresenter aPres = injector.getAppPresenter(); aPres.bind(); RootPanel.get().add(aPres.getDisplay().asWidget()); PlaceManager placeManager = injector.getPlaceManager(); placeManager.fireCurrentPlace(); } } Here are all Interfaces. Their implementations are injected by GIN. But which implementation is bound to which Interface? => See AppClientModule .configure()
  • 30. Learn more Articles: • Google's MVP tutorial • Best Practices For Architecting Your GWT App session Projects: • Project google-gin • Project google-guice • Project gwt-dispatch • Project gwt-presenter • Project gwt-platform • A project implement MVP patterns based on gwt-dispatch, gin, guice • Apache Hupa – a GWT based webmail (using maven+junit+eclipse, gwt-dispatch, gwt- presenter, gin, guin). Highly recommended! • TeampScape – Another tutorial projects about gwt+gae, gwt-dispatch, gwt-presenter, datastore/jdo