Guice expert question
Posted
by Roman
on Stack Overflow
See other posts from Stack Overflow
or by Roman
Published on 2010-05-08T18:48:56Z
Indexed on
2010/05/08
18:58 UTC
Read the original article
Hit count: 246
Hi All
I am wondering if someone would be such an expert in guice that he even would know how to implement that :
I have an injection annotation (@ConfParam
)with some parameters , like that :
class TestClass {
private final int intValue;
@Inject
public TestClass(@ConfParam(section = "test1", key = "1") int intValue{
this.intValue = intValue;
}
public int getIntValue() {
return intValue;
}
}
The ConfParam is my custom annotation.
Now , when the injection value is requested , I would like guice to create a dynamic binding, to resolve the value.
For that binding I will need the parameters inside the annotation.
Some example could be , I will have to look in the database in some table where the section is ? and the key is ?.
All the trouble is that the data is not available when the injector is created and could be also be added at runtime.
Ps. I static solution is easy. ( just have a look at the Names class)
© Stack Overflow or respective owner