开发者

Google Guice: Provider with parameters

开发者 https://www.devze.com 2023-02-09 07:00 出处:网络
I have a constructor that depends on classes A and B. I defined it like this: @Inject TestClass(A a, B b)

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)?


I think what you need is Assisted Inject.

0

精彩评论

暂无评论...
验证码 换一张
取 消