Пример #1
0
  protected void doRun(String[] ids) throws Exception {

    // Print release information

    System.out.println("Starting " + ReleaseInfo.getReleaseInfo());

    // Portal resiliency

    DistributedRegistry.registerDistributed(
        ComponentConstants.COMPONENT_CONTEXT, Direction.DUPLEX, MatchType.POSTFIX);
    DistributedRegistry.registerDistributed(
        MimeResponse.MARKUP_HEAD_ELEMENT, Direction.DUPLEX, MatchType.EXACT);
    DistributedRegistry.registerDistributed(
        PortletRequest.LIFECYCLE_PHASE, Direction.DUPLEX, MatchType.EXACT);
    DistributedRegistry.registerDistributed(WebKeys.class);

    Intraband intraband = MPIHelperUtil.getIntraband();

    intraband.registerDatagramReceiveHandler(
        SystemDataType.MAILBOX.getValue(), new MailboxDatagramReceiveHandler());

    MessageBus messageBus = (MessageBus) PortalBeanLocatorUtil.locate(MessageBus.class.getName());

    intraband.registerDatagramReceiveHandler(
        SystemDataType.MESSAGE.getValue(), new MessageDatagramReceiveHandler(messageBus));

    intraband.registerDatagramReceiveHandler(
        SystemDataType.PROXY.getValue(), new IntrabandProxyDatagramReceiveHandler());

    intraband.registerDatagramReceiveHandler(
        SystemDataType.RPC.getValue(), new RPCDatagramReceiveHandler());

    // Shutdown hook

    if (_log.isDebugEnabled()) {
      _log.debug("Add shutdown hook");
    }

    Runtime runtime = Runtime.getRuntime();

    runtime.addShutdownHook(new Thread(new ShutdownHook()));

    // Template manager

    if (_log.isDebugEnabled()) {
      _log.debug("Initialize template manager");
    }

    TemplateManagerUtil.init();

    // Indexers

    IndexerRegistryUtil.register(new MBMessageIndexer());
    IndexerRegistryUtil.register(new PluginPackageIndexer());

    // Upgrade

    if (_log.isDebugEnabled()) {
      _log.debug("Upgrade database");
    }

    DBUpgrader.upgrade();

    // Clear locks

    if (_log.isDebugEnabled()) {
      _log.debug("Clear locks");
    }

    try {
      LockLocalServiceUtil.clear();
    } catch (Exception e) {
      if (_log.isWarnEnabled()) {
        _log.warn("Unable to clear locks because Lock table does not exist");
      }
    }

    // Messaging

    if (_log.isDebugEnabled()) {
      _log.debug("Initialize message bus");
    }

    MessageSender messageSender =
        (MessageSender) PortalBeanLocatorUtil.locate(MessageSender.class.getName());
    SynchronousMessageSender synchronousMessageSender =
        (SynchronousMessageSender)
            PortalBeanLocatorUtil.locate(SynchronousMessageSender.class.getName());

    MessageBusUtil.init(
        DoPrivilegedUtil.wrap(messageBus),
        DoPrivilegedUtil.wrap(messageSender),
        DoPrivilegedUtil.wrap(synchronousMessageSender));

    // Cluster executor

    ClusterExecutorUtil.initialize();

    if (!SPIUtil.isSPI()) {
      ClusterMasterExecutorUtil.initialize();
    }

    // Ehache bootstrap

    EhcacheStreamBootstrapCacheLoader.start();

    // Scheduler

    if (_log.isDebugEnabled()) {
      _log.debug("Initialize scheduler engine lifecycle");
    }

    SchedulerEngineHelperUtil.initialize();

    // Verify

    if (_log.isDebugEnabled()) {
      _log.debug("Verify database");
    }

    DBUpgrader.verify();

    // Background tasks

    if (!ClusterMasterExecutorUtil.isEnabled()) {
      BackgroundTaskLocalServiceUtil.cleanUpBackgroundTasks();
    }

    // Liferay JspFactory

    JspFactorySwapper.swap();

    // Jericho

    CachedLoggerProvider.install();
  }
Пример #2
0
  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;
  }