Questions tagged [assisted-inject]
53 questions
24
votes
3 answers
Looking for an example for Dagger assisted injection
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…
![](../../users/profiles/1071136.webp)
user1071136
- 15,368
- 2
- 35
- 59
20
votes
1 answer
Using @Assisted inject with multiple params of same Type (@Named params)
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…
![](../../users/profiles/1307108.webp)
Groostav
- 2,871
- 1
- 20
- 27
15
votes
1 answer
Guice assistedinject already configured
I have an issue with the AssistedInject. I followed the instructions on this link
https://github.com/google/guice/wiki/AssistedInject
but when I run my application I get an error:
ERROR [2015-04-23 14:49:34,701]…
![](../../users/profiles/335209.webp)
almy
- 163
- 1
- 7
6
votes
1 answer
guice assisted inject + multibinding + generics
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):
…
![](../../users/profiles/6703449.webp)
Andrew
- 353
- 2
- 12
6
votes
2 answers
How can I make a non-assisted dependency assisted?
Suppose I have a third party class as follows:
public class MyObject {
@Inject
public MyObject(Foo foo, Bar bar) { ... }
}
Now suppose that I have a factory interface like so:
public interface MyObjectFactory {
public MyObject build(Bar…
![](../../users/profiles/1163186.webp)
Kelvin Chung
- 1,111
- 10
- 20
5
votes
1 answer
scala-guice and assisted injection
I have been using google-guice with the assisted inject mechanism for quite some time now. As i am in scala, and just discover scala-guice, i'm interested in using it as well. However i'm confused as to how to use assisted injection with it. There…
![](../../users/profiles/2292791.webp)
MaatDeamon
- 7,821
- 5
- 46
- 96
4
votes
1 answer
Dagger2.10+: Inject ViewModel in Fragment/Activity which has run-time dependencies
For ViewModels which has only compile-time dependencies, I use the ViewModelProvider.Factory from Architecture components like following:
class ViewModelFactory @Inject constructor(private val viewModel: Lazy) :…
![](../../users/profiles/1852343.webp)
Sandip Fichadiya
- 3,120
- 2
- 17
- 44
4
votes
1 answer
error: cannot find symbol @dagger.Module(includes = {InflationInject_ViewModule.class})
I've tried implementing Jake Wharton's AssistedInject with Dagger 2 (https://github.com/square/AssistedInject) in my project.
My code is pretty much identical to…
![](../../users/profiles/1130131.webp)
Villa
- 429
- 5
- 17
4
votes
1 answer
How to make Multibinder work with FactoryModuleBuilder and Generics using Guice?
I've read Google guice - multibinding + generics + assistedinject but it doesn't seem to answer my specific scenario. Here's what i have:
The interfaces to use with FactoryModuleBuilder
public interface IFilterFactory {
T…
![](../../users/profiles/1872168.webp)
Crystark
- 3,101
- 3
- 32
- 51
3
votes
1 answer
How does AssistedInject for Dagger 2 work?
The AssitedInject library from Square is actually an annotation processor that generates Dagger 2 modules. Dagger 2 is also an annotation processor.
And as I know there is no way to control the order of processors execution.
In this example (see…
![](../../users/profiles/2645340.webp)
Nikita Slushkin
- 33
- 4
3
votes
1 answer
Guice inject different instance based on the parent instance annotation
I am using guice framework in my application. I have a scenario where a single class might require multiple instances of same interface C (but for different purposes) as shown in the example. I am trying to resolve this using the annotation facility…
![](../../users/profiles/1153438.webp)
amrk7
- 1,144
- 4
- 13
- 29
3
votes
1 answer
Guice, FactoryModuleBuilder, multiple implementations, and generics
I am using Guice and FactoryModuleBuilder. Typically, it is enough to just define an interface of the factory and Guice will automatically inject the implementation.
However, the part that I am struggling is that the methods in a factory uses…
![](../../users/profiles/3111978.webp)
Christopher Z
- 801
- 1
- 7
- 26
3
votes
1 answer
GIN AssistedInject issue with factory "Unable to create or inherit binding"
I am getting an strange error which I cannot get past when using Assisted Injection:
[DEBUG] [project] - Rebinding com.gwtplatform.mvp.client.DesktopGinjector
[DEBUG] [project] - Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
…
![](../../users/profiles/412354.webp)
Casey Jordan
- 1,104
- 1
- 18
- 35
3
votes
1 answer
@Nullable doesn't seem to work with @AssistedInject
I have a constructor that looks like this:
@Inject
public MyClass(
@Named("config") String configFile,
@Named("template") String templateFile,
CachedSettings settings,
@Assisted String channelId,
@Nullable…
![](../../users/profiles/1768232.webp)
durron597
- 30,764
- 16
- 92
- 150
2
votes
0 answers
Guice Assisted Inject - java.lang.IllegalStateException: zip file closed
I'm having problems with using Guice's assisted inject within my spigot plugin, and can't seem to narrow down the problem. This is the error I'm getting:
> [12:00:38 INFO]: [DestinyMC] Enabling DestinyMC v1.0
> 2019-01-14 12:00:41,492…
![](../../users/profiles/10909587.webp)
Pwnion
- 21
- 2