Liferay 启动过程分析9-初始化主题

Linux大全评论1.1K views阅读模式

MainServlet中,当初始化社交结束之后,就开始初始化主题了,对应代码是:

 
 
  1.     if (_log.isDebugEnabled()) { 
  2.             _log.debug("Initialize themes"); 
  3.         } 
  4.  
  5.         try { 
  6.             initThemes(pluginPackage, portlets); 
  7.         } 
  8. .. 

它对应的代码在initThemes方法中:

 
 
  1. protected void initThemes( 
  2.             PluginPackage pluginPackage, List<Portlet> portlets) 
  3.         throws Exception { 
  4.  
  5.         ServletContext servletContext = getServletContext(); 
  6.  
  7.         String[] xmls = new String[] { 
  8.             HttpUtil.URLtoString( 
  9.                 servletContext.getResource( 
  10.                     "/WEB-INF/liferay-look-and-feel.xml")), 
  11.             HttpUtil.URLtoString( 
  12.                 servletContext.getResource( 
  13.                     "/WEB-INF/liferay-look-and-feel-ext.xml")) 
  14.         }; 
  15.  
  16.         ThemeLocalServiceUtil.init( 
  17.             servletContext, nulltrue, xmls, pluginPackage); 
  18.     } 

这里可以看出,它仍然是先获取servletContext,然后获得theme有关的配置文件,然后从第16行开始来解析这些配置文件:

 

解析是调用ThemLocalServiceUtil的init方法:

 
 
  1. public static java.util.List<java.lang.String> init( 
  2.         javax.servlet.ServletContext servletContext, 
  3.         java.lang.String themesPath, boolean loadFromServletContext, 
  4.         java.lang.String[] xmls, 
  5.         com.liferay.portal.kernel.plugin.PluginPackage pluginPackage) { 
  6.         return getService() 
  7.                    .init(servletContext, themesPath, loadFromServletContext, 
  8.             xmls, pluginPackage); 
  9.     } 

 

 
 
  1. public List<String> init( 
  2.         String servletContextName, ServletContext servletContext, 
  3.         String themesPath, boolean loadFromServletContext, String[] xmls, 
  4.         PluginPackage pluginPackage) { 
  5.  
  6.         List<String> themeIdsList = new ArrayList<String>(); 
  7.  
  8.         try { 
  9.             for (String xml : xmls) { 
  10.                 Set<String> themeIds = _readThemes( 
  11.                     servletContextName, servletContext, themesPath, 
  12.                     loadFromServletContext, xml, pluginPackage); 
  13.  
  14.                 for (String themeId : themeIds) { 
  15.                     if (!themeIdsList.contains(themeId)) { 
  16.                         themeIdsList.add(themeId); 
  17.                     } 
  18.                 } 
  19.             } 
  20.         } 
  21.         catch (Exception e) { 
  22.             e.printStackTrace(); 
  23.         } 
  24.  
  25.         _themesPool.clear(); 
  26.  
  27.         return themeIdsList; 
  28.     } 

企鹅博客
  • 本文由 发表于 2019年7月19日 16:46:01
  • 转载请务必保留本文链接:https://www.qieseo.com/152714.html

发表评论