这篇文章继续对Liferay启动过程的processStartupEvents()方法进行分析。
在初始化完集群节点和定时器之后,Liferay开始校验数据库:
(12)校验数据库:
- // Verify
- if (_log.isDebugEnabled()) {
- _log.debug("Verify database");
- }
- DBUpgrader.verify();
它会去调用DBUpgrader的verify()方法:
- public static void verify() throws Exception {
- // Verify
- Release release = null;
- try {
- release = ReleaseLocalServiceUtil.getRelease(
- ReleaseConstants.DEFAULT_SERVLET_CONTEXT_NAME,
- ReleaseInfo.getBuildNumber());
- }
- catch (PortalException pe) {
- release = ReleaseLocalServiceUtil.addRelease(
- ReleaseConstants.DEFAULT_SERVLET_CONTEXT_NAME,
- ReleaseInfo.getBuildNumber());
- }
- StartupHelperUtil.verifyProcess(release.isVerified());
- // Update indexes
- if (StartupHelperUtil.isUpgraded()) {
- StartupHelperUtil.updateIndexes();
- }
- // Update release
- boolean verified = StartupHelperUtil.isVerified();
- if (release.isVerified()) {
- verified = true;
- }
- ReleaseLocalServiceUtil.updateRelease(
- release.getReleaseId(), ReleaseInfo.getBuildNumber(),
- ReleaseInfo.getBuildDate(), verified);
- // Enable database caching after verify
- CacheRegistryUtil.setActive(true);
- }
要展开又没底了,反正从宏观上看,它主要做校验版本,更新索引,设置校验状态位,启用数据库缓存。
(13)JSPFactorySwap
- // Liferay JspFactory
- JspFactorySwapper.swap();
就是用在Tomcat中,使用JSPFactoryWrapper来代替JSPFactory:
- public static void swap() {
- if (!ServerDetector.isTomcat()) {
- return;
- }
- JspFactory jspFactory = JspFactory.getDefaultFactory();
- if (jspFactory instanceof JspFactoryWrapper) {
- return;
- }
- synchronized (JspFactorySwapper.class) {
- if (_jspFactoryWrapper == null) {
- _jspFactoryWrapper = new JspFactoryWrapper(jspFactory);
- }
- JspFactory.setDefaultFactory(_jspFactoryWrapper);
- }
- }
因为JSPFactoryWrapper比JSPFactory更强大,具体参见JSPFactoryWrapper类。
(14)分析HTML的LoggerFactory
- // Jericho
- CachedLoggerProvider.install();
它会去使用net.htmlparser.jericho.LoggerFactory这个开源项目的日志器:
- public static void install() throws Exception {
- Class<?> clazz = Class.forName("net.htmlparser.jericho.LoggerFactory");
- Method method = ReflectionUtil.getDeclaredMethod(
- clazz, "getDefaultLoggerProvider");
- LoggerProvider loggerProvider = (LoggerProvider)method.invoke(null);
- CachedLoggerProvider cachedLoggerProvider = new CachedLoggerProvider(
- loggerProvider);
- Config.LoggerProvider = cachedLoggerProvider;
- }
转载于:https://blog.51cto.com/supercharles888/905968