There are examples where different kinds of objects are getting injected into a presenter, but I can't find an explanation how this can be done.
In the Bootstrap-Code example they are injecting e.g. a SecurityDelegate
object.
Also in the Gatekeeper example I see things being injected, e.g. MyGatekeeper
, but how is this done?
What I want is to first check if the user is logged in and then create a CurrentSession
object or something like this. But how can I pass/inject this object around?
At the moment I am initializing a singleton object CurrentUser
which is kind of ugly imho. I would like to get the GWTP support running, but how?
Take this example of the CurrentSession
being injected into the gatekeeper:
@DefaultGatekeeper
public class LoggedInGatekeeper implements Gatekeeper {
private final CurrentSession currentSession;
@Inject
LoggedInGatekeeper(CurrentSession currentSession) {
this.currentSession = currentSession;
}
@Override
public boolean canReveal() {
return currentSession.isLoggedIn();
}
}
How do I inject CurrentSession
here?