Package org.nuxeo.launcher.config
Class ConfigurationGenerator
java.lang.Object
org.nuxeo.launcher.config.ConfigurationGenerator
Builder for server configuration and datasource files from templates and properties.
- Author:
- jcarsique
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected static final Path
protected static final Pattern
Java options split by spaces followed by an even number of quotes (or zero).static final String
Java options configured inbin/nuxeo.conf
andbin/nuxeoctl
.static final String
static final String
protected static final String
Absolute or relative PATH to the included templates (comma separated list).protected final Properties
System properties used to load the configuration, generallySystem.getProperties()
.static final String
static final String
-
Constructor Summary
ModifierConstructorDescriptionDeprecated.ConfigurationGenerator
(boolean quiet, boolean debug) Deprecated.since 11.5, usebuilder()
instead.protected
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTemplate
(String templatesToAdd) Add template(s) to theConfigurationConstants.PARAM_TEMPLATES_NAME
list if not already presentstatic ConfigurationGenerator
build()
builder()
protected void
Generate properties which values are based on othersprotected void
getChangedParameters
(Map<String, String> changedParameters) Filters given parameters including them only if (there was no previous value and new value is not empty/null) or (there was a previous value and it differs from the new value)Returns theConfigurationHolder
held by the generator.getEnv()
getJavaOpts
(Function<String, String> mapper) Gets the Java options defined in Nuxeo configuration files, e.g.protected void
boolean
init()
Initialize configurator, check requirements and load current configurationboolean
init
(boolean forceReload) Initialize configurator, check requirements and load current configurationprotected static void
initLogsIfNeeded
(ConfigurationHolder configHolder) Initializes log configuration if it doesn't exist.void
rmTemplate
(String templatesToRm) Remove template(s) from theConfigurationConstants.PARAM_TEMPLATES_NAME
listvoid
run()
Runs the configuration files generation.void
saveConfiguration
(Map<String, String> changedParameters) Save changed parameters innuxeo.conf
.void
saveConfiguration
(Map<String, String> changedParameters, boolean setGenerationOnceToFalse, boolean setGenerationFalseToOnce) Save changed parameters innuxeo.conf
.void
saveFilteredConfiguration
(Map<String, String> changedParameters) Save changed parameters innuxeo.conf
, filtering parameters withgetChangedParameters(Map)
setProperties
(String template, Map<String, String> newParametersToSave) Set properties in the given template, if it existssetProperties
(Map<String, String> newParametersToSave) Set properties in nuxeo configurationsetProperty
(String key, String value) Set a property in nuxeo configurationvoid
Create needed directories.
-
Field Details
-
TEMPLATE_SEPARATOR
- Since:
- 6.0
- See Also:
- Implementation Note:
- also used for profiles
-
NUXEO_ENVIRONMENT_CONF_FORMAT
- Since:
- 11.1
- See Also:
-
PARAM_INCLUDED_TEMPLATES
Absolute or relative PATH to the included templates (comma separated list).- See Also:
-
JAVA_OPTS_PATTERN
Java options split by spaces followed by an even number of quotes (or zero).- Since:
- 9.3
-
JAVA_OPTS_PROP
Java options configured inbin/nuxeo.conf
andbin/nuxeoctl
.- Since:
- 9.3
- See Also:
-
VERSIONED_REGEX
- See Also:
-
BOOTSTRAP_JAR_REGEX
- See Also:
-
JULI_JAR_REGEX
- See Also:
-
DEFAULT_NUXEO_CONF_PATH
- Since:
- 11.5
-
systemProperties
System properties used to load the configuration, generallySystem.getProperties()
.- Since:
- 11.5
-
-
Constructor Details
-
Method Details
-
build
- Since:
- 11.5
-
builder
- Since:
- 11.5
-
initLogsIfNeeded
Initializes log configuration if it doesn't exist.This is called in
ConfigurationGenerator(Builder)
, so the givenconfigHolder
is not yetloaded
.- Since:
- 11.5
-
getUserConfig
-
run
Runs the configuration files generation.- Throws:
ConfigurationException
-
init
public boolean init()Initialize configurator, check requirements and load current configuration- Returns:
- returns true if current install is configurable, else returns false
-
init
public boolean init(boolean forceReload) Initialize configurator, check requirements and load current configuration- Parameters:
forceReload
- If true, forces configuration reload.- Returns:
- returns true if current install is configurable, else returns false
- Since:
- 5.6
-
includeTemplates
- Throws:
ConfigurationException
- Since:
- 5.7
-
evalDynamicProperties
Generate properties which values are based on others- Returns:
- Map with new parameters to save in
nuxeoConf
- Throws:
ConfigurationException
- Since:
- 5.5
-
generateFiles
- Throws:
ConfigurationException
-
saveConfiguration
Save changed parameters innuxeo.conf
. This method does not check values in map. UsesaveFilteredConfiguration(Map)
for parameters filtering.- Parameters:
changedParameters
- Map of modified parameters- Throws:
ConfigurationException
- See Also:
-
saveConfiguration
public void saveConfiguration(Map<String, String> changedParameters, boolean setGenerationOnceToFalse, boolean setGenerationFalseToOnce) throws ConfigurationExceptionSave changed parameters innuxeo.conf
. If a parameter value is empty ("" or null), then the property is unset.ConfigurationConstants.PARAM_TEMPLATES_NAME
andConfigurationConstants.PARAM_FORCE_GENERATION
cannot be unset, but their value can be changed.This method does not check values in map: use
saveFilteredConfiguration(Map)
for parameters filtering.- Parameters:
changedParameters
- Map of modified parameterssetGenerationOnceToFalse
- If generation was on (true or once), then set it to false or not?setGenerationFalseToOnce
- If generation was off (false), then set it to once?- Throws:
ConfigurationException
- Since:
- 5.5
- See Also:
-
saveFilteredConfiguration
public void saveFilteredConfiguration(Map<String, String> changedParameters) throws ConfigurationExceptionSave changed parameters innuxeo.conf
, filtering parameters withgetChangedParameters(Map)
- Parameters:
changedParameters
- Maps of modified parameters- Throws:
ConfigurationException
- Since:
- 5.4.2
- See Also:
-
getChangedParameters
Filters given parameters including them only if (there was no previous value and new value is not empty/null) or (there was a previous value and it differs from the new value)- Parameters:
changedParameters
- parameters to be filtered- Returns:
- filtered map
- Since:
- 5.4.2
-
verifyInstallation
Create needed directories. Check existence of old paths. If old paths have been found and they cannot be upgraded automatically, then upgrading message is logged and error thrown.- Throws:
ConfigurationException
- If a deprecated directory has been detected.- Since:
- 5.4.2
-
createDirectoriesIfNotExist
- Throws:
IOException
- Since:
- 11.5
-
addTemplate
Add template(s) to theConfigurationConstants.PARAM_TEMPLATES_NAME
list if not already present- Parameters:
templatesToAdd
- Comma separated templates to add- Throws:
ConfigurationException
- Since:
- 5.5
-
rmTemplate
Remove template(s) from theConfigurationConstants.PARAM_TEMPLATES_NAME
list- Parameters:
templatesToRm
- Comma separated templates to remove- Throws:
ConfigurationException
- Since:
- 5.5
-
setProperty
Set a property in nuxeo configuration- Returns:
- The old value
- Throws:
ConfigurationException
- Since:
- 5.5
-
setProperties
public Map<String,String> setProperties(Map<String, String> newParametersToSave) throws ConfigurationExceptionSet properties in nuxeo configuration- Returns:
- The old values
- Throws:
ConfigurationException
- Since:
- 7.4
-
setProperties
public Map<String,String> setProperties(String template, Map<String, String> newParametersToSave) throws ConfigurationExceptionSet properties in the given template, if it exists- Returns:
- The old values
- Throws:
ConfigurationException
- Since:
- 7.4
-
getEnv
- Returns:
- an
Environment
initialized with a few basics - Since:
- 5.6
-
getCrypto
-
getJavaOpts
Gets the Java options defined in Nuxeo configuration files, e.g.bin/nuxeo.conf
andbin/nuxeoctl
.- Returns:
- the Java options.
- Since:
- 9.3
-
getConfigurationHolder
Returns theConfigurationHolder
held by the generator.This configuration could be empty if the
init()
method hasn't been called.- Returns:
- the
ConfigurationHolder
held by the generator. - Since:
- 11.5
- See Also:
-
build()
instead.