Comment #4 on issue 231 by limpbizkit: Support mixed injection and manual  
wiring
http://code.google.com/p/google-guice/issues/detail?id=231

Plan:
We'll Introduce a special binding annotation called '@New'. It is an error  
to bind to @New by hand; ie. it's an
error to do this:
   bind(Foo.class).annotatedWith(New.class).to(...)
When an injection point asks for an @New Foo, we create a default binding  
for the constructor of Foo. Foo
must always be a concrete class with a Guice-invokable constructor (ie.  
@Inject or public no-args).

Complications:
What happens if Foo.class is annotated @Singleton? Do I get the same  
instance each time I inject @New Foo?
Or different ones?
Suppose I inject both Foo and @New Foo. If Foo.class is annotaed  
@Singleton, do I get the same instance?

SPI Considerations:
I'm tempted to make it so @New is 1:1 with constructor bindings. For  
example, given this code:
    bind(Bar.class).to(BarImpl.class);
Guice would create 3 bindings:
    Bar.class linked to BarImpl.class (explicit)
    BarImpl.class linked to @New BarImpl.class (default)
    @New BarImpl to its own constructor (built-in)

Syntactic Sugar:
We confound linked bindings and constructor bindings in the current Guice.  
It means you can't solve the
turkey bacon problem [http://tinyurl.com/turkeybaconproblem]. So I'd like  
to introduce some syntactic sugar
related to @New:
   bind(Bar.class).toConstructor(BarImpl.class);
      is syntactic sugar for:
   bind(Bar.class).to(Key.get(BarImpl.class, New.class));



-- 
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to