You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can you elaborate on the use case you're going for? From the code example, it appears that you want the resultsPerPage variable to be bound to some value that you've configured in a Guice module somewhere, as opposed to being provided by the client of a web-service. (If I have this part wrong, please clarify.)
If I'm on the right track, and you dislike field injection, the typical way Jersey does this is with constructor injection:
@Path('/results')
public class ResultsResource {
private final byte _resultsPerPage;
@Inject
public ResultsResource( @ResultsPerPage byte resultsPerPage ) {
_resultsPerPage = resultsPerPage;
}
// ... methods to follow ...
}
Will this meet the need, or is there a different twist you're going for?
It would be great if this sample application could demonstrate argument injection using guice binding annotations.
I'm talking about method arguments like (where ResultsPerPage is custom binding annotation):
With existing application configuration it's only possible to use binding annotations to inject fields. Or did I miss something?
Thanks
The text was updated successfully, but these errors were encountered: