Yes
I left the factory out to keep my post a little shorter. Your example is just what I wanted to refere to.

Am 21.04.2014 05:47 schrieb =?UTF-8?Q?C=C3=A9dric_Beust_=E2=99=94?= <ced...@beust.com>:

On Sun, Apr 20, 2014 at 12:05 PM, Stephan Classen <st.clas...@gmx.ch> 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:


@Inject
private 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 google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/d/optout.

--
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 google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
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