-
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.
- Loading branch information
Showing
45 changed files
with
268 additions
and
177 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
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...aging/springwebmvc/SepulkaController.java → ...essaging/springmvc/SepulkaController.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
Empty file.
Empty file.
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
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
13 changes: 13 additions & 0 deletions
13
libs/essentials/src/main/java/smecalculus/bezmen/configuration/ConfigKeeperSpringConfig.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,13 @@ | ||
package smecalculus.bezmen.configuration; | ||
|
||
import org.springframework.boot.context.properties.bind.Binder; | ||
import org.springframework.core.env.Environment; | ||
|
||
public record ConfigKeeperSpringConfig(Environment environment) implements ConfigKeeper { | ||
|
||
@Override | ||
public <T> T read(String key, Class<T> type) { | ||
Binder binder = Binder.get(environment); | ||
return binder.bind(key, type).get(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
libs/essentials/src/main/java/smecalculus/bezmen/configuration/ConfigMappingMode.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,6 @@ | ||
package smecalculus.bezmen.configuration; | ||
|
||
public enum ConfigMappingMode { | ||
LIGHTBEND_CONFIG, | ||
SPRING_CONFIG | ||
} |
2 changes: 1 addition & 1 deletion
2
...ulus/bezmen/configuration/ConfigMode.java → ...men/configuration/ConfigProtocolMode.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package smecalculus.bezmen.configuration; | ||
|
||
public enum ConfigMode { | ||
public enum ConfigProtocolMode { | ||
FILE_SYSTEM | ||
} |
15 changes: 15 additions & 0 deletions
15
...entials/src/main/java/smecalculus/bezmen/construction/ConditionalOnConfigMappingMode.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,15 @@ | ||
package smecalculus.bezmen.construction; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import org.springframework.context.annotation.Conditional; | ||
import smecalculus.bezmen.configuration.ConfigMappingMode; | ||
|
||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Conditional(ConfigMappingModeCondition.class) | ||
public @interface ConditionalOnConfigMappingMode { | ||
ConfigMappingMode value(); | ||
} |
15 changes: 15 additions & 0 deletions
15
...ntials/src/main/java/smecalculus/bezmen/construction/ConditionalOnConfigProtocolMode.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,15 @@ | ||
package smecalculus.bezmen.construction; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import org.springframework.context.annotation.Conditional; | ||
import smecalculus.bezmen.configuration.ConfigProtocolMode; | ||
|
||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Conditional(ConfigProtocolModeCondition.class) | ||
public @interface ConditionalOnConfigProtocolMode { | ||
ConfigProtocolMode value(); | ||
} |
23 changes: 17 additions & 6 deletions
23
libs/essentials/src/main/java/smecalculus/bezmen/construction/ConfigBeans.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 |
---|---|---|
@@ -1,20 +1,31 @@ | ||
package smecalculus.bezmen.construction; | ||
|
||
import static smecalculus.bezmen.configuration.ConfigMappingMode.LIGHTBEND_CONFIG; | ||
import static smecalculus.bezmen.configuration.ConfigMappingMode.SPRING_CONFIG; | ||
import static smecalculus.bezmen.configuration.ConfigProtocolMode.FILE_SYSTEM; | ||
|
||
import com.typesafe.config.ConfigFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.env.Environment; | ||
import smecalculus.bezmen.configuration.ConfigKeeper; | ||
import smecalculus.bezmen.configuration.ConfigKeeperLightbendConfig; | ||
import smecalculus.bezmen.configuration.ConfigMode; | ||
import smecalculus.bezmen.configuration.ConfigKeeperSpringConfig; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
public class ConfigBeans { | ||
|
||
@Bean | ||
ConfigKeeper configKeeper() { | ||
String configMode = System.getProperty("bezmen.config.mode", ConfigMode.FILE_SYSTEM.name()); | ||
return switch (ConfigMode.valueOf(configMode.toUpperCase())) { | ||
case FILE_SYSTEM -> new ConfigKeeperLightbendConfig(ConfigFactory.load()); | ||
}; | ||
@ConditionalOnConfigProtocolMode(FILE_SYSTEM) | ||
@ConditionalOnConfigMappingMode(LIGHTBEND_CONFIG) | ||
ConfigKeeper configKeeperLightbendConfig() { | ||
return new ConfigKeeperLightbendConfig(ConfigFactory.load()); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnConfigProtocolMode(FILE_SYSTEM) | ||
@ConditionalOnConfigMappingMode(SPRING_CONFIG) | ||
ConfigKeeper configKeeperSpringConfig(Environment environment) { | ||
return new ConfigKeeperSpringConfig(environment); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../essentials/src/main/java/smecalculus/bezmen/construction/ConfigMappingModeCondition.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,27 @@ | ||
package smecalculus.bezmen.construction; | ||
|
||
import static org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase.REGISTER_BEAN; | ||
|
||
import java.util.Map; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.context.annotation.ConfigurationCondition; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
import smecalculus.bezmen.configuration.ConfigMappingMode; | ||
|
||
class ConfigMappingModeCondition implements ConfigurationCondition { | ||
|
||
@Override | ||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
Map<String, Object> attributes = | ||
metadata.getAnnotationAttributes(ConditionalOnConfigMappingMode.class.getName()); | ||
ConfigMappingMode expectedMode = (ConfigMappingMode) attributes.get("value"); | ||
String actualMode = context.getEnvironment() | ||
.getProperty("bezmen.config.mapping.mode", ConfigMappingMode.LIGHTBEND_CONFIG.name()); | ||
return expectedMode.name().equalsIgnoreCase(actualMode); | ||
} | ||
|
||
@Override | ||
public ConfigurationPhase getConfigurationPhase() { | ||
return REGISTER_BEAN; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...essentials/src/main/java/smecalculus/bezmen/construction/ConfigProtocolModeCondition.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,27 @@ | ||
package smecalculus.bezmen.construction; | ||
|
||
import static org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase.REGISTER_BEAN; | ||
|
||
import java.util.Map; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.context.annotation.ConfigurationCondition; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
import smecalculus.bezmen.configuration.ConfigProtocolMode; | ||
|
||
class ConfigProtocolModeCondition implements ConfigurationCondition { | ||
|
||
@Override | ||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
Map<String, Object> attributes = | ||
metadata.getAnnotationAttributes(ConditionalOnConfigProtocolMode.class.getName()); | ||
ConfigProtocolMode expectedMode = (ConfigProtocolMode) attributes.get("value"); | ||
String actualMode = context.getEnvironment() | ||
.getProperty("bezmen.config.protocol.mode", ConfigProtocolMode.FILE_SYSTEM.name()); | ||
return expectedMode.name().equalsIgnoreCase(actualMode); | ||
} | ||
|
||
@Override | ||
public ConfigurationPhase getConfigurationPhase() { | ||
return REGISTER_BEAN; | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
libs/messaging/src/main/java/smecalculus/bezmen/configuration/MessageMappingPropsEg.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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
package smecalculus.bezmen.configuration; | ||
|
||
import static java.util.Collections.singleton; | ||
import static smecalculus.bezmen.configuration.MessageMappingMode.SPRING_MVC; | ||
|
||
import java.util.Set; | ||
|
||
public class MessageMappingPropsEg { | ||
public static class Builders { | ||
public static MessageMappingProps.Builder messageMappingProps() { | ||
return MessageMappingProps.builder().mappingModes(singleton(SPRING_MVC)); | ||
return MessageMappingProps.builder().mappingModes(Set.of(SPRING_MVC)); | ||
} | ||
} | ||
} |
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
5 changes: 0 additions & 5 deletions
5
libs/messaging/src/main/java/smecalculus/bezmen/configuration/MessagingConfig.java
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
libs/messaging/src/main/java/smecalculus/bezmen/configuration/MessagingConfigImpl.java
This file was deleted.
Oops, something went wrong.
21 changes: 12 additions & 9 deletions
21
libs/messaging/src/main/java/smecalculus/bezmen/construction/MessagingConfigBeans.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 |
---|---|---|
@@ -1,30 +1,33 @@ | ||
package smecalculus.bezmen.construction; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.PropertySource; | ||
import smecalculus.bezmen.configuration.ConfigKeeper; | ||
import smecalculus.bezmen.configuration.MessagingCfgMapper; | ||
import smecalculus.bezmen.configuration.MessagingCfgMapperImpl; | ||
import smecalculus.bezmen.configuration.MessagingConfig; | ||
import smecalculus.bezmen.configuration.MessagingConfigImpl; | ||
import smecalculus.bezmen.configuration.MessagingProps; | ||
import smecalculus.bezmen.configuration.MessagingPropsCfg; | ||
import smecalculus.bezmen.validation.EdgeValidator; | ||
|
||
@PropertySource("classpath:messaging.properties") | ||
@Configuration(proxyBeanMethods = false) | ||
public class MessagingConfigBeans { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(MessagingConfigBeans.class); | ||
|
||
@Bean | ||
MessagingCfgMapper messagingCfgMapper() { | ||
return new MessagingCfgMapperImpl(); | ||
} | ||
|
||
@Bean | ||
MessagingConfig messagingConfig(ConfigKeeper keeper, EdgeValidator validator, MessagingCfgMapper mapper) { | ||
return new MessagingConfigImpl(keeper, validator, mapper); | ||
} | ||
|
||
@Bean | ||
MessagingProps messagingProps(MessagingConfig config) { | ||
return config.getMessagingProps(); | ||
MessagingProps messagingProps(ConfigKeeper keeper, EdgeValidator validator, MessagingCfgMapper mapper) { | ||
MessagingPropsCfg propsCfg = keeper.read("bezmen.messaging", MessagingPropsCfg.class); | ||
validator.validate(propsCfg); | ||
LOG.info("Read {}", propsCfg); | ||
return mapper.toDomain(propsCfg); | ||
} | ||
} |
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,2 @@ | ||
bezmen.messaging.protocol.modes[0]=http | ||
bezmen.messaging.mapping.modes[0]=spring_mvc |
Oops, something went wrong.