assisted-inject

When is Assisted-inject useful?

自古美人都是妖i 提交于 2020-01-05 05:18:15
问题 I'm currently using Guice in my App. However i find myself mostly using assisted inject because there is a chain of injected objects that all depend on what was the input of the program. Hence almost everything is assisted inject. For instance A need B who need c who need Z which needs input from the command line. In the end i feel like everything will be assisted injected. So given that i'm stuck with it i want to be sure that i m using it right. I personally feel like writing my own

When is Assisted-inject useful?

流过昼夜 提交于 2020-01-05 05:18:14
问题 I'm currently using Guice in my App. However i find myself mostly using assisted inject because there is a chain of injected objects that all depend on what was the input of the program. Hence almost everything is assisted inject. For instance A need B who need c who need Z which needs input from the command line. In the end i feel like everything will be assisted injected. So given that i'm stuck with it i want to be sure that i m using it right. I personally feel like writing my own

guice assisted inject + multibinding + generics

末鹿安然 提交于 2020-01-04 09:23:13
问题 I'm trying to combine this 3 features of Guice: inject, multibinding, generics. I create a prototype of production project, so here it is: First, this is a little hierarchy for generics(in production case there is hierarchy of N entities): public interface Type { } public class Type1 implements Type{ } public class Type2 implements Type { } Next, classes ToCreate1 and ToCreate2 I want to create by Factory . Base class: public abstract class AbstractToCreate<T extends Type> { public T type;

Guice AssistedInject won't inject the factory

坚强是说给别人听的谎言 提交于 2019-12-23 04:18:11
问题 I am trying to use Guice 3.0 AssistedInject , and it won't instantiate the factory. SSCCE Code: Parent class public class ParentClass() { @Inject private MyFactory myFactory; private final Foo foo; private final Bar bar; public ParentClass() { if(myFactory == null) System.err.println("Error: I should have injected by now!"); foo = myFactory.create(new Map<String, Object>()); // etc. } } Factory Interface public interface MyFactory { Foo create(Map<String, Object> mapA); Bar create(Map<String,

Using @Assisted inject with multiple params of same Type (@Named params)

自作多情 提交于 2019-12-08 15:48:52
问题 my problem boils down to using @Assisted with two string arguments to the factory. The problem is that because Guice treats type as the identification mechanism for parameters, both parameters are the same, and I get a configuration error. Some Code: public class FilePathSolicitingDialog { //... some fields public static interface Factory { public FilePathSolicitingDialog make(Path existingPath, String allowedFileExtension, String dialogTitle); } @Inject public FilePathSolicitingDialog

Looking for an example for Dagger assisted injection

帅比萌擦擦* 提交于 2019-11-27 21:17:24
From dagger-discuss@ : I have a class that gets some dependencies from the object graph, and other dependencies from a caller at runtime. public class ImageDownloader { // Get these dependencies from the injector. private final HttpClient httpClient; private final ExecutorService executorService; // Get these from the caller. private final URL imageUrl; private final ImageCallback callback; ... } I came up with a solution, where I define a Factory, public class ImageDownloader { ... public static class Factory { private final HttpClient httpClient; private final ExecutorService executorService

Looking for an example for Dagger assisted injection

青春壹個敷衍的年華 提交于 2019-11-26 16:34:07
问题 From dagger-discuss@: I have a class that gets some dependencies from the object graph, and other dependencies from a caller at runtime. public class ImageDownloader { // Get these dependencies from the injector. private final HttpClient httpClient; private final ExecutorService executorService; // Get these from the caller. private final URL imageUrl; private final ImageCallback callback; ... } I came up with a solution, where I define a Factory, public class ImageDownloader { ... public