Liferay 启动过程分析9

MainServlet中,当初始化社交结束之后,就开始初始化主题了,对应代码是:    if (_log.isDebugEnabled()) {             _log.debug("Initialize themes");         }          try {             initThemes(pluginPackage, portlets);         } .. 

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

protected void initThemes(             PluginPackage pluginPackage, List<Portlet> portlets)         throws Exception {          ServletContext servletContext = getServletContext();          String[] xmls = new String[] {             HttpUtil.URLtoString(                 servletContext.getResource(                     "/WEB-INF/liferay-look-and-feel.xml")),             HttpUtil.URLtoString(                 servletContext.getResource(                     "/WEB-INF/liferay-look-and-feel-ext.xml"))         };          ThemeLocalServiceUtil.init(             servletContext, nulltrue, xmls, pluginPackage);     } 

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

解析是调用ThemLocalServiceUtil的init方法:

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

作为封装,实际是调用的ThemeLocalServiceImpl的5参数的init方法,而它又调用重载的6参数的init方法:

public List<String> init(         String servletContextName, ServletContext servletContext,         String themesPath, boolean loadFromServletContext, String[] xmls,         PluginPackage pluginPackage) {          List<String> themeIdsList = new ArrayList<String>();          try {             for (String xml : xmls) {                 Set<String> themeIds = _readThemes(                     servletContextName, servletContext, themesPath,                     loadFromServletContext, xml, pluginPackage);                  for (String themeId : themeIds) {                     if (!themeIdsList.contains(themeId)) {                         themeIdsList.add(themeId);                     }                 }             }         }         catch (Exception e) {             e.printStackTrace();         }          _themesPool.clear();          return themeIdsList;     } 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/86e45824c871ad3cc3f167f877c799ab.html