目前的需求是要 web application 被重新 deploy 的時候,使用者必須能保留 session
原本在找用 session migration 把 session 遷移出去,deploy 完成後再遷移回來
不過後來找到比較簡單的方式,可以直接即時把 session 寫進資料庫
deploy 完成後 tomcat 會自動把 session 再抓出來。
Software entities (class, modules, functions, etc.) should be open for extension, but closed for modification.
- Bertrand Meyer
Junior programmers create simple solutions to simple problems. Senior programmers create complex solutions to complex problems. Great programmers find simple solutions to complex problems.
- Charles Connell
註1:本部落格的範例程式碼在 2015 年以前的文章中,大多是以全型空白做縮排。如需服用,請自行用文字編輯器的取代功能把全型空白取代成半型空白。
註2:本部落格的內容授權請參閱部落格底部的授權宣告。
2011年12月16日 星期五
把 Session 寫入資料庫的方法:Session Persistent
2011年12月14日 星期三
Session migration
定義(來源:http://www.roseindia.net/interviewquestions/servlet/session-tracking.shtml):
Session Migration is a mechanism of moving the session from one server to another in case of server failure. Session Migration can be implemented by:
a) Persisting the session into database
b) Storing the session in-memory on multiple servers.
關鍵字:Session migration、Session replication、Cluster
相關資源:
1、Cluster:Tomcat 叢集設置
2、用terracotta達成tomcat session
3、How to integrate two web applications having two different context paths
後來發現我需要的不是 Session migration,而是 Session Persistent,所以這篇的資料整理就先停在這了。
2011年12月7日 星期三
字串切割遇到 "點" (period) 時會回應空陣列
參考資料:http://www.velocityreviews.com/forums/t139874-string-method-split-doesnt-work.html
如上述的連結回應所說,split() 函式裡面實際上用的是 regular expression
"." 在 regular expression 中是 metacharacter
所以必須改成以下的寫法才會有效果:
1 2 |
String string = "aaa.bbb" ; String[] result = string.split( "\\." ); |