generated from cuioss/cui-java-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disentangle configuration-impl from configuration-yaml
- Loading branch information
Showing
25 changed files
with
269 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...-api/src/main/java/de/cuioss/portal/configuration/source/ConfigurationSourceResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package de.cuioss.portal.configuration.source; | ||
|
||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import de.cuioss.portal.configuration.ConfigurationSource; | ||
import de.cuioss.tools.io.FileLoader; | ||
|
||
/** | ||
* SPI for resolving different types of {@link ConfigurationSource}s | ||
*/ | ||
public interface ConfigurationSourceResolver { | ||
|
||
/** | ||
* @param source must not be null | ||
* @return the concrete {@link ConfigurationSource} if available. | ||
*/ | ||
Optional<ConfigurationSource> resolve(FileLoader source); | ||
|
||
/** | ||
* @return the supported file-suffixes | ||
*/ | ||
Set<String> supportedSuffixes(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...de/cuioss/portal/configuration/impl/source/JavaPropertiesConfigurationSourceResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package de.cuioss.portal.configuration.impl.source; | ||
|
||
import static de.cuioss.tools.collect.CollectionLiterals.immutableSet; | ||
import static de.cuioss.tools.string.MoreStrings.isEmpty; | ||
|
||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import de.cuioss.portal.configuration.ConfigurationSource; | ||
import de.cuioss.portal.configuration.impl.PropertiesConfigurationProvider; | ||
import de.cuioss.portal.configuration.source.ConfigurationSourceResolver; | ||
import de.cuioss.tools.io.FileLoader; | ||
import de.cuioss.tools.logging.CuiLogger; | ||
|
||
/** | ||
* | ||
*/ | ||
public class JavaPropertiesConfigurationSourceResolver implements ConfigurationSourceResolver { | ||
|
||
private static final String SUFFIX = "properties"; | ||
private static final String MSG_LOAD_ERROR = "Portal-519: Unable to load configuration file: {}, due to: {}"; | ||
private static final CuiLogger LOGGER = new CuiLogger(JavaPropertiesConfigurationSourceResolver.class); | ||
|
||
@Override | ||
public Optional<ConfigurationSource> resolve(FileLoader source) { | ||
if ((null == source) || isEmpty(source.getFileName().getOriginalName())) { | ||
LOGGER.debug("Nothing to load found"); | ||
return Optional.empty(); | ||
} | ||
|
||
final var suffix = source.getFileName().getSuffix().toLowerCase(); | ||
if (SUFFIX.equals(suffix)) { | ||
LOGGER.debug("Found properties file {}", source); | ||
if (!source.isReadable()) { | ||
LOGGER.error(MSG_LOAD_ERROR, source, "not readable"); | ||
return Optional.empty(); | ||
} | ||
return Optional.of(new PropertiesConfigurationProvider(source)); | ||
} | ||
|
||
LOGGER.debug("Given file seems not to represent a properties file: {}", source); | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Set<String> supportedSuffixes() { | ||
return immutableSet(SUFFIX); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...tion/portal-configuration-impl/src/main/resources/META-INF/microprofile-config.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Defines the default configuration for the CUI-Portal | ||
|
||
# Context parameter within configuration-subsysten with the name "portal.locale.default" | ||
# Defines the default locale. Caution: the default locale must be defined within | ||
# "portal.locale.available". | ||
# The default value for the is: 'de' | ||
portal.locale.default=de | ||
|
||
# Context parameter within configuration-subsysten with the name "portal.locale.available" | ||
# Defines the available locales for for the Portal as a comma separated list. | ||
# The default value for the is: 'en,de,fr' | ||
portal.locale.available=en,de,fr | ||
|
||
# Path to the Portals configuration directory. | ||
portal.configuration.dir=config/ | ||
|
||
# Used for the configuration of tracking of changes in files, usually configuration files, | ||
# see FileWatcherService for handling details. | ||
# This is the successor of the previous cron-based approach. | ||
# The default-value is true | ||
portal.configuration.file_watcher.enabled=true | ||
|
||
# Project-Stage | ||
# | ||
# Used for the configuration of the Portal project stage. Defaults to 'production'. | ||
# Valid values are: production, test, configuration, development. | ||
# The mapping between Portal stages and their JSF equivalent is as follows | ||
# (Portal-stage -> JSF-stage): | ||
# production -> Production, test -> SystemTest, | ||
# configuration -> Production, development -> Development | ||
portal.configuration.stage=production | ||
|
||
# 1 year | ||
portal.storage.cookieMaxAge=31536000 | ||
|
||
# Defines the maximum interval (in minutes) the user may be inactive | ||
# before we black the screen and display the idle message dialog. | ||
# Should correspond with "timeout". If not set, the timeout value will be used as default. | ||
# Technically this behavior is achieved by setting the "maxInactiveInterval" to the value '-1'. | ||
portal.session.maxInactiveInterval=-1 | ||
|
||
# Defines the timeout (in minutes) of the session in the jsf server. | ||
portal.session.timeout=20 | ||
|
||
# Servlet based authentication | ||
portal.authentication.servlet.allowBasicAuth=true | ||
|
||
# Keep in sync with 'portal.configuration.stage' | ||
smallrye.config.profile=${portal.configuration.stage} |
Oops, something went wrong.