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…
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…
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]…
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): …
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…
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…
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) :…
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…
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…
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…
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…
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…
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 …
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…
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…
Pwnion
  • 21
  • 2
1
2 3 4