Hi!
I have created some sample GWT application, which uses Guice 2.0.1,,
gwt-dispatch 1.1.0 and AppEngine 1.3.6. For user authorization I use
com.google.appengine.api.users.UserService class. For every kind of
RPC request I use specific action handler, which implements
ActionHandler, coming from gwt-dispatch library.
First action handler checks, if user has just logged in, generates
login or logout URLs and tries to fill with additional user data my
custom, session
scoped class UserInfo:
package sesstest.server;
import java.io.Serializable;
public class UserInfo implements Serializable {
private static final long serialVersionUID = 5L;
private String testValue;
public UserInfo() {
}
public UserInfo(final String testValue) {
this.testValue = testValue;
}
public String getTestValue() {
return testValue;
}
public void setTestValue(String testValue) {
this.testValue = testValue;
}
}
FirstActionHandler:
@Inject
public FirstActionHandler(final Provider<UserInfo> userInfoProvider)
{
this.userInfoProvider = userInfoProvider;
}
@Override
public MyActionsResult execute(FirstAction action, ExecutionContext
arg1)
throws DispatchException {
logger.debug("first action handler, execute method has been
started");
UserInfo userInfo = userInfoProvider.get();
String link;
String linkText;
UserService userService = UserServiceFactory.getUserService();
User currentUser = userService.getCurrentUser();
if (currentUser == null){
link =
userService.createLoginURL(action.getRedirectUrl());
linkText = "User is not logged in. Please login!";
} else {
link =
userService.createLogoutURL(action.getRedirectUrl());
linkText = currentUser.getEmail();
}
userInfo.setTestValue("text from first action handler");
MyActionsResult result = new MyActionsResult(linkText, link);
logger.debug("finish");
return result;
}
In second action handler, where I get UserInfo instance in the same
way, I expect it to contain previously specified testValue, but IT'S
NULL :(
I have only one Guice binding:
bind(UserInfo.class).in(SessionScoped.class);
According to gwt-dispatch, all action handlers are singletons.
My appengine-web.xml contains this line:
<sessions-enabled>true</sessions-enabled>
The most interesting thing is that all this happens ONLY in web mode
on appengine, in GWT hosted mode everything works fine.
This definitely happens because of UserService. If I remove it from
first action handler, and only define some value for
userInfo.testValue, it will be available inside
second action handler in both hosted and web (deployed on appengine)
modes.
Could anybody explain me how should I use this UserService together
with session scoped objects? Any additional Guice bindings for that?
Or maybe this is more appengine related problem...
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
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.