On Monday, December 17, 2012 3:52:51 PM UTC+1, Dirk Nimerem wrote:
>
> Hello Moandji,
>
> could you please make an example how to specifiy a binding via annotation 
> for this?
>
> Any other class should use the CachedFileReader for an IFileReader, only 
> the CachedFileReader itself should use the basic FileReader.
>

You know that the CachedFileReader's dependency on IFileReader is special, 
so annotate it in the constructor.

Simple example here with the @Named annotation:

@Inject CachedFileReader(@Named("non_cached") IFileReader fileReader) { … }

then:

// CachedFileReader uses the basic FileReader:
bind(IFileReader.class).annotatedWith(Names.named("non_cached")).to(FileReader.class);
// Every other class should be given the CachedFileReader:
bind(IFileReader.class).to(CachedFileReader.class);

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-guice/-/JFnMdRCakToJ.
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