diff --git a/src/main/java/org/openwms/wms/movements/IndexController.java b/src/main/java/org/openwms/wms/movements/IndexController.java index b0252a12..9e33b850 100644 --- a/src/main/java/org/openwms/wms/movements/IndexController.java +++ b/src/main/java/org/openwms/wms/movements/IndexController.java @@ -16,6 +16,7 @@ package org.openwms.wms.movements; import org.openwms.core.http.Index; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -29,6 +30,7 @@ * @author Heiko Scherrer */ @RestController("movementsIndexController") +@RefreshScope class IndexController { @GetMapping("/index") diff --git a/src/main/java/org/openwms/wms/movements/MovementController.java b/src/main/java/org/openwms/wms/movements/MovementController.java index b69578e4..59ad29d5 100644 --- a/src/main/java/org/openwms/wms/movements/MovementController.java +++ b/src/main/java/org/openwms/wms/movements/MovementController.java @@ -22,6 +22,7 @@ import org.openwms.wms.movements.api.MovementVO; import org.openwms.wms.movements.impl.ValidationGroups; import org.openwms.wms.movements.spi.DefaultMovementState; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; @@ -48,6 +49,7 @@ */ @Validated @MeasuredRestController +@RefreshScope public class MovementController extends AbstractWebController { private final MovementService service; diff --git a/src/main/java/org/openwms/wms/movements/MovementProperties.java b/src/main/java/org/openwms/wms/movements/MovementProperties.java index 973b6537..8bf178f4 100644 --- a/src/main/java/org/openwms/wms/movements/MovementProperties.java +++ b/src/main/java/org/openwms/wms/movements/MovementProperties.java @@ -16,6 +16,7 @@ package org.openwms.wms.movements; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.annotation.Configuration; import java.util.ArrayList; @@ -30,6 +31,7 @@ */ @Configuration @ConfigurationProperties("owms.movement") +@RefreshScope public class MovementProperties { /** Shall the Putaway API be called to resolve a final target for Movements. */ diff --git a/src/main/java/org/openwms/wms/movements/app/MovementAsyncConfiguration.java b/src/main/java/org/openwms/wms/movements/app/MovementAsyncConfiguration.java index bd0870bc..ce6f7c6f 100644 --- a/src/main/java/org/openwms/wms/movements/app/MovementAsyncConfiguration.java +++ b/src/main/java/org/openwms/wms/movements/app/MovementAsyncConfiguration.java @@ -36,6 +36,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; @@ -43,6 +44,8 @@ import org.springframework.retry.backoff.ExponentialBackOffPolicy; import org.springframework.retry.support.RetryTemplate; +import java.util.Objects; + import static org.ameba.LoggingCategories.BOOT; /** @@ -52,6 +55,7 @@ */ @Profile(SpringProfiles.ASYNCHRONOUS_PROFILE) @EnableRabbit +@RefreshScope @Configuration class MovementAsyncConfiguration { @@ -61,7 +65,7 @@ class MovementAsyncConfiguration { @ConditionalOnExpression("'${owms.movements.serialization}'=='json'") @Bean MessageConverter messageConverter() { - Jackson2JsonMessageConverter messageConverter = new Jackson2JsonMessageConverter(); + var messageConverter = new Jackson2JsonMessageConverter(); BOOT_LOGGER.info("Using JSON serialization over AMQP"); return messageConverter; } @@ -69,7 +73,7 @@ MessageConverter messageConverter() { @ConditionalOnExpression("'${owms.movements.serialization}'=='barray'") @Bean MessageConverter serializerMessageConverter() { - SerializerMessageConverter messageConverter = new SerializerMessageConverter(); + var messageConverter = new SerializerMessageConverter(); BOOT_LOGGER.info("Using byte array serialization over AMQP"); return messageConverter; } @@ -79,15 +83,15 @@ MessageConverter serializerMessageConverter() { public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory, ObjectProvider messageConverter, @Autowired(required = false) RabbitTemplateConfigurable rabbitTemplateConfigurable) { - RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); - ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy(); + var rabbitTemplate = new RabbitTemplate(connectionFactory); + var backOffPolicy = new ExponentialBackOffPolicy(); backOffPolicy.setMultiplier(2); backOffPolicy.setMaxInterval(15000); backOffPolicy.setInitialInterval(500); - RetryTemplate retryTemplate = new RetryTemplate(); + var retryTemplate = new RetryTemplate(); retryTemplate.setBackOffPolicy(backOffPolicy); rabbitTemplate.setRetryTemplate(retryTemplate); - rabbitTemplate.setMessageConverter(messageConverter.getIfUnique()); + rabbitTemplate.setMessageConverter(Objects.requireNonNull(messageConverter.getIfUnique())); if (rabbitTemplateConfigurable != null) { rabbitTemplateConfigurable.configure(rabbitTemplate); } diff --git a/src/main/java/org/openwms/wms/movements/app/MovementModuleConfiguration.java b/src/main/java/org/openwms/wms/movements/app/MovementModuleConfiguration.java index 05cb5f41..5daf2592 100644 --- a/src/main/java/org/openwms/wms/movements/app/MovementModuleConfiguration.java +++ b/src/main/java/org/openwms/wms/movements/app/MovementModuleConfiguration.java @@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer; import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -65,6 +66,7 @@ @EnableJpaAuditing @EnableAspects(propagateRootCause = true) @EnableScheduling +@RefreshScope @Import(JSONConfiguration.class) public class MovementModuleConfiguration implements WebMvcConfigurer { @@ -87,13 +89,13 @@ public void addInterceptors(InterceptorRegistry registry) { } public @Bean LocaleResolver localeResolver() { - SessionLocaleResolver slr = new SessionLocaleResolver(); + var slr = new SessionLocaleResolver(); slr.setDefaultLocale(Locale.US); return slr; } public @Bean LocaleChangeInterceptor localeChangeInterceptor() { - LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); + var lci = new LocaleChangeInterceptor(); lci.setParamName("lang"); return lci; } @@ -108,7 +110,7 @@ protected MessageSource getMessageSource() { } @Bean MessageSource messageSource() { - NestedReloadableResourceBundleMessageSource messageSource = new NestedReloadableResourceBundleMessageSource(); + var messageSource = new NestedReloadableResourceBundleMessageSource(); messageSource.setBasenames("classpath:/META-INF/i18n/mvm"); messageSource.setDefaultEncoding("UTF-8"); messageSource.setCommonMessages(new Properties()); diff --git a/src/main/java/org/openwms/wms/movements/commands/MovementCommandListener.java b/src/main/java/org/openwms/wms/movements/commands/MovementCommandListener.java index 2ba0f221..673da210 100644 --- a/src/main/java/org/openwms/wms/movements/commands/MovementCommandListener.java +++ b/src/main/java/org/openwms/wms/movements/commands/MovementCommandListener.java @@ -54,7 +54,7 @@ class MovementCommandListener { @RabbitListener(queues = "${owms.commands.movements.movement.queue-name}") public void onCommand(@Valid @NotNull @Payload MovementCommand command) { if (command.getType() == MovementCommand.Type.CREATE) { - MovementMO movement = command.getMovement(); + var movement = command.getMovement(); LOGGER.debug("Got command to create a Movement [{}]", movement); movementService.create(movement.getTransportUnitBK(), mapper.map(movement, MovementVO.class)); } diff --git a/src/main/java/org/openwms/wms/movements/events/ReservationMessageListener.java b/src/main/java/org/openwms/wms/movements/events/ReservationMessageListener.java index a0a497a2..8e13a9b5 100644 --- a/src/main/java/org/openwms/wms/movements/events/ReservationMessageListener.java +++ b/src/main/java/org/openwms/wms/movements/events/ReservationMessageListener.java @@ -45,7 +45,7 @@ public ReservationMessageListener(MovementService movementService) { @Measured @RabbitListener(queues = "${owms.events.shipping.split.queue-name}") public void handle(@Payload SplitMO mo, @Header("amqp_receivedRoutingKey") String routingKey) { - MovementVO movement = new MovementVO(); + var movement = new MovementVO(); movement.setTransportUnitBk(mo.getTransportUnitBK()); movement.setPriority(mo.getPriority()); movement.setTarget(mo.getTargetName()); diff --git a/src/main/java/org/openwms/wms/movements/impl/MovementEventListener.java b/src/main/java/org/openwms/wms/movements/impl/MovementEventListener.java index 2642f8c8..64a320f3 100644 --- a/src/main/java/org/openwms/wms/movements/impl/MovementEventListener.java +++ b/src/main/java/org/openwms/wms/movements/impl/MovementEventListener.java @@ -18,7 +18,6 @@ import org.ameba.exception.NotFoundException; import org.ameba.i18n.Translator; import org.openwms.common.location.api.LocationApi; -import org.openwms.common.location.api.LocationVO; import org.openwms.common.location.api.messages.LocationMO; import org.openwms.common.transport.api.commands.TUCommand; import org.openwms.common.transport.api.messages.TransportUnitMO; @@ -26,8 +25,6 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.event.TransactionalEventListener; -import java.util.Optional; - import static org.openwms.wms.movements.MovementsMessages.LOCATION_NOT_FOUND_BY_ERP_CODE; /** @@ -50,7 +47,7 @@ class MovementEventListener { @TransactionalEventListener public void onEvent(MovementTargetChangedEvent event) { - Optional locationByErpCode = locationApi.findByErpCode(event.getSource().getTargetLocation()); + var locationByErpCode = locationApi.findByErpCode(event.getSource().getTargetLocation()); if (locationByErpCode.isPresent()) { asyncTransportUnitApi.process( TUCommand.newBuilder(TUCommand.Type.CHANGE_TARGET) diff --git a/src/main/java/org/openwms/wms/movements/impl/MovementServiceImpl.java b/src/main/java/org/openwms/wms/movements/impl/MovementServiceImpl.java index 325c4988..247e58ea 100644 --- a/src/main/java/org/openwms/wms/movements/impl/MovementServiceImpl.java +++ b/src/main/java/org/openwms/wms/movements/impl/MovementServiceImpl.java @@ -40,6 +40,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.ApplicationEventPublisher; import org.springframework.plugin.core.PluginRegistry; import org.springframework.validation.annotation.Validated; @@ -71,6 +72,7 @@ */ @Validated @TxService +@RefreshScope class MovementServiceImpl implements MovementService { private static final Logger LOGGER = LoggerFactory.getLogger(MovementServiceImpl.class); diff --git a/src/main/java/org/openwms/wms/movements/impl/PutawayAdapter.java b/src/main/java/org/openwms/wms/movements/impl/PutawayAdapter.java index 4aebf706..127e7ef6 100644 --- a/src/main/java/org/openwms/wms/movements/impl/PutawayAdapter.java +++ b/src/main/java/org/openwms/wms/movements/impl/PutawayAdapter.java @@ -16,13 +16,13 @@ package org.openwms.wms.movements.impl; import org.ameba.annotation.TxService; -import org.openwms.common.location.api.LocationVO; import org.openwms.wms.movements.Message; import org.openwms.wms.movements.MovementProperties; import org.openwms.wms.movements.spi.common.putaway.PutawayApi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.ApplicationEventPublisher; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -36,6 +36,7 @@ * @author Heiko Scherrer */ @TxService +@RefreshScope class PutawayAdapter { private static final Logger LOGGER = LoggerFactory.getLogger(PutawayAdapter.class); @@ -61,7 +62,7 @@ public void onEvent(MovementEvent event) { try { var movementTarget = properties.findTarget(movement.getTargetLocationGroup()); LOGGER.debug("Call putaway strategy to find target location for movement [{}] in [{}]", movement.getPersistentKey(), movementTarget.getSearchLocationGroupNames()); - LocationVO target = putawayApi.findAndAssignNextInLocGroup( + var target = putawayApi.findAndAssignNextInLocGroup( movement.getInitiator(), movementTarget.getSearchLocationGroupNames(), movement.getTransportUnitBk().getValue(), diff --git a/src/main/java/org/openwms/wms/movements/impl/TransactionWriter.java b/src/main/java/org/openwms/wms/movements/impl/TransactionWriter.java index 47e3b946..c871fe8f 100644 --- a/src/main/java/org/openwms/wms/movements/impl/TransactionWriter.java +++ b/src/main/java/org/openwms/wms/movements/impl/TransactionWriter.java @@ -30,6 +30,7 @@ import org.openwms.transactions.api.commands.TransactionCommand; import org.openwms.wms.movements.spi.common.AsyncTransportUnitApi; import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; import org.springframework.transaction.event.TransactionalEventListener; @@ -47,6 +48,7 @@ */ @Profile(SpringProfiles.ASYNCHRONOUS_PROFILE) @Component +@RefreshScope class TransactionWriter { private final String applicationName; diff --git a/src/main/java/org/openwms/wms/movements/spi/DefaultMovementStateResolver.java b/src/main/java/org/openwms/wms/movements/spi/DefaultMovementStateResolver.java index 783e259c..0ac84bed 100644 --- a/src/main/java/org/openwms/wms/movements/spi/DefaultMovementStateResolver.java +++ b/src/main/java/org/openwms/wms/movements/spi/DefaultMovementStateResolver.java @@ -16,6 +16,7 @@ package org.openwms.wms.movements.spi; import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; @@ -26,6 +27,7 @@ */ @Profile("!CUSTOM") @Component +@RefreshScope class DefaultMovementStateResolver implements MovementStateResolver { private final DefaultMovementState newState; diff --git a/src/main/java/org/openwms/wms/movements/spi/DefaultMovementTypeResolver.java b/src/main/java/org/openwms/wms/movements/spi/DefaultMovementTypeResolver.java index 9648a354..cd1d9b3d 100644 --- a/src/main/java/org/openwms/wms/movements/spi/DefaultMovementTypeResolver.java +++ b/src/main/java/org/openwms/wms/movements/spi/DefaultMovementTypeResolver.java @@ -17,8 +17,8 @@ import org.ameba.annotation.Measured; import org.openwms.wms.movements.MovementProperties; -import org.openwms.wms.movements.MovementTarget; import org.openwms.wms.movements.api.MovementType; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; @@ -34,6 +34,7 @@ @Validated @Profile("!CUSTOM") @Component +@RefreshScope class DefaultMovementTypeResolver implements MovementTypeResolver { private final MovementProperties properties; @@ -48,7 +49,6 @@ class DefaultMovementTypeResolver implements MovementTypeResolver { @Override @Measured public Optional resolve(@NotEmpty String transportUnitBK, @NotEmpty String target) { - MovementTarget movementTarget = properties.findTarget(target); - return Optional.of(movementTarget.getType()); + return Optional.of(properties.findTarget(target).getType()); } }