Skip to content
Snippets Groups Projects
Commit 7a7d58a8 authored by Jan Zickermann's avatar Jan Zickermann
Browse files

OZG-4094 beans: Condition on enabled=true

parent c153c969
No related branches found
No related tags found
2 merge requests!9Draft: Ozg 4094 wiremock ausprobieren,!7Ozg-4094 Konfiguration für nachrichten-manager
Pipeline #1476 passed
...@@ -7,11 +7,12 @@ import org.springframework.stereotype.Service; ...@@ -7,11 +7,12 @@ import org.springframework.stereotype.Service;
import de.ozgcloud.nachrichten.postfach.PostfachNachricht; import de.ozgcloud.nachrichten.postfach.PostfachNachricht;
import de.ozgcloud.nachrichten.postfach.PostfachRemoteService; import de.ozgcloud.nachrichten.postfach.PostfachRemoteService;
import de.ozgcloud.nachrichten.postfach.osiv2.config.Osi2PostfachProperties;
import de.ozgcloud.nachrichten.postfach.osiv2.transfer.PostfachApiFacadeService; import de.ozgcloud.nachrichten.postfach.osiv2.transfer.PostfachApiFacadeService;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
@Service @Service
@ConditionalOnProperty("ozgcloud.osiv2-postfach.enabled") @ConditionalOnProperty(prefix = Osi2PostfachProperties.PREFIX, name = "enabled", havingValue = "true")
@Log4j2 @Log4j2
public record OsiPostfachRemoteService( public record OsiPostfachRemoteService(
PostfachApiFacadeService postfachApiFacadeService PostfachApiFacadeService postfachApiFacadeService
......
...@@ -23,11 +23,11 @@ import reactor.netty.transport.ProxyProvider; ...@@ -23,11 +23,11 @@ import reactor.netty.transport.ProxyProvider;
@Configuration @Configuration
@RequiredArgsConstructor @RequiredArgsConstructor
@ConditionalOnProperty("ozgcloud.osiv2-postfach.enabled") @ConditionalOnProperty(prefix = Osi2PostfachProperties.PREFIX, name = "enabled", havingValue = "true")
public class ApiClientConfiguration { public class ApiClientConfiguration {
private final OsiPostfachProperties.ApiConfiguration apiConfiguration; private final Osi2PostfachProperties.ApiConfiguration apiConfiguration;
private final OsiPostfachProperties.ProxyConfiguration proxyConfiguration; private final Osi2PostfachProperties.ProxyConfiguration proxyConfiguration;
@Bean @Bean
MessageExchangeApi messageExchangeApi(ApiClient apiClient) { MessageExchangeApi messageExchangeApi(ApiClient apiClient) {
......
...@@ -2,6 +2,7 @@ package de.ozgcloud.nachrichten.postfach.osiv2.config; ...@@ -2,6 +2,7 @@ package de.ozgcloud.nachrichten.postfach.osiv2.config;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -11,10 +12,10 @@ import lombok.Setter; ...@@ -11,10 +12,10 @@ import lombok.Setter;
@Getter @Getter
@Setter @Setter
@Configuration @Configuration
@ConfigurationProperties(prefix = OsiPostfachProperties.PREFIX) @ConditionalOnProperty(prefix = Osi2PostfachProperties.PREFIX, name = "enabled", havingValue = "true")
public class OsiPostfachProperties { public class Osi2PostfachProperties {
static final String PREFIX = "ozgcloud.osiv2-postfach"; public static final String PREFIX = "ozgcloud.osiv2-postfach";
private boolean enabled; private boolean enabled;
...@@ -23,7 +24,7 @@ public class OsiPostfachProperties { ...@@ -23,7 +24,7 @@ public class OsiPostfachProperties {
@Configuration @Configuration
@ConfigurationProperties(prefix = ApiConfiguration.PREFIX) @ConfigurationProperties(prefix = ApiConfiguration.PREFIX)
static class ApiConfiguration { static class ApiConfiguration {
static final String PREFIX = OsiPostfachProperties.PREFIX + ".api"; static final String PREFIX = Osi2PostfachProperties.PREFIX + ".api";
private String resource; private String resource;
private String url; private String url;
...@@ -40,7 +41,7 @@ public class OsiPostfachProperties { ...@@ -40,7 +41,7 @@ public class OsiPostfachProperties {
@Configuration @Configuration
@ConfigurationProperties(prefix = ProxyConfiguration.PREFIX) @ConfigurationProperties(prefix = ProxyConfiguration.PREFIX)
static class ProxyConfiguration { static class ProxyConfiguration {
static final String PREFIX = OsiPostfachProperties.PREFIX + ".http-proxy"; static final String PREFIX = Osi2PostfachProperties.PREFIX + ".http-proxy";
private boolean enabled; private boolean enabled;
......
...@@ -7,16 +7,21 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; ...@@ -7,16 +7,21 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import de.ozgcloud.nachrichten.postfach.PostfachNachricht; import de.ozgcloud.nachrichten.postfach.PostfachNachricht;
import de.ozgcloud.nachrichten.postfach.osiv2.config.Osi2PostfachProperties;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.api.MessageExchangeApi; import de.ozgcloud.nachrichten.postfach.osiv2.gen.api.MessageExchangeApi;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.MessageExchangeReceiveMessage; import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.MessageExchangeReceiveMessage;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
@Log4j2 @Log4j2
@Service @Service
@ConditionalOnProperty("ozgcloud.osiv2-postfach.enabled") @ConditionalOnProperty(prefix = Osi2PostfachProperties.PREFIX, name = "enabled", havingValue = "true")
public record PostfachApiFacadeService(MessageExchangeApi messageExchangeApi, RequestMapper requestMapper, ResponseMapper responseMapper) { public record PostfachApiFacadeService(
MessageExchangeApi messageExchangeApi,
RequestMapper requestMapper,
ResponseMapper responseMapper
) {
private static int MAX_NUMBER_RECEIVED_MESSAGES = 100; private static int MAX_NUMBER_RECEIVED_MESSAGES = 100;
public void sendMessage(PostfachNachricht nachricht) { public void sendMessage(PostfachNachricht nachricht) {
messageExchangeApi.sendMessage( messageExchangeApi.sendMessage(
requestMapper.mapMailboxId(nachricht), requestMapper.mapMailboxId(nachricht),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment