Commit b059e823 authored by Ard Schrijvers's avatar Ard Schrijvers

HSTTWO-4333 By default, use old hst node loading behavior and spring init

By default, the old (pre 12.x style) loading of hst config nodes (lazy
on first request) is used and by default the spring component manager
is initialized without checking and/or waiting whether the repository
is already up and running. To get in version 11.2 or 10.2 to the behavior
of version 12.x, you need to add to your web.xml:

  <context-param>
    <param-name>hst-lazy-configuration-loading</param-name>
    <param-value>false</param-value>
  </context-param>

  <context-param>
    <param-name>hst-wait-for-repository-to-start</param-name>
    <param-value>true</param-value>
  </context-param>
parent d946a7f9
/*
* Copyright 2008-2017 Hippo B.V. (http://www.onehippo.com)
* Copyright 2008-2018 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -150,6 +150,7 @@ public class DefaultHstSiteConfigurer implements HstSiteConfigurer {
private boolean hstSystemPropertiesOverride = true;
private boolean lazyHstConfigurationLoading = false;
private boolean waitForRepositoryToStart = false;
private String hstConfigEnvProperties = HST_CONFIG_ENV_PROPERTIES;
......@@ -233,7 +234,8 @@ public class DefaultHstSiteConfigurer implements HstSiteConfigurer {
return;
}
lazyHstConfigurationLoading = BooleanUtils.toBoolean(getConfigOrContextInitParameter(HST_LAZY_HST_CONFIGURATION_LOADING_PARAM, "false"));
lazyHstConfigurationLoading = BooleanUtils.toBoolean(getConfigOrContextInitParameter(HST_LAZY_HST_CONFIGURATION_LOADING_PARAM, "true"));
waitForRepositoryToStart = BooleanUtils.toBoolean(getConfigOrContextInitParameter(HST_WAIT_FOR_REPOSITORY_TO_START_PARAM, "false"));
hstSystemPropertiesOverride = BooleanUtils.toBoolean(getConfigOrContextInitParameter(HST_SYSTEM_PROPERTIES_OVERRIDE_PARAM, "true"));
hstConfigEnvProperties = getConfigOrContextInitParameter(HST_CONFIG_ENV_PROPERTIES_PARAM, HST_CONFIG_ENV_PROPERTIES);
......@@ -249,7 +251,9 @@ public class DefaultHstSiteConfigurer implements HstSiteConfigurer {
assemblyOverridesConfigurations = this.configuration.getStringArray(ASSEMBLY_OVERRIDES_CONFIGURATIONS_PARAM);
}
if (HippoServiceRegistry.getService(RepositoryService.class) != null) {
if (!waitForRepositoryToStart) {
initializeComponentManager();
} else if (HippoServiceRegistry.getService(RepositoryService.class) != null) {
initializeComponentManager();
} else {
initThread = new Thread(() -> {
......@@ -326,7 +330,7 @@ public class DefaultHstSiteConfigurer implements HstSiteConfigurer {
}
}
if (!HstServices.isHstConfigurationNodesLoaded() && !lazyHstConfigurationLoading) {
if (!HstServices.isHstConfigurationNodesLoaded() && !lazyHstConfigurationLoading && waitForRepositoryToStart) {
log.info("Trigger HST Configuration nodes to be loaded");
final long start = System.currentTimeMillis();
final HstNodeLoadingCache hstNodeLoadingCache = componentManager.getComponent(HstNodeLoadingCache.class);
......
/*
* Copyright 2008-2017 Hippo B.V. (http://www.onehippo.com)
* Copyright 2008-2018 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -56,6 +56,7 @@ public interface HstSiteConfigurer extends Serializable {
*/
String HST_LAZY_HST_CONFIGURATION_LOADING_PARAM = "hst-lazy-configuration-loading";
String HST_WAIT_FOR_REPOSITORY_TO_START_PARAM = "hst-wait-for-repository-to-start";
/**
* Loads configuration and initialize HST Container.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment