我有一个如下所示的工厂:
public final class Application {
private static IFoo foo;
public static IFoo getFoo(String bar)
{
// i need to inject bar to the constructor of Foo
// obvious i have to do something, not sure what
Injector injector = Guice.createInjector();
logger = injector.getInstance(Foo.class);
return logger;
}
}
这是Foo的定义:
class Foo
{
Foo(String bar)
{
}
}
好的,我不确定如何使用Guice将此参数传递给Foo构造函数?
有什么想法吗?