public static synchronized void init() { if (_initialized) { return; } StopWatch stopWatch = new StopWatch(); stopWatch.start(); // Set the default locale used by Liferay. This locale is no longer set // at the VM level. See LEP-2584. String userLanguage = SystemProperties.get("user.language"); String userCountry = SystemProperties.get("user.country"); String userVariant = SystemProperties.get("user.variant"); LocaleUtil.setDefault(userLanguage, userCountry, userVariant); // Set the default time zone used by Liferay. This time zone is no // longer set at the VM level. See LEP-2584. String userTimeZone = SystemProperties.get("user.timezone"); TimeZoneUtil.setDefault(userTimeZone); // Shared class loader try { PortalClassLoaderUtil.setClassLoader(ClassLoaderUtil.getContextClassLoader()); } catch (Exception e) { e.printStackTrace(); } // Properties com.liferay.portal.kernel.util.PropsUtil.setProps(new PropsImpl()); // Log4J if (GetterUtil.getBoolean(SystemProperties.get("log4j.configure.on.startup"), true)) { ClassLoader classLoader = InitUtil.class.getClassLoader(); Log4JUtil.configureLog4J(classLoader); } // Shared log try { LogFactoryUtil.setLogFactory(new Log4jLogFactoryImpl()); } catch (Exception e) { e.printStackTrace(); } // Log sanitizer SanitizerLogWrapper.init(); // Java properties JavaDetector.isJDK5(); // Security manager SecurityManagerUtil.init(); if (SecurityManagerUtil.ENABLED) { com.liferay.portal.kernel.util.PropsUtil.setProps( DoPrivilegedUtil.wrap(com.liferay.portal.kernel.util.PropsUtil.getProps())); LogFactoryUtil.setLogFactory(DoPrivilegedUtil.wrap(LogFactoryUtil.getLogFactory())); } // Cache registry CacheRegistryUtil.setCacheRegistry(DoPrivilegedUtil.wrap(new CacheRegistryImpl())); // Configuration factory ConfigurationFactoryUtil.setConfigurationFactory( DoPrivilegedUtil.wrap(new ConfigurationFactoryImpl())); // Data source factory DataSourceFactoryUtil.setDataSourceFactory(DoPrivilegedUtil.wrap(new DataSourceFactoryImpl())); // DB factory DBFactoryUtil.setDBFactory(DoPrivilegedUtil.wrap(new DBFactoryImpl())); // ROME XmlReader.setDefaultEncoding(StringPool.UTF8); if (_PRINT_TIME) { System.out.println("InitAction takes " + stopWatch.getTime() + " ms"); } _initialized = true; }
public static void reset() { setDBFactory(null); }