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, null, true, 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);
- }
- 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;
- }