, , , Guice docs . , Guice Guice : API .
, , , . , MyAppInterface, , (getContentPane() , ) MyApp . MyAppInterface MyApp ( providesMyApp ), MyAppInterface . MyApp MyAppInterface, .
Guice . , MyAppInterface , -, , , MyApp, MyApp , Guice, .
MyAppInterface , , MyApp MyApp MyAppImpl.
, Guice , - - , , .
: Groovy Gradle, SSCCE , , . DefaultFizzClient @Provides @Singleton menuBar provideExampleApp, , .
@Singleton: @Singleton, . , . @Singleton, Guice , . . , " X" " X". , , , - , ..
menuBar: , . . , , addMenuToFrame requestInjection(this).
, , Guice, :
ExampleAppModule, configure(). Guice, , , ExampleAppModule , @Inject .configure() , , Guice requestInjection(this). , addMenuToFrame @Inject. , , ExampleApp JMenuBar.- Guice
ExampleApp provideExampleApp. Guice , FizzClient. - Guice
FizzClient DefaultFizzClient. DefaultFizzClient no-args , Guice , . FizzClient, Guice provideExampleApp. , ExampleApp.addMenuToFrame - JMenuBar, providesMenuBar. Guice , ActionListener "widgetsMenuActionListener".- Guice
ActionListener "widgetsMenuActionListener" providesWidgetsMenuActionListener. Guice , ExampleApp JPanel "widgetsPanel". ExampleApp, 5, -, @Singleton, , provideExampleApp . - Guice
JPanel "widgetsPanel" providesWidgetPanel. , Guice JPanel, . JPanel ExampleApp, Guice providesWidgetsMenuActionListener, ActionListener.ActionListener , Guice providesMenuBar, JMenuBar.- , ,
ExampleApp JMenuBar, Guice addMenuToFrame, . - , ,
getInstance(ExampleApp) main . Guice , ExampleApp , @Singleton, .
, , @Singleton provideExampleApp, , .