Skip to content

Commit

Permalink
Update App.java
Browse files Browse the repository at this point in the history
  • Loading branch information
kapinuss authored May 18, 2017
1 parent 2b229d8 commit 09aa44d
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.inject.Injector;

/**
*
* Dependency Injection pattern deals with how objects handle their dependencies. The pattern
* implements so called inversion of control principle. Inversion of control has two specific rules:
* - High-level modules should not depend on low-level modules. Both should depend on abstractions.
Expand All @@ -45,28 +44,27 @@
* The fourth example takes the pattern a step further. It uses Guice framework for Dependency
* Injection. {@link TobaccoModule} binds a concrete implementation to abstraction. Injector is then
* used to create {@link GuiceWizard} object with correct dependencies.
*
*/
public class App {

/**
* Program entry point
*
* @param args command line args
*/
public static void main(String[] args) {
SimpleWizard simpleWizard = new SimpleWizard();
simpleWizard.smoke();
/**
* Program entry point
*
* @param args command line args
*/
public static void main(String[] args) {
SimpleWizard simpleWizard = new SimpleWizard();
simpleWizard.smoke();

AdvancedWizard advancedWizard = new AdvancedWizard(new SecondBreakfastTobacco());
advancedWizard.smoke();
AdvancedWizard advancedWizard = new AdvancedWizard(new SecondBreakfastTobacco());
advancedWizard.smoke();

AdvancedSorceress advancedSorceress = new AdvancedSorceress();
advancedSorceress.setTobacco(new SecondBreakfastTobacco());
advancedSorceress.smoke();
AdvancedSorceress advancedSorceress = new AdvancedSorceress();
advancedSorceress.setTobacco(new SecondBreakfastTobacco());
advancedSorceress.smoke();

Injector injector = Guice.createInjector(new TobaccoModule());
GuiceWizard guiceWizard = injector.getInstance(GuiceWizard.class);
guiceWizard.smoke();
}
Injector injector = Guice.createInjector(new TobaccoModule());
GuiceWizard guiceWizard = injector.getInstance(GuiceWizard.class);
guiceWizard.smoke();
}
}

0 comments on commit 09aa44d

Please sign in to comment.