zhaoyi wrote:
> Below is my code. When I running this program, I will get an error
> "Could not find a suitable constructor in java.lang.Integer. Classes
> must have either one (and only one) constructor annotated with @Inject
> or a zero-argument constructor that is not private.". How can I pass a
> parameter to the provider?

Hi zhaoyi,

To answer your direct question, passing a parameter to a provider
invocation is explained here:
http://code.google.com/p/google-guice/wiki/AssistedInject


However, if your provider simply switches the returned implementation
based on a parameter, I think you should instead be writing two separate
providers and employing binding annotations as described here:
http://code.google.com/p/google-guice/wiki/BindingAnnotations


It would be easier to suggest an appropriate technique if you made your
example code a little less abstract.


Max.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to