Asier
unread,Nov 23, 2009, 3:24:23 AM11/23/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Guice mailing list
Hi all
How can I declare something like this in a module so it can be injected?
I have some mapbinders in different modules, and don't like to have lots of
semi-empty interfaces spreaded, so I've created a generic interface:
public interface IFactory<T extends IBuilder<T>> {
public T create(String type);
}
The objects in the mapbinder are expensive to build so I delay it's full
construction helping me with some builder:
public interface IBuilder<T extends IBuilder<T>> {
public T build() throws Exception;
}
The "final" interfaces are like this:
public interface IDataProvider extends IBuilder<IDataProvider> {
public void process(ISigner signer) throws Exception;
}
public interface ISigner extends IBuilder<ISigner> {
public byte[] sign(InputStream inStream) throws Exception;
}
There´s about five "final" interfaces, each one with 3-5 different
implementations.
Prior to this idea I was using five IBuilder interfaces. five IFactory
interfaces and binding them in his own modules, but I think it can be done
better, but I can't see how to inject generic types. I've readed about
TypeLiteral but I can't find a clear example, easy to understand.
Thanks