For some inexplicable reason for me ,Gin does not works as i intend. Let me explain with little code.
对于我来说有些莫名其妙的原因,杜松子酒并不像我想的那样有效。让我用小代码解释一下。
Let say i have a formA
假设我有一个formA
@Singleton
public class formA extends Composite
private final MyGinjector ginjector;
@Inject
public formA(MyGinjector ginjector)
{
this.ginjector = ginjector;
this.add(ginjector.getFormB());
this.add(ginjector.getFormC());
}
here are and formB and formC (let assume formB and formC has similar code)
这里是和formB和formC(假设formB和formC有类似的代码)
@Singleton
public class formB extends Composite
{
@Inject
public formB(MyGinjector ginjector)
{
this.ginjector = ginjector;
..............
}
}
And the problem i has been facing is in some moment when i inject formA (ginjector.getFormA() return an instance of formA but with missing childWidgets meaning with no reference to formB and formC
我遇到的问题是在我注入formA的某个时刻(ginjector.getFormA()返回一个formA的实例,但缺少childWidgets意味着没有引用formB和formC
What could be the problem? all forms are singleton ... probably i should not inject the ginjector like that?
可能是什么问题呢?所有的形式都是单身......可能我不应该像那样注射那些ginjector?
Thanks
1 个解决方案
#1
0
I believe gin does not support injecting the injector: gin groups discussion.
我相信杜松子酒不支持注射注射器:杜松子酒小组讨论。
Is there any reason you try injecting injector instead od injecting dependencies directly?
您是否有任何理由尝试直接注射注射器而不是注射依赖性?
You should just inject dependencies directly:
你应该直接注入依赖项:
@Inject
public formA(FormB formB, FormC formC){
#1
0
I believe gin does not support injecting the injector: gin groups discussion.
我相信杜松子酒不支持注射注射器:杜松子酒小组讨论。
Is there any reason you try injecting injector instead od injecting dependencies directly?
您是否有任何理由尝试直接注射注射器而不是注射依赖性?
You should just inject dependencies directly:
你应该直接注入依赖项:
@Inject
public formA(FormB formB, FormC formC){