Questions tagged [assisted-inject]

61 questions
1
vote
1 answer

Guice AssistedInject can not find matching constructor

I just started learning Guice, but I've already encountered a problem. I have an interface PlayerFactory with one implementation BlackjackPlayer PlayerFactory.java public interface PlayerFactory { Player createPlayer(String name); Player…
mariusz
  • 157
  • 2
  • 16
1
vote
0 answers

Guice scope and AssistedInject

I have code which uses AssistedInject to create factories of my classes. Now what I want to do is create a number of objects, each of which gets injected with a different item of a collection (reverse Multibinding one could say). My approach is to…
kutschkem
  • 7,826
  • 3
  • 21
  • 56
1
vote
1 answer

Guice assisted inject

I'm new at Guice, so I'm trying to understand AssistedInject. I have very simple project: Class that I want to Inject: public class I1 { } Class with assisted injection: public interface ICla { } public class Cla implements ICla{ public…
Andrei Koch
  • 898
  • 1
  • 7
  • 23
1
vote
0 answers

Annotate assisted injection factory

Without AssistedInjection, I have the following interface IA { ... } class B implements IA { B (String p) } class C implements IA { C (String p) } interface IAFactory { IA create(String p) } class BFactory implements IAFactory {…
SANDeveloper
  • 560
  • 2
  • 7
  • 22
1
vote
1 answer

Guice assisted inject with multiple constructors always calls the default constructor

I have a class which has two constructors. I am trying to create instances of this class using a guice factory. If no parameter is passed, then default constructor should be called. If a parameter is passed, then constructor with parameter should be…
AnOldSoul
  • 4,017
  • 12
  • 57
  • 118
1
vote
1 answer

Guice - Binding an instance created by assisted injection factory

Let's say that there's class A that's constructor looks something like that: public A(@Assited long id, @Assisten String name, ServiceA serviceA, ServiceB serviceB) And there's AFactory: public interface AFactory{ A create(long id, String…
slashms
  • 928
  • 9
  • 26
1
vote
1 answer

@Assisted \ @Provider usage in objects creation in hierarchical design

This question is about a correct usage of Guice @Assisted and @Provides and also, how to do it. The current design I refer to is something like this: The class in the top of the hierarchy is also the only class that is exposed to the client…
slashms
  • 928
  • 9
  • 26
1
vote
1 answer

Managing complex life cycles in Guice

I've run into a situation where I have a graph of data objects, and would like to create one service for each node on this graph. The problem is this service (and its dependencies) are dependent on the the node they're working for. Something like…
Groostav
  • 3,170
  • 1
  • 23
  • 27
1
vote
2 answers

Android assisted injection with Factory using Roboguice not working

I'm trying to inject some classes while passing some parameters in the constructor. To achive that, I've found this questions (1, 2) saying that this could be achived by using Assisted Injection with a Factory. This is how my code looks like,…
1
vote
1 answer

Chaining assisted injected parameters using guice-assistedinject

I'm using Guice Assisted Inject library to build a factory for me. I currently have it set up like this: class MyObject { @Inject public MyObject(@Assisted FirstDep first, @Assisted SecondDep second, ThirdDep third) { /**/ } } class FirstDep { /*…
Jorn
  • 20,612
  • 18
  • 79
  • 126
1
vote
2 answers

When is Assisted-inject useful?

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…
MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
1
vote
2 answers

Guice AssistedInject won't inject the factory

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()…
durron597
  • 31,968
  • 17
  • 99
  • 158
1
vote
0 answers

Spring: complex object creation

I've tried to create a complex object by using spring's @Autowired annotation but it looks like it is not possible. I'm trying to create two objects: View and Presenter, with prototype scopes and then inject their references to each other. What is…
G. Demecki
  • 10,145
  • 3
  • 58
  • 58
0
votes
0 answers

Work Manger injection with dagger assisted inject and dagger multi binding

No able to provide Map in assisted inject: Worker: class SyncWorker @AssistedInject constructor( @Assisted appContext: Context, @Assisted workerParams: WorkerParameters, val storeCurrencyData: StoreCurrencyData, val…
JSONParser
  • 1,112
  • 2
  • 15
  • 30
0
votes
1 answer

Shared viewModel with assisted injection and hilt

I have an activity. This activity is receiving some arguments. At the moment, I'm able to create a viewModel with those parameters with assisted injection. //activity code private val viewModel: ViewModel by viewModels { val keyName =…
YorchSircam
  • 168
  • 8