Revision: dc8549564eec
Author:   sberlin <sber...@gmail.com>
Date:     Mon Feb 10 15:19:43 2014 UTC
Log:      simplify example
http://code.google.com/p/google-guice/source/detail?r=dc8549564eec&repo=wiki

Modified:
 /GettingStarted.wiki

=======================================
--- /GettingStarted.wiki        Sat May 21 18:15:32 2011 UTC
+++ /GettingStarted.wiki        Mon Feb 10 15:19:43 2014 UTC
@@ -4,14 +4,14 @@

Building object graphs by hand is labour intensive, error prone, and makes testing difficult. Instead, Guice can build the object graph for you. But first, Guice needs to be configured to build the graph exactly as you want it.

-To illustrate, we'll start the `RealBillingService` class that accepts its dependent interfaces `CreditCardProcessor` and `TransactionLog` in its constructor. To make it explicit that the `RealBillingService` constructor is invoked by Guice, we add the `@Inject` annotation: +To illustrate, we'll start the `BillingService` class that accepts its dependent interfaces `CreditCardProcessor` and `TransactionLog` in its constructor. To make it explicit that the `BillingService` constructor is invoked by Guice, we add the `@Inject` annotation:
 {{{
-class RealBillingService implements BillingService {
+class BillingService {
   private final CreditCardProcessor processor;
   private final TransactionLog transactionLog;

   @Inject
-  RealBillingService(CreditCardProcessor processor,
+  BillingService(CreditCardProcessor processor,
       TransactionLog transactionLog) {
     this.processor = processor;
     this.transactionLog = transactionLog;
@@ -23,7 +23,7 @@
   }
 }
 }}}
-We want to build a `RealBillingService` using `PaypalCreditCardProcessor` and `DatabaseTransactionLog`. Guice uses *bindings* to map types to their implementations. A *module* is a collection of bindings specified using fluent, English-like method calls: +We want to build a `BillingService` using `PaypalCreditCardProcessor` and `DatabaseTransactionLog`. Guice uses *bindings* to map types to their implementations. A *module* is a collection of bindings specified using fluent, English-like method calls:
 {{{
 public class BillingModule extends AbstractModule {
   @Override
@@ -43,7 +43,7 @@
   }
 }
 }}}
-The modules are the building blocks of an *injector*, which is Guice's object-graph builder. First we create the injector, and then we can use that to build the `RealBillingService`: +The modules are the building blocks of an *injector*, which is Guice's object-graph builder. First we create the injector, and then we can use that to build the `BillingService`:
 {{{
  public static void main(String[] args) {
     /*
@@ -56,7 +56,7 @@
     /*
      * Now that we've got the injector, we can build objects.
      */
- RealBillingService billingService = injector.getInstance(RealBillingService.class); + BillingService billingService = injector.getInstance(BillingService.class);
     ...
   }
 }}}

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-guice-dev+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice-dev@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice-dev.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to