• 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: Henrique Prange <email@hidden>
  • Date: Wed, 11 Apr 2012 18:12:53 -0300

Hi Lachlan,

Indeed, that is a much simpler and straight to the point solution. :)

Cheers,

Henrique

On 11/04/2012, at 15:55, Lachlan Deck wrote:

> On 11/04/2012, at 12:28 PM, Ramsey Gurley wrote:
>
>> What if I want an advanced service on component one and a basic service on component two?
>
> class ComponentOne
> {
> 	@Inject
> 	AdvancedService service;
> }
> class ComponentTwo
> {
> 	@Inject
> 	BasicService service;
> }
>
> <...>
> class AppModule
> {
> 	void configure()
> 	{
> 		bind(BasicService.class).to(BasicServiceImpl.class);
> 		bind(AdvancedService.class).to(AdvancedServiceImpl.class);
> 	}
> }
>
> Next you'll ask, what if I have two types of advanced services and depending on certain conditions I want one or the other (e.g., session-aware or not). It's quite flexible and can be nicely done. Refer to guice docs.
>
> e.g.,
> bind(ConditionalService.class).toProvider(ConditionalServiceProvider.class);
>
> class ConditionalServiceProvider implements Provider<ConditionalService>
> {
> 	@Inject @Current
> 	WOContext context;
>
> 	public ConditionalService get()
> 	{
> 		<...>
> 	}
> }
>
> The other thing to say about IoC is that it serves another purpose, that of allowing for easy mocking in unit tests, and testing that 'thing' separately.
>
> cheers,
> Lachlan Deck
>


 _______________________________________________
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: Ron X <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>)
 >Re: [ANN] WOInject 1.0 (From: Ramsey Gurley <email@hidden>)
 >Re: [ANN] WOInject 1.0 (From: Lachlan Deck <email@hidden>)

  • Prev by Date: Re: [ANN] WOInject 1.0
  • Next by Date: Order by primary key
  • Previous by thread: Re: [ANN] WOInject 1.0
  • Next by thread: Re: [ANN] WOInject 1.0
  • Index(es):
    • Date
    • Thread