Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Guice: Provider with parameters

I have a constructor that depends on classes A and B. I defined it like this:

@Inject TestClass(A a, B b)

Is there a way in Guice to have one of the constructor parameters injected manually?

Problem is, the object of class A cannot be built as it depends on the user input. I was just wondering if Guice supports a provider that accepts an argument. For example, currently an object can be created by provider.get(), does Guice has one that support provider.get(a)?

like image 817
Abidi Avatar asked Feb 09 '11 17:02

Abidi


1 Answers

I think what you need is Assisted Inject.

like image 160
ColinD Avatar answered Sep 19 '22 17:09

ColinD