Google App Engine Cloud中会重置最终的静态变量(final static variables are reset in Google App Engine Cloud)
我有一个GWT + GAE网络应用程序,有几个服务和模块。 我正在使用mvp4g的模块功能。 我所有的服务扩展到:
public abstract class BaseServiceImpl extends RemoteServiceServlet { protected final static Map USERS = new HashMap();
我使用USERS来存储我当前的活动用户会话。 一旦我用户认证自己,我将他的会话ID存储为地图的关键字。
protected String getSessionId() { return getThreadLocalRequest().getSession().getId(); } public String authenticate(String username, String password) { ... .. . String id = getSessionId(); synchronized( this ) { users.put(id, user); } ... .. .
对于每个请求,我检查用户会话是否仍然有效。
protected boolean validUserSession() { if(getThreadLocalRequest() == null) { logger.log(Level.SEVERE, "Thread is null"); return false; } else if(getThreadLocalRequest().getSession() == null) { logger.log(Level.SEVERE, "Session is null"); return false; } String id = getSessionId(); UserJDO user = (UserJDO) users.get(id); if(user==null) { logger.log(Level.SEVERE, "User is null"); return false; } return true; }
我启用了会话。 接下来我发布appengine-web.xml的最后几行
... .. . <sessions-enabled>true</sessions-enabled> </appengine-web-app>
在开发服务器中一切正常。 但是,当我将它部署到谷歌应用引擎云时, 用户变量会针对每个请求进行重置。
任何人都可以解释我发生了什么? 我应该如何继续? 我应该将用户会话存储在数据存储中吗?
I have a GWT+GAE web app with several service and modules. I am using the module functionlity of mvp4g. All of my services extends:
public abstract class BaseServiceImpl extends RemoteServiceServlet { protected final static Map USERS = new HashMap();
I use USERS to store my current active user sessions. Once I user authenticates himself I store his session id as a key of the map.
protected String getSessionId() { return getThreadLocalRequest().getSession().getId(); } public String authenticate(String username, String password) { ... .. . String id = getSessionId(); synchronized( this ) { users.put(id, user); } ... .. .
For every request, I check if the user session is still valid.
protected boolean validUserSession() { if(getThreadLocalRequest() == null) { logger.log(Level.SEVERE, "Thread is null"); return false; } else if(getThreadLocalRequest().getSession() == null) { logger.log(Level.SEVERE, "Session is null"); return false; } String id = getSessionId(); UserJDO user = (UserJDO) users.get(id); if(user==null) { logger.log(Level.SEVERE, "User is null"); return false; } return true; }
I have sessions enabled. Next I post the last lines of appengine-web.xml
... .. . <sessions-enabled>true</sessions-enabled> </appengine-web-app>
Everything works fine in the Development server. However, when I deploy it to the google app engine cloud the users variable is reset for every request.
Can anyone explain me what it is happening? How should I proceed? Should I store the user sessions in the datastore?
原文:https://stackoverflow.com/questions/3545554
满意答案
while true; do foo; sleep 2; done
顺便说一下,如果您在命令提示符下键入多行(正如您所显示的),然后使用箭头向上调用历史记录,则可以在单行上正确地标记。
$ while true > do > echo "hello" > sleep 2 > done hello hello hello ^C $ <arrow up> while true; do echo "hello"; sleep 2; done
while true; do foo; sleep 2; done
By the way, if you type it as a multiline (as you are showing) at the command prompt and then call the history with arrow up, you will get it on a single line, correctly punctuated.
$ while true > do > echo "hello" > sleep 2 > done hello hello hello ^C $ <arrow up> while true; do echo "hello"; sleep 2; done
相关问答
更多单行Bash无限while循环语法(Syntax for a single-line Bash infinite while loop)
从bash脚本到无限循环中的bash脚本(From bash script to bash script in infinite loop)
Bash Shell:无限循环(Bash Shell: Infinite Loop)
Bash脚本迭代目录中的文件进入无限循环(Bash script iterating files in a directory goes into infinite loop)
单线在哪里?(Where is the single-line?)
Bash脚本无限循环关闭(Bash script infinite loop shutdown)
在不创建无限循环的情况下向基本bash命令添加内容(Adding things to basic bash commands without creating infinite loops)
在bash中无限循环[重复](Infinite while loop in bash [duplicate])
我的bash脚本进入无限循环(My bash script gets into infinite loop)
这个bash脚本如何导致无限循环?(How is this bash script resulting in an infinite loop?)
相关文章
更多深入浅出dwr系列教程之3.engine.js的功能详解
全球最流行的66款App的共同规律
最简单下拉刷新,Google最新(可刷新任何控件)
十分钟了解分布式计算:Google Dataflow
基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
微信公众平台如何与Web App结合?
基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果(转)
基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
最新问答
更多python的访问器方法有哪些
使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
透明度错误IE11(Transparency bug IE11)
linux的基本操作命令。。。
响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
元素上的盒子阴影行为(box-shadow behaviour on elements)
它看起来像只在Windows上的Chrome的错误。 我在Google Canary (Chrome 63)中也进行了测试,问题依然存在,所以有可能它不会很快修复。 这个问题是由overflow: auto引起的overflow: auto ,在你的情况下,它可以很容易地通过删除或设置为可见(默认)来解决。 但是 ,将鼠标悬停在右侧(顶部和底部)时,会出现滚动条。 一个解决方案可以设置overflow: hidden的身体,所以预期的结果是所需的。 我想指出,这不是一个很好的解决方案,但我建议暂
Laravel检查是否存在记录(Laravel Checking If a Record Exists)
这取决于您是否要以后与用户合作,或仅检查是否存在。 如果要使用用户对象(如果存在): $user = User::where('email', '=', Input::get('email'))->first(); if ($user === null) { // user doesn't exist } 如果你只想检查 if (User::where('email', '=', Input::get('email'))->count() > 0) { // user found
设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
$scope.getData= function () { var reader = new FileReader(); reader.onload = $('input[type=file]')[0].files; var img = new Image(); img.src =(reader.onload[0].result); img.onload = function() { if(this.width > 640
Copyright ©2023
peixunduo.com All
Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!
Laravel检查是否存在记录(Laravel Checking If a Record Exists)
设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!