JavaWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JavaWorld@TW » Java Tools  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to topicthreaded modego to previous topicgo to next topic
己加入精華區
by jini at 2005-12-20 21:14
本主題所含的標籤
無標籤
作者 Jetspeed-2 心得隨筆(3)-Overview [精華]
wayyoung





發文: 21
積分: 1
於 2005-12-20 19:15 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Jetspeed1是我接觸到第一個Portal Server。可惜其獨特的架構,我一直沒辦法接受。後來因為工作上的需要,弄了很久的WebSphere Portal Server,卻總是有一種被IBM欺負的感覺。最近和Jetspeed2相處一陣子後,覺得J2蠻不錯的;儘管release的比較慢,可是架構、功能和速度個人都覺得滿意。寫下一些個人心得,希望有更多能人加入J2,一起開發一些有用的元件和管理設定的portlet,讓J2完美。

由衷希望J2能超越WPS...哈哈。

J2的feature很多,請務必連至http://portals.apache.org/jetspeed-2/features.html瀏覽一下。另外對Spring、Velocity、JAAS,JSR168的了解是一定要的。

OK,碎碎唸完畢。今天介紹一下J2的一些觀念,如果有錯誤,請大家不吝指正。
(文章中提到的一些檔案路徑,是依照之前寫的範例。)

先來一張官方的overview流程

在這張圖中,J2算是位於Engine的部份,而Container是Pluto Portlet Container,Portlet就是自已寫的Portlet;所以這張圖正好對照JSR168中的Portal--Portlet Container--Portlet的概念。要特別注意的是,圖中在Engine和Container之間有很多個雙向的箭頭,這代表整個流程可能會在這裡來來回回地執行。
至於這圖大概可以這樣說明:
1 request送至server後由JetspeedServlet(org.apache.jetspeed.JetspeedServlet)接收

2 JetspeedServlet透過Jetspeed(org.apache.jetspeed.Jetspeed)取得ComponentManager,然後透過ComponentManager取得RequestContextComponent(org.apache.jetspeed.request.JetspeedRequestContextComponent)

3 RequestContextComponent會針對這個request建立一個RequestContext(org.apache.jetspeed.JetspeedRequestContext),並且讓這個request和新建的RequestContext能互相參照

4 呼叫Engine(org.apache.jetspeed.JetspeedEngine)的service()方法,這個方法會把剛剛建立的RequestContext傳入,這樣後面的元件才能使用

5 在service()方法中,Engine會依據request的目標URL來取得相對應的Pipeline(org.apache.jetspeed.pipelineJetspeedPipeline)來處理。Pipeline使用了chain of responsibility的pattern,是由一堆Valve(org.apache.jetspeed.pipeline.valve.Valve)串起來的

6 各個Valve依序執行,其中某些Valve會和Container動作,某些Valve會負責產生要response的portal頁面。在這個過程中,Continer會執行相關的Portlet,並將結果返回至Pipeline,也就是Valve chain中。

7 將產生的portal頁面傳回給user,流程結束


由上面的介紹,應該可以體會到Pipeline在J2中是非常重要的元件。這裡附上Pipeline的官方UML簡圖做參考


而J2本身是Spring-based的架構,主要的Spring設定檔都在"C:\tomcat\webapps\jetspeed\WEB-INF\assembly"下。JetspeedServlet在init時會建立Spring容器並載入這些設定檔,而之前提到的ComponentManager就可以透過name或class在Spring容器中尋找需要的component。有關J2的component,請務必參考http://portals.apache.org/jetspeed-2/guides/guide-components.html及原始碼。

來看一下目錄中的pipelines.xml。這個XML是用來組合各個Pipeline和設定各Pipeline和其對應的URL。先看一下最後一段bean id="pipeline-map"的部份,在這邊可以看到URL和其相對應的Pipeline。另外找到bean id="jetspeed-pipeline"這一段,可以看到這個Pipeline中Valve的組合,而這個Pipeline也是default的Pipeline;有興趣的不妨參考這份XML把這個Pipeline中的Valve的原始碼找到翻一翻,大致了解一下每個Valve在做啥,還蠻有幫助的。

如果依照之前所寫的echo portlet,其FORM的action URL起頭為/portal,而Engine會用此做為key由"pipeline-map"中找到"jetspeed-pipeline"這個Pipeline來處理。

底下這個是J2附的Valve官方簡圖,大家參考一下


vote up 0 vote down
wayyoung edited on 2006-01-03 08:52
reply to postreply to post
作者 Re:Jetspeed-2 心得隨筆(3)-Overview [Re:wayyoung]
natte





發文: 15
積分: 0
於 2005-12-23 10:41 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
集成太麻烦了!

vote up 0 vote down
reply to postreply to post
咖啡+牛奶
我本將心向明月,奈何明月照溝渠!

» JavaWorld@TW »  Java Tools

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JavaWorld@TW


Powered by Powerful JuteForum® Version Jute 1.5.8
Copyright© 2002-2003 Rainman Zhu,Zua,Netboy,Scott. All Rights Reserved.