Ah yes of course, I see what you were saying now...
In other news...
I've updated my blog with some examples that I was inspired from
reading a post on Dhanji R. Prasanna's blog:
http://stubbisms.wordpress.com/2008/07/26/google-guice-injecting-prim...
My now favourite module binding for my use case is:
<pre>
String DEFAULT_PET_NAME = "suki";
bind(HouseHoldPet.class).toProvider(new Provider<HouseHoldPet>()
{
public HouseHoldPet get()
{
return new HouseHoldPet(DEFAULT_PET_NAME);
}
});
</pre>
On Jul 26, 7:06 pm, "Dhanji R. Prasanna" <dha...@gmail.com> wrote:
> On Sat, Jul 26, 2008 at 10:50 AM, astubbs <antony.stu
...@gmail.com> wrote:
> > Ah yes I think I gathered that but I was hell bent on not having to
> > actually create my own annotation just to inject a string into my
> > constructor args. Is that actually what you are refering to?
> > So AN_INT - is that an annotation you'd have to create? It would
> > really help my understanding if you could complete the example you
> > posted?
> //module class:
> public static final String AN_INT = "anInt";
> ...configure() {
> bindConstant().annotatedWith(named(AN_INT)).to(12);
> }
> //elsewhere:
> @Inject @Named(MyModule.AN_INT) int x;
> Dhanji.