Skip to content

Commit

Permalink
Extract tomcat specific configuration to specific module
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Sep 6, 2023
1 parent 662cee4 commit fbbe527
Show file tree
Hide file tree
Showing 29 changed files with 419 additions and 110 deletions.
6 changes: 6 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>de.cuioss.portal.configuration</groupId>
<artifactId>portal-configuration-standalone</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Authentication-->
<dependency>
<groupId>de.cuioss.portal.authentication</groupId>
Expand Down
1 change: 1 addition & 0 deletions modules/configuration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@
<module>portal-configuration-api</module>
<module>portal-configuration-impl</module>
<module>portal-configuration-yaml</module>
<module>portal-configuration-standalone</module>
</modules>
</project>
28 changes: 14 additions & 14 deletions modules/configuration/portal-configuration-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>de.cuioss.portal.configuration</groupId>
<artifactId>portal-configuration-api</artifactId>
</dependency>
<dependency>
<groupId>de.cuioss.portal.configuration</groupId>
<artifactId>portal-configuration-yaml</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
<dependencies>
<dependency>
<groupId>de.cuioss.portal.configuration</groupId>
<artifactId>portal-configuration-api</artifactId>
</dependency>
<dependency>
<groupId>de.cuioss.portal.configuration</groupId>
<artifactId>portal-configuration-yaml</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.awaitility</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
Expand Down Expand Up @@ -97,7 +96,7 @@ public class ConfigChangeObserver implements ApplicationInitializer {
private Instance<FileWatcherService> fileWatcherServices;

@Inject
private List<FileConfigurationSource> fileConfigurationSources;
private Instance<FileConfigurationSource> fileConfigurationSources;

/** Fired, if the configuration of the changed file has changed */
@Inject
Expand Down Expand Up @@ -172,7 +171,7 @@ private Map<String, String> getAffectedPropertiesAndIndirections(Map<String, Str
LOGGER.debug("Adding affected properties to delta map: {}", affectedProperties);
deltaMap.putAll(affectedProperties);

if (LOOP_LIMIT == i + 1) {
if (LOOP_LIMIT == (i + 1)) {
LOGGER.debug("Reached loop limit of {} iterations for finding config placeholder indirections",
LOOP_LIMIT);
}
Expand Down Expand Up @@ -230,7 +229,7 @@ private Map<String, String> getFileChangeDeltaMap(Path changedFilePath) {
}

private boolean containsPlaceholder(final String haystack, final String needle) {
return null != haystack && null != needle
return (null != haystack) && (null != needle)
&& (haystack.contains("${" + needle + "}") || haystack.contains("${" + needle + ":"));
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public final class FancyYamlFileConfigSource extends YamlConfigSource {

public FancyYamlFileConfigSource() {
super("classpath:/config/yml/application.yml");
super("classpath:/config/yml/application-user.yml");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@

import de.cuioss.portal.configuration.impl.producer.PortalConfigProducer;
import de.cuioss.portal.configuration.impl.schedule.ConfigChangeObserver;
import de.cuioss.portal.configuration.impl.source.InstallationConfigSourcePathInitializer;
import de.cuioss.portal.configuration.impl.source.InstallationFileConfigSource;
import de.cuioss.portal.configuration.impl.source.InstallationProductionFileConfigSource;
import io.smallrye.config.inject.ConfigProducer;

/**
Expand All @@ -39,8 +36,6 @@
* <li>{@link ConfigProducer}</li>
* <li>{@link PortalConfigProducer}</li>
* <li>{@link PortalConfigurationMock}</li>
* <li>{@link InstallationFileConfigSource}</li>
* <li>{@link InstallationProductionFileConfigSource}</li>
* </ul>
*
* @author Sven Haag
Expand All @@ -49,6 +44,6 @@
@Retention(RUNTIME)
@Target(TYPE)
@AddBeanClasses({ ConfigProducer.class, PortalConfigProducer.class, PortalConfigurationMock.class,
InstallationConfigSourcePathInitializer.class, ConfigChangeObserver.class })
ConfigChangeObserver.class })
public @interface EnablePortalConfigurationLocal {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Keep this test SPI content in sync with the pom.xml's antrun plugin!
# Only this way the tests are running fine in your IDE and Maven.

de.cuioss.portal.configuration.impl.source.InstallationFileConfigSource
de.cuioss.portal.configuration.impl.source.InstallationProductionFileConfigSource
de.cuioss.portal.configuration.impl.support.TestEnvConfigSource
de.cuioss.portal.configuration.impl.support.PortalConfigurationMock
de.cuioss.portal.configuration.impl.support.TestYamlFileConfigurationSource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
my.user.key: user-value
key-with-value: user-value
key-bool: true
key-with-value: stringvalue
key-with-no-value:
key-master:
key-sub-number: 123456
key-sub-master:
key-sub-master-bool: yes
key-sub-master-string: stringvalue
nested.key.replacement: ${key-with-value:default-nested-key-value}

#SHOULD RESULT IN THE FOLLOWING PROPERTIES:
#key-bool = true
#key-with-value = stringvalue
#key-with-no-value =
#key-master.key-sub-number = 123456
#key-master.key-sub-master.key-sub-master-bool = true
#key-master.key-sub-master.key-sub-master-string = stringvalue

array:
list:
- "a"
- "b"
- c
string.list: "a,b,c"
15 changes: 15 additions & 0 deletions modules/configuration/portal-configuration-standalone/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
= portal-configuration-standalone

== What is it?

Provides structure for configuration that can be used in a non quarkus context. It handle application.yml an so on

=== Maven Coordinates

[source,xml]
----
<dependency>
<groupId>de.cuioss.portal.configuration</groupId>
<artifactId>portal-configuration-standalone</artifactId>
</dependency>
----
37 changes: 37 additions & 0 deletions modules/configuration/portal-configuration-standalone/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.cuioss.portal.configuration</groupId>
<artifactId>configuration</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>portal-configuration-standalone</artifactId>
<name>Portal Standalone Configuration</name>
<description>Provides structure for configuration that can be used in a non
quarkus context. It handle application.yml an so on</description>
<properties>
<maven.jar.plugin.automatic.module.name>
de.cuioss.portal.configuration.standalone</maven.jar.plugin.automatic.module.name>
</properties>
<dependencies>
<dependency>
<groupId>de.cuioss.portal.configuration</groupId>
<artifactId>portal-configuration-api</artifactId>
</dependency>
<dependency>
<groupId>de.cuioss.portal.configuration</groupId>
<artifactId>portal-configuration-impl</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.cuioss.portal.configuration</groupId>
<artifactId>portal-configuration-yaml</artifactId>
</dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.cuioss.portal.configuration.impl.source;
package de.cuioss.portal.configuration.standalone.source;

import static de.cuioss.portal.configuration.PortalConfigurationKeys.PORTAL_CONFIG_DIR;
import static de.cuioss.portal.configuration.PortalConfigurationKeys.PORTAL_CONFIG_DIR_DEFAULT;
Expand All @@ -24,6 +24,7 @@

import de.cuioss.portal.configuration.FileConfigurationSource;
import de.cuioss.portal.configuration.common.PortalPriorities;
import de.cuioss.portal.configuration.impl.source.LoaderUtils;
import de.cuioss.portal.configuration.source.AbstractPortalConfigSource;
import de.cuioss.tools.collect.CollectionLiterals;
import de.cuioss.tools.io.FileSystemLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.cuioss.portal.configuration.impl.source;
package de.cuioss.portal.configuration.standalone.source;

import static de.cuioss.portal.configuration.PortalConfigurationKeys.PORTAL_CONFIG_FILENAME_DEFAULT;

/**
* Configuration source for the application.yml file.
*
* @author Sven Haag, Sven Haag
* @author Sven Haag
*/
public class InstallationFileConfigSource extends AbstractInstallationConfigSource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.cuioss.portal.configuration.impl.source;
package de.cuioss.portal.configuration.standalone.source;

import static de.cuioss.portal.configuration.PortalConfigurationKeys.PORTAL_CONFIG_PRODUCTION_FILENAME_DEFAULT;

/**
* Configuration source for the application-production.yml file.
*
* @author Sven Haag, Sven Haag
* @author Sven Haag
*/
public class InstallationProductionFileConfigSource extends AbstractInstallationConfigSource {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
de.cuioss.portal.configuration.standalone.source.InstallationFileConfigSource
de.cuioss.portal.configuration.standalone.source.InstallationProductionFileConfigSource
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
bean-discovery-mode="annotated" version="2.0">
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.cuioss.portal.configuration.impl.source;
package de.cuioss.portal.configuration.standalone.source;

import static de.cuioss.portal.configuration.PortalConfigurationKeys.PORTAL_CONFIG_DIR;

Expand All @@ -26,6 +26,7 @@
import org.eclipse.microprofile.config.spi.ConfigSource;

import de.cuioss.portal.configuration.ConfigurationSourceChangeEvent;
import de.cuioss.portal.configuration.standalone.source.AbstractInstallationConfigSource;
import de.cuioss.tools.logging.CuiLogger;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.cuioss.portal.configuration.impl.source;
package de.cuioss.portal.configuration.standalone.source;

import static de.cuioss.portal.configuration.PortalConfigurationKeys.PORTAL_CONFIG_DIR;
import static de.cuioss.portal.configuration.PortalConfigurationKeys.PORTAL_CONFIG_DIR_DEFAULT;
Expand All @@ -30,6 +30,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

import de.cuioss.portal.configuration.standalone.source.InstallationFileConfigSource;
import de.cuioss.test.juli.TestLogLevel;
import de.cuioss.test.juli.junit5.EnableTestLogger;
import de.cuioss.tools.string.Joiner;
Expand All @@ -51,7 +52,7 @@ void resolvesPath() {
assertDoesNotThrow(() -> underTest.getPath());
assertNotNull(underTest.getPath());
assertTrue(underTest.getPath().endsWith(
Joiner.on(File.separatorChar).join("portal-configuration-impl", "config", "application.yml")));
Joiner.on(File.separatorChar).join("portal-configuration-standalone", "config", "application.yml")));
assertSingleLogMessagePresentContaining(TestLogLevel.WARN, "Portal-121");
assertSingleLogMessagePresentContaining(TestLogLevel.WARN, "Portal-158");
}
Expand Down
Loading

0 comments on commit fbbe527

Please sign in to comment.