• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [ANN] WOInject 1.0
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ANN] WOInject 1.0


  • Subject: Re: [ANN] WOInject 1.0
  • From: Ramsey Gurley <email@hidden>
  • Date: Tue, 10 Apr 2012 19:28:15 -0700

On Apr 7, 2012, at 8:07 PM, Henrique Prange wrote:

> Suppose you have a Service interface and a BasicService implementation for it. This Service is required across your components. So you have something like this:
>
> class ComponentOne {
> 	Service service = new BasicService();
> }
>
> class ComponentTwo {
> 	Service service = new BasicService();
> }
>
> ...
>
> Then, the project evolves, and you develop a new AdvancedService implementation for the Service interface. You have to traverse the entire code base updating the instantiation of Service.
>
> On the other hand, if you use Guice, you can delegate the creation of Services to Guice, and inject the instances of Service when required. You write code like this:
>
> class ComponentOne {
> 	@Inject
> 	Service service;
> }
>
> class ComponentTwo {
> 	@Inject
> 	Service service;
> }
>
> ...
>
> And you configure a Guice Module to specify that you want an instance of BasicService (or an AdvancedService) when you need a Service.
>
> class AppModule extends AbstractModule {
> 	void configure() {
> 		bind(Service.class).to(BasicService.class);
> 	}
> }
>
> If you need to change the implementation class, you just have to redefine your module:
>
> class AppModule extends AbstractModule {
> 	void configure() {
> 		bind(Service.class).to(AdvancedService.class);
> 	}
> }
>

What if I want an advanced service on component one and a basic service on component two?

Ramsey


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: [ANN] WOInject 1.0
      • From: Henrique Prange <email@hidden>
    • Re: [ANN] WOInject 1.0
      • From: Lachlan Deck <email@hidden>
References: 
 >Re: [ANN] WOInject 1.0 (From: Paul Hoadley <email@hidden>)
 >Re: [ANN] WOInject 1.0 (From: Henrique Prange <email@hidden>)
 >Re: [ANN] WOInject 1.0 (From: "Ricardo J. Parada" <email@hidden>)
 >Re: [ANN] WOInject 1.0 (From: Henrique Prange <email@hidden>)

  • Prev by Date: Re: preventing direct component access
  • Next by Date: Re: preventing direct component access
  • Previous by thread: Re: [ANN] WOInject 1.0
  • Next by thread: Re: [ANN] WOInject 1.0
  • Index(es):
    • Date
    • Thread