I've got a design that looks something like this:
public interface Encryptor<T> {
Encrypted<T> encrypt(T toEncrypt);
T decrypt(Encrypted<T> toDecrypt);
}
public class BlowfishEncryptor<T> implements Encryptor<T> {
private Provider<byte[]> passwordProvider;
@Inject
public BlowfishEncryptor<T>(Provider<byte[]> passwordProvider) {
this.passwordProvider = passwordProvider;
}
Encrypted<T> encrypt(T toEncrypt) { ... }
T decrypt(Encrypted<T> toDecrypt) { ... }
}
I want to be able to wire my application to use a BlowfishEncryptor<String>
which is itself wired to a byte array provider.
The only example of binding to parameterized types is in the FAQ, and it
only shows a binding to a collections instance.
Is something like this possible in Guice?
public void configure(Binder binder) {
binder.bind(new TypeLiteral<Encryptor<String>>() {}).to( /* some injected
BlowfishEncryptor<String> */ )
}
-Brandon
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---