From 8cf375b2728c2b6fad7de3bcf9788f251d188f7f Mon Sep 17 00:00:00 2001 From: Andrej Vano Date: Thu, 20 Apr 2023 09:22:46 +0200 Subject: [PATCH] [closes #437] Add defaultConfiguration method to customizable service --- .../software/tnb/common/service/ConfigurableService.java | 5 +++++ .../java/software/tnb/common/service/ServiceFactory.java | 1 + .../java/software/tnb/aws/common/service/AWSService.java | 3 ++- .../src/main/java/software/tnb/jaeger/service/Jaeger.java | 4 ++++ .../java/software/tnb/splunk/resource/local/LocalSplunk.java | 3 ++- .../tnb/splunk/resource/openshift/OpenshiftSplunk.java | 3 ++- 6 files changed, 16 insertions(+), 3 deletions(-) diff --git a/system-x/common/src/main/java/software/tnb/common/service/ConfigurableService.java b/system-x/common/src/main/java/software/tnb/common/service/ConfigurableService.java index cbbdbff39..632dd5b86 100644 --- a/system-x/common/src/main/java/software/tnb/common/service/ConfigurableService.java +++ b/system-x/common/src/main/java/software/tnb/common/service/ConfigurableService.java @@ -35,4 +35,9 @@ public ConfigurableService() { public C getConfiguration() { return configuration; } + + /** + * The default configuration in case no customizations are made. + */ + protected abstract void defaultConfiguration(); } diff --git a/system-x/common/src/main/java/software/tnb/common/service/ServiceFactory.java b/system-x/common/src/main/java/software/tnb/common/service/ServiceFactory.java index 81aa8917e..e60ac21df 100644 --- a/system-x/common/src/main/java/software/tnb/common/service/ServiceFactory.java +++ b/system-x/common/src/main/java/software/tnb/common/service/ServiceFactory.java @@ -68,6 +68,7 @@ public static S create(Class clazz) { public static > S create(Class clazz, Consumer config) { S service = create(clazz); + service.defaultConfiguration(); config.accept(service.getConfiguration()); return service; } diff --git a/system-x/services/aws/common/src/main/java/software/tnb/aws/common/service/AWSService.java b/system-x/services/aws/common/src/main/java/software/tnb/aws/common/service/AWSService.java index fec7f1f2b..b2a629ea2 100644 --- a/system-x/services/aws/common/src/main/java/software/tnb/aws/common/service/AWSService.java +++ b/system-x/services/aws/common/src/main/java/software/tnb/aws/common/service/AWSService.java @@ -24,7 +24,8 @@ public abstract class AWSService im protected JaegerValidation validation; + @Override + protected void defaultConfiguration() { + } + protected Map env() { Map env = new HashMap<>(); env.put("COLLECTOR_OTLP_ENABLED", "true"); diff --git a/system-x/services/splunk/src/main/java/software/tnb/splunk/resource/local/LocalSplunk.java b/system-x/services/splunk/src/main/java/software/tnb/splunk/resource/local/LocalSplunk.java index 7401dcc02..b55631730 100644 --- a/system-x/services/splunk/src/main/java/software/tnb/splunk/resource/local/LocalSplunk.java +++ b/system-x/services/splunk/src/main/java/software/tnb/splunk/resource/local/LocalSplunk.java @@ -23,7 +23,8 @@ public class LocalSplunk extends Splunk implements Deployable { private final int containerApiPort = 8089; private static final String PASSWORD = "password"; - public LocalSplunk() { + @Override + public void defaultConfiguration() { getConfiguration().protocol(SplunkProtocol.HTTP); } diff --git a/system-x/services/splunk/src/main/java/software/tnb/splunk/resource/openshift/OpenshiftSplunk.java b/system-x/services/splunk/src/main/java/software/tnb/splunk/resource/openshift/OpenshiftSplunk.java index aee6a01bb..d862f3c0c 100644 --- a/system-x/services/splunk/src/main/java/software/tnb/splunk/resource/openshift/OpenshiftSplunk.java +++ b/system-x/services/splunk/src/main/java/software/tnb/splunk/resource/openshift/OpenshiftSplunk.java @@ -52,7 +52,8 @@ public class OpenshiftSplunk extends Splunk implements OpenshiftDeployable { private Route apiRoute; private String sccName; - public OpenshiftSplunk() { + @Override + public void defaultConfiguration() { getConfiguration().protocol(SplunkProtocol.HTTPS); }