Hey all,
how do you manage the Scopes of your injected fields and make it easy for
people to understand from where these objects originate from. The system
I'm working on has a growing number of objects that are injectable in the
@RequestScoped context. The difficulty is that I can't simply slap a
@RequestScoped annotation onto them.
Here is an example. There is one instance of the Account class in the
@RequestScoped context and there are possibly many in the default or some
other context (may or may not be constructed with Guice). Do people use
@Named in these cases or do you use some custom marker annotation document
the scope and make it more obvious for the reader?
class AccountHelper {
@Inject
private AccountDAO accountDAO;
@Inject
private Account primaryAccount;
public List<Account> getSecondaryAccounts() {
return accountDAO.getSecondaryAccounts(primaryAccount.getId());
}
}
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-guice/-/YpC8uUh_61oJ.
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.