談笑有鴻儒,往來無白丁

          在恰當(dāng)?shù)臅r(shí)間、地點(diǎn)以恰當(dāng)?shù)姆绞奖磉_(dá)給恰當(dāng)?shù)娜?..  閱讀的時(shí)候請(qǐng)注意分類,佛曰我日里面是談笑文章,其他是各個(gè)分類的文章,積極的熱情投入到寫博的隊(duì)伍中來,支持blogjava做大做強(qiáng)!向dudu站長(zhǎng)致敬>> > 我的微博敬請(qǐng)收聽
          Portal開源實(shí)現(xiàn)-Liferay的Portlet Session處理(1)

          一、規(guī)范中的SESSION描述

          (PortletSession objects must be scoped at the portlet application context level. Each portlet application has its own distinct PortletSession object per user session. The portlet container must not share the PortletSession object or the attributes stored in it among different portlet applications or among different user sessions.)
          上面這段話是portlet規(guī)范里的一段。很明白的可以看出,每個(gè)Portlet Application應(yīng)該在Process Action和Render的時(shí)候應(yīng)該擁有自己私有的Session對(duì)象,來為當(dāng)前用戶服務(wù)。也就是說,如果某一個(gè)用戶在一個(gè)PORTAL系統(tǒng)中操作不同的PORTLET,而且這些PORTLET屬于不同的PORTLET APPLICATION,則,這個(gè)用戶將操作多個(gè)SESSION對(duì)象,用戶在每個(gè)PORTLET中操作SESSION時(shí),這個(gè)SESSION都將是屬于該P(yáng)ORTLET所在的上下文的私有SESSION 對(duì)象。比如,用戶當(dāng)前頁面有三個(gè)PORTLET,每個(gè)PORTLET都屬于不同的PORTLET APPLICATION。則當(dāng)該用戶在第一個(gè)PORTLET里面有對(duì)SESSION的操作后,該P(yáng)ORTLET所屬的APPLICATION將為這個(gè)用戶生成一個(gè)SESSION;當(dāng)該用戶又操作第二個(gè)PORTLET中的SESSION時(shí),該上下文有會(huì)對(duì)此用戶產(chǎn)生一個(gè)新的SESSION對(duì)象;第三個(gè)依然如此。加上PORTAL系統(tǒng)的SESSION,也就是該用戶實(shí)際和四個(gè)SESSION在大交道。

          另外要說明一點(diǎn)的是,PORTLET APPLICATION和WEB APPLICATION的關(guān)系。規(guī)范中有如下的定義:
          (Portlets, servlets and JSPs are bundled in an extended web application called portlet application. Portlets, servlets and JSPs within the same portlet application share class loader, application context and session. )
          這說明PORTLET APPLICATION其實(shí)就是一個(gè)WEB APPLICATION。規(guī)范中還有一段話更是說明了這個(gè)問題,同時(shí)也強(qiáng)調(diào)了PORTLET SESSION 和普通的該APPLICATION的SESSION的關(guān)系:
          (A Portlet Application is also a Web Application. The Portlet Application may contain servlets and JSPs in addition to portlets. Portlets, servlets and JSPs may share information through their session. The PortletSession must store all attributes in the HttpSession of the portlet application. A direct consequence of this is that data stored in the HttpSession by servlets or JSPs is accessible to portlets through the PortletSession in the portlet application scope. Conversely, data stored by portlets in the PortletSession in the portlet application scope is accessible to servlets and JSPs through the HttpSession. If the HttpSession object is invalidated, the PortletSession object must also be invalidated by the portlet container. If the PortletSession object is invalidated by a portlet, the portlet container must invalidate the associated HttpSession object.)

          最后一點(diǎn)要說明的是怎樣得到PORTLET SESSION對(duì)象。規(guī)范中有這樣一個(gè)例子:
          PortletSession session = request.getSession(true);
          URL url = new URL(“http://www.foo.com“);
          session.setAttribute(“home.url”,url,PortletSession.APPLICATION_SCOPE);
          session.setAttribute(“bkg.color”,”RED”,PortletSession.PORTLET_SCOPE);

          posted on 2006-07-31 10:07 壞男孩 閱讀(707) 評(píng)論(0)  編輯  收藏 所屬分類: webserverPortal相關(guān)文檔
          主站蜘蛛池模板: 尼玛县| 玉环县| 东宁县| 宜黄县| 城市| 横山县| 江津市| 襄城县| 葫芦岛市| 普兰店市| 十堰市| 望都县| 牙克石市| 惠东县| 墨竹工卡县| 海晏县| 分宜县| 滦平县| 西安市| 河东区| 墨竹工卡县| 兰坪| 博湖县| 炎陵县| 安远县| 武清区| 盈江县| 栖霞市| 任丘市| 昆明市| 伊金霍洛旗| 沁水县| 德令哈市| 来凤县| 天峻县| 浑源县| 南江县| 万山特区| 方城县| 黄龙县| 永清县|