@BeforeClass
  public static void setupClass() throws TemplateException {
    try {
      DBUpgrader.upgrade();
    } catch (Exception e) {
      _log.error(e, e);
    }

    TemplateManagerUtil.init();
  }
Esempio n. 2
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();
  }
  protected void processStartupEvents() throws Exception {

    // Print release information

    Class<?> clazz = getClass();

    ClassLoader classLoader = clazz.getClassLoader();

    try (InputStream inputStream =
        classLoader.getResourceAsStream("com/liferay/portal/events/dependencies/startup.txt")) {

      System.out.println(_toString(inputStream));
    }

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

    if (_log.isDebugEnabled()) {
      _log.debug("Portal Resiliency - NOT SUPPORTED");
    }

    // Shutdown hook

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

    Runtime runtime = Runtime.getRuntime();

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

    // MySQL version

    DB db = DBManagerUtil.getDB();

    if ((db.getDBType() == DBType.MYSQL) && GetterUtil.getFloat(db.getVersionString()) < 5.6F) {

      throw new ServletException(
          "Please upgrade to at least MySQL 5.6.4. The portal no "
              + "longer supports older versions of MySQL.");
    }

    // Check required build number

    if (_log.isDebugEnabled()) {
      _log.debug("Check required build number");
    }

    DBUpgrader.checkRequiredBuildNumber(ReleaseInfo.getParentBuildNumber());

    Registry registry = RegistryUtil.getRegistry();

    Map<String, Object> properties = new HashMap<>();

    properties.put("module.service.lifecycle", "database.initialized");
    properties.put("service.vendor", ReleaseInfo.getVendor());
    properties.put("service.version", ReleaseInfo.getVersion());

    _dbModuleServiceLifecycleServiceRegistration =
        registry.registerService(
            ModuleServiceLifecycle.class, new ModuleServiceLifecycle() {}, properties);

    // Check class names

    if (_log.isDebugEnabled()) {
      _log.debug("Check class names");
    }

    ClassNameLocalServiceUtil.checkClassNames();
  }