Hi all guys,
I'm just trying to use the Binder#convertToTypes to convert URLs in that way:

@Override
    protected void configure() {
        this.binder().convertToTypes(Matchers.only(URL.class), new
TypeConverter {

    public Object convert(String value, TypeLiteral<?> toType) {
        try {
            return new URL(value);
        } catch (URISyntaxException e) {
            throw new RuntimeException("String vaue '"
                    + value
                    + "' is not a valid URL", e);
        }
    }});

    }

then I annotate the POJO field:

class FakeConfig {

    @Inject
    @Named("url")
    private URL url;

    ....

}

and finally in different module (it comes from a 3rd part developed
application):

Injector injector = Guice.createInjector(
                new AbstractModule() {
                    @Override
                    protected void configure() {
                        this.bindConstant()
                            .annotatedWith(Names.named("url"))
                            .to("http://code.google.com/";);
                    }
                });

I get the following error:

com.google.inject.ConfigurationException: Guice configuration errors:

1) No implementation for java.net.URL annotated with
@com.google.inject.name.Named(value=url) was bound.
  while locating java.net.URL annotated with
@com.google.inject.name.Named(value=url)

Am I misunderstanding or missing something? Thanks in advance, any
hint is very appreciated.
Best regards,
Simo

-- 
http://www.google.com/profiles/simone.tripodi
-- 
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