Your SlideShare is downloading. ×
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Google Guice
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Google Guice

4,274

Published on

10-th meetuo of Java User Group of Lviv

10-th meetuo of Java User Group of Lviv

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,274
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
77
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Google guice It’s easy © Skelia 201 1
  • 2. Agenda
    • Pattern Dependency injection
    • Why we need DI
    • Google guice introduction
    • Guice simple injection
    • Integration with Servlets
    • Integration with Guice
    • Philosophy
    • Instead of summary
    • Q&A
    © Skelia 2011
  • 3. DI or Don't Call Me, I Will Call You
    • Dependency injection  ( DI ) in  object-oriented   computer programming  is a technique that indicates to a part of a program which other parts it can use, i.e. to supply an  external dependency  – a reference – to a  software component . In technical terms, it is a  design pattern  that separates behavior from  dependency resolution , thus decoupling highly dependent components.
    © Skelia 2011 Wikipedia: http://en.wikipedia.org/wiki/Dependency_injection
  • 4. DI or Don't Call Me, I Will Call You
    • Dependency injection  ( DI ) in  object-oriented   computer programming  is a technique that indicates to a part of a program which other parts it can use, i.e. to supply an  external dependency  – a reference – to a  software component . In technical terms, it is a  design pattern  that separates behavior from  dependency resolution , thus decoupling highly dependent components.
    © Skelia 2011 Wikipedia: http://en.wikipedia.org/wiki/Dependency_injection
  • 5. DI or Don't Call Me, I Will Call You © Skelia 2011
  • 6. DI or Don't Call Me, I Will Call You © Skelia 2011 Wild programmer Spaghetti Architecture
  • 7. Google Guice © Skelia 2011 Google-Guice Current version 3.0 Guice (pronounced 'juice') is a lightweight dependency injection framework for Java 5 and above, brought to you by Google.
  • 8. Google Guice © Skelia 2011
  • 9. Google Guice (Module) © Skelia 2011
    • Module Types:
    • Non-obvious
    • AbstractModule
    • ServletModule
  • 10. Google Guice (Binding) © Skelia 2011
    • Binding types:
    • Bind implementation
    • bind(PaymentCashImpl.class)
    • Bind implementation to interface bind(Payment.class).to(PaymentCardImpl.class)
    • Bind multiple implementation to interface
    • bind(Payment.class).annotatedWith(Cash.class).to(PaymentCashImpl.class)
    • bind(Payment.class).annotatedWith(Names.named("Cash")).to(PaymentCashImpl.class)
  • 11. Google Guice (Injection) © Skelia 2011
    • Injection types :
    • Constructor
    • Method
    • Field (not recommended)
    • @Inject private @Card Payment payment;
    • @ Named("PaymentType") @Inject private String text;
  • 12. Google Guice (Provides) © Skelia 2011   public class PayModule extends AbstractModule{   protected void configure() {     }     @Provides     Payment providePayment(){         CashPayment pay = new CashPayment();         pay.setAmount(100);         return pay;     } @Provides List<String> providesListOfString() { return new ArrayList<String>(); } @Inject public void setList(List<String> list)
  • 13. Google Guice (Scope) © Skelia 2011
  • 14. Google Guice (AOP) © Skelia 2011
  • 15. Google Guice (Sample) © Skelia 2011
  • 16. Google Guice (Servlet integration) © Skelia 2011
  • 17. Google Guice (Sample) © Skelia 2011
  • 18. Google Guice (Integration) © Skelia 2011 Mobile RoboGuice - Guice for Android.
    • Other Languages
      • Groovy-Guice - Groovy
      • Ninject - .NET
      • Snake Guice - Python
      • Smartypants-IOC - Flex/AS3
      • Dawn - AS3
  • 19. Google Guice (Integration) © Skelia 2011
  • 20. Google Guice (philosophy) © Skelia 2011
  • 21. Google Guice (philosophy) © Skelia 2011
  • 22. Instead of Conclusion © Skelia 2011
  • 23. Thank you ! © Skelia 2011

×