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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected static final Pathprotected static final PatternJava options split by spaces followed by an even number of quotes (or zero).static final StringJava options configured inbin/nuxeo.confandbin/nuxeoctl.static final Stringstatic final Stringprotected static final StringAbsolute or relative PATH to the included templates (comma separated list).protected final PropertiesSystem properties used to load the configuration, generallySystem.getProperties().static final Stringstatic final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionDeprecated.ConfigurationGenerator(boolean quiet, boolean debug) Deprecated.since 11.5, usebuilder()instead.protected -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTemplate(String templatesToAdd) Add template(s) to theConfigurationConstants.PARAM_TEMPLATES_NAMElist if not already presentstatic ConfigurationGeneratorbuild()builder()protected voidGenerate properties which values are based on othersprotected voidgetChangedParameters(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 theConfigurationHolderheld by the generator.getEnv()getJavaOpts(Function<String, String> mapper) Gets the Java options defined in Nuxeo configuration files, e.g.protected voidbooleaninit()Initialize configurator, check requirements and load current configurationbooleaninit(boolean forceReload) Initialize configurator, check requirements and load current configurationprotected static voidinitLogsIfNeeded(ConfigurationHolder configHolder) Initializes log configuration if it doesn't exist.voidrmTemplate(String templatesToRm) Remove template(s) from theConfigurationConstants.PARAM_TEMPLATES_NAMElistvoidrun()Runs the configuration files generation.voidsaveConfiguration(Map<String, String> changedParameters) Save changed parameters innuxeo.conf.voidsaveConfiguration(Map<String, String> changedParameters, boolean setGenerationOnceToFalse, boolean setGenerationFalseToOnce) Save changed parameters innuxeo.conf.voidsaveFilteredConfiguration(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 configurationvoidCreate 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.confandbin/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 givenconfigHolderis 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_NAMEandConfigurationConstants.PARAM_FORCE_GENERATIONcannot 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_NAMElist if not already present- Parameters:
templatesToAdd- Comma separated templates to add- Throws:
ConfigurationException- Since:
- 5.5
-
rmTemplate
Remove template(s) from theConfigurationConstants.PARAM_TEMPLATES_NAMElist- 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
Environmentinitialized with a few basics - Since:
- 5.6
-
getCrypto
-
getJavaOpts
Gets the Java options defined in Nuxeo configuration files, e.g.bin/nuxeo.confandbin/nuxeoctl.- Returns:
- the Java options.
- Since:
- 9.3
-
getConfigurationHolder
Returns theConfigurationHolderheld by the generator.This configuration could be empty if the
init()method hasn't been called.- Returns:
- the
ConfigurationHolderheld by the generator. - Since:
- 11.5
- See Also:
-
build()instead.