Liferay 啟動過程分析

lightwing發表於2021-09-09

前幾天搞了一個BUG,吧精力耗盡,也激發了我對Liferay這個框架內部的探究慾望。所以這幾天端午節準備對Liferay框架啟動過程進行深入研究,來滿足自己的好奇心。

 

當我們在位址列中訪問:

         index.html         index.jsp     

 

所以,它會去找index.jsp:

...               " http-equiv="refresh" />   ')">    

 

其中,最值得看的就是

 

然後找到並替換之後,去執行PropsUtil.get("portal.ctx");

public static String get(String key) {     return _instance._get(key); }

 

它會訪問

private String _get(String key) {         return _getConfiguration().get(key);     }

這段程式碼最終會訪問配置檔案,然後讀取key-value對到Configuration中,我們在portal.properties中找到了portal.ctx的定義:


  1. ## 

  2. ## Portal Context 

  3. ## 

  4.  

  5.     # 

  6.     # Specify the path of the portal servlet context. This is needed because 

  7.     # javax.servlet.ServletContext did not have access to the context path until 

  8.     # Java EE 5. 

  9.     # 

  10.     # Set this property if you deploy the portal to another path besides root. 

  11.     # 

  12.     portal.ctx=/ 


所以portal.ctx=/

 

解析PATH_MAIN:

它在Portal介面中有定義:

public static final String PATH_MAIN = "/c";

 

所以綜上所述,在PortalImpl構造器中的_pathMain = _pathContext + PATH_MAIN="/"+"/c"="//c"

它就是的值。

 

所以當index.jsp中DOM樹載入完畢之後,它會去執行:


  

 

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/3407/viewspace-2814984/,如需轉載,請註明出處,否則將追究法律責任。

相關文章