--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To post to this group, send email to google...@googlegroups.com.
To unsubscribe from this group, send email to google-guice...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
You can achieve something like
@Inject
public void injectWebServiceProperties(
@Optional @Named("akui.webServiceURL") String webServiceUrl,
@Optional @Named("akui.webServiceUsername") String webServiceUsername,
@Optional @Named("akui.webServicePassword") String webServicePassword) {
...
}
only using field injection, which is obviously a bad thing. I've already
ran into this several times and I don't think it's so rare it should be
ignored.
Not really, I need to do a setter/field injection in the Holder. This is
no problem, but one more class for each parameter is quite bad,
especially with my parameters being ints and strings, so I need an
annotation for each of them (I hate using @Named). This means 2 classes
per parameter, don't you feel it's too much?
Isn't this problem common enough to be solved? I'm quite sure, it'd
require only small changes in Guice. I feel that constructor injection
should be at least as good as setter/field injection in each aspect.
Really? I see no reason for this, unless you generally prefer using
setters to using constructors. The constructor argument list gets very
long mostly because of the Named annotations, this is not nice, but no
real problem.
Jason
Without constructor injection you obviously can't get your fields final
and your objects immutable.