diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-07-09 14:11:47 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-07-09 14:11:47 +0200 |
commit | 8aba1b4f18f5fbfebdf239b4b4945b628e439905 (patch) | |
tree | 0004115e44b8d6ddf48542b7413d4f54fa76dc27 /src/main/java/at/gv/egiz/moazs/service | |
parent | 65163646205b6e05139485fe957bceabe531f447 (diff) | |
download | moa-zs-8aba1b4f18f5fbfebdf239b4b4945b628e439905.tar.gz moa-zs-8aba1b4f18f5fbfebdf239b4b4945b628e439905.tar.bz2 moa-zs-8aba1b4f18f5fbfebdf239b4b4945b628e439905.zip |
Refactor Needles Interfaces and Rename "process" to "backend"
Reason:
- Interfaces with a single method can be replaced with
interfaces from java.util.function.
- Less interfaces = less code = less maintenance!
- Spring can inject beans by name so we name dependencies correctly
to prevent ambiguity.
Others:
- Rename process to backend since backend gives a better description
of its components.
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/service')
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/service/MsgService.java | 11 | ||||
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/service/MzsService.java | 10 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/service/MsgService.java b/src/main/java/at/gv/egiz/moazs/service/MsgService.java index 87644a0..9f94cb3 100644 --- a/src/main/java/at/gv/egiz/moazs/service/MsgService.java +++ b/src/main/java/at/gv/egiz/moazs/service/MsgService.java @@ -1,5 +1,4 @@ package at.gv.egiz.moazs.service; -import at.gv.egiz.moazs.process.MsgResponseHandler; import at.gv.egiz.moazs.repository.DeliveryRepository; import at.gv.egiz.moazs.scheme.MsgResponse; import at.gv.egiz.moazs.scheme.NameSpace; @@ -10,6 +9,8 @@ import org.apache.cxf.annotations.SchemaValidation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.function.Consumer; + import static at.gv.zustellung.msg.xsd.DeliveryNotificationACKType.deliveryNotificationACKTypeBuilder; import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusACKType.deliveryRequestStatusACKTypeBuilder; import static at.gv.zustellung.msg.xsd.GetVersionResponse.getVersionResponseBuilder; @@ -20,12 +21,12 @@ import static java.util.concurrent.CompletableFuture.runAsync; public class MsgService implements Zuse2AppPort { private final DeliveryRepository repository; - private final MsgResponseHandler handler; + private final Consumer<String> backend; @Autowired - public MsgService(DeliveryRepository repository, MsgResponseHandler handler) { + public MsgService(DeliveryRepository repository, Consumer<String> msgResponseBackend) { this.repository = repository; - this.handler = handler; + this.backend = msgResponseBackend; } @Override @@ -59,7 +60,7 @@ public class MsgService implements Zuse2AppPort { private void sendToWork(MsgResponse response) { runAsync(() -> repository.store(response)) - .thenRunAsync(() -> handler.handle(response.getResponseID())); + .thenRunAsync(() -> backend.accept(response.getResponseID())); } private DeliveryNotificationACKType notificationAck(String appDeliveryID, String zsDeliveryID) { diff --git a/src/main/java/at/gv/egiz/moazs/service/MzsService.java b/src/main/java/at/gv/egiz/moazs/service/MzsService.java index 2755a37..c8c0878 100644 --- a/src/main/java/at/gv/egiz/moazs/service/MzsService.java +++ b/src/main/java/at/gv/egiz/moazs/service/MzsService.java @@ -1,7 +1,6 @@ package at.gv.egiz.moazs.service; import at.gv.egiz.moazs.preprocess.DeliveryRequestAugmenter; -import at.gv.egiz.moazs.process.DeliveryPipeline; import at.gv.egiz.moazs.repository.DeliveryRepository; import at.gv.egiz.moazs.scheme.Msg2MzsConverter; import at.gv.egiz.moazs.client.MzsClient; @@ -19,6 +18,7 @@ import org.springframework.stereotype.Service; import javax.jws.WebParam; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.function.Consumer; import static at.gv.egiz.moazs.MoaZSException.moaZSException; import static at.gv.egiz.moazs.MoaZSException.moaZSExceptionBuilder; @@ -36,16 +36,16 @@ public class MzsService implements App2MzsPortType { private static final int TIMEOUT_FOR_ANWSER = 10; private final DeliveryRepository repository; - private final DeliveryPipeline pipeline; + private final Consumer<String> backend; private final MzsClient appClient; private final DeliveryRequestAugmenter augmenter; private final Msg2MzsConverter converter; @Autowired - public MzsService(DeliveryRepository repository, DeliveryPipeline pipeline, MzsClient appClient, + public MzsService(DeliveryRepository repository, Consumer<String> deliveryRequestBackend, MzsClient appClient, DeliveryRequestAugmenter augmenter, Msg2MzsConverter converter) { this.repository = repository; - this.pipeline = pipeline; + this.backend = deliveryRequestBackend; this.appClient = appClient; this.augmenter = augmenter; this.converter = converter; @@ -87,7 +87,7 @@ public class MzsService implements App2MzsPortType { logger.info("Receive request with appDeliveryID = {}.", appDeliveryID); repository.store(deliveryRequest); - pipeline.processRequest(appDeliveryID); + backend.accept(appDeliveryID); var statusId = RequestStatusResponse.getResponseID(appDeliveryID); var response = repository.retrieveResponse(statusId) |