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?= <[email protected]>:
-- --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
userNameis a real parameter andstatsServiceis 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 [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.
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.
