On Sun, Apr 20, 2014 at 12:05 PM, Stephan Classen <[email protected]> wrote:

Here is an example:
>
> public class SomeHelper {
>
>     private final StatsService statsService;
>     private final String userName;
>
>     @Inject
>     public SomeHelper(String userName, StatsService statsService) {
>         this.userName = userName;
>         this.statsService = statsService;
>     }
>
>     // ...
>
> You probably mean that userName is a real parameter and statsService is
injected, so it would be more like this:

public class SomeHelper {
  public interface IFactory {
    SomeHelper create(String userName);
  }

  @Inject
  private SomeHelper(@Assisted String userName, ServiceDependency dependency) {
    // ...
  }
}

To use:

@Injectprivate SomeHelper.IFactory factory;
// ...

someHelper = factory.create("John Smith");

-- 
Cédric

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/d/optout.

Reply via email to