Status: New
Owner: ----

New issue 441 by [email protected]: [RFE] Add annotations for  
AssistedInjected factories
http://code.google.com/p/google-guice/issues/detail?id=441

I just thought Guice may use annotations for AssistedInject as it does
normally.


@ImplementedBy(BasicStuff.class)
interface Stuff {  }

// Class is invalid (2x same method signature), but it's just for the show
// Equivalent to bind(StuffFactory)
//    .to(FactoryProvider.newFactory(StuffFactory, XYZ))
@AssistedFactory
interface StuffFactory {
   // Using default implementation for replacement of XYZ.
   public Stuff create(String name);

   // Using defined implementation, replaces XYZ.
   @ImplementedBy(NiceStuff.class)
   public Stuff create(String name);
}

class BasicStuff implements Stuff {
   StuffImpl (@Assisted String name) { }
}

class NiceStuff implements Stuff {
   NiceStuff (@Assisted String name) { }
}


This way a simple call like the following will work.

Stuff myStuff = Guice
                    .createInjector()
                    .getInstance(StuffFactory.class)
                    .create("myStuff");

Maybe this would require to put the assisted injection package in the main
distribution, but since it's 25kb long, is it really a problem?

--
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