Hi all guys,
I'm in trouble with a silly question but I hope you don't mind and
provide me a little help :P

Given the simple POJO created by Guice:

{{{
@Singleton
public class MyConfig {

@Inject @Named("myconfig.autoclose") boolean autoClose(); // please
note the type

// setter here

}
}}}

immagine the proeprty come from a text file, if in the module I bind
the property via:

{{{
binder.bindConstant().annotatedWith(Names.named("myconfig.autoclose")).to(myAlchemyObject.getStringValue());
}}}

or, like in the com.google.inject.name.Names class:

{{{
binder.bind(Key.get(String.class,
Names.Named("myconfig.autoclose"))).toInstance(myAlchemyObject.getStringValue());
}}}

things work well, the String will be successfully (if the value
matches) to boolean and the startup works well.

Problems come when binding the String to a Provider<String>:

{{{
binder.bind(Key.get(String.class,
Names.Named("myconfig.autoclose"))).toProvider(new Provider<String>()
{
                        public String get() {
                            return myAlchemyObject.getStringValue();
                        }
                    });
}}}

the Injector raises an error:

{{{
1) No implementation for java.lang.Boolean annotated with
@com.google.inject.name.Named(value=myconfig.autoclose) was bound.
  while locating java.lang.Boolean annotated with
@com.google.inject.name.Named(value=myconfig.autoclose)
    for field at MyConfig.autoClose(MyConfig.java:XX)
}}}

Any idea why? Any suggestion will be more than appreciated, thanks in advance!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to