From 5356d0d027f61095d47857891d3d4c9d5f1b88b9 Mon Sep 17 00:00:00 2001 From: Christopher Schnick Date: Fri, 10 Dec 2021 17:13:35 +0100 Subject: [PATCH] Rework exchange classes --- .../exchange/ListCollectionsExchange.java | 5 ++-- .../beacon/exchange/ListEntriesExchange.java | 3 +- .../xpipe/beacon/exchange/ModeExchange.java | 2 +- .../exchange/ReadStructureExchange.java | 2 +- .../exchange/ReadTableDataExchange.java | 4 +-- .../exchange/ReadTableInfoExchange.java | 2 +- .../xpipe/beacon/exchange/StatusExchange.java | 2 +- .../xpipe/beacon/exchange/StopExchange.java | 30 +++++++++++++++++++ .../beacon/exchange/VersionExchange.java | 2 +- 9 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 beacon/src/main/java/io/xpipe/beacon/exchange/StopExchange.java diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/ListCollectionsExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/ListCollectionsExchange.java index f91ab35ca..843e01ee4 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/ListCollectionsExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/ListCollectionsExchange.java @@ -3,9 +3,10 @@ package io.xpipe.beacon.exchange; import io.xpipe.beacon.message.RequestMessage; import io.xpipe.beacon.message.ResponseMessage; +import java.time.Instant; import java.util.List; -public class ListCollectionsExchange implements MessageExchange { +public abstract class ListCollectionsExchange implements MessageExchange { @Override public String getId() { @@ -26,7 +27,7 @@ public class ListCollectionsExchange implements MessageExchange { @@ -26,7 +27,7 @@ public abstract class ListEntriesExchange implements MessageExchange { +public abstract class ModeExchange implements MessageExchange { @Override public String getId() { diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/ReadStructureExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/ReadStructureExchange.java index fad9e29c2..6066e82db 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/ReadStructureExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/ReadStructureExchange.java @@ -4,7 +4,7 @@ import io.xpipe.beacon.message.RequestMessage; import io.xpipe.beacon.message.ResponseMessage; import io.xpipe.core.source.DataSourceId; -public class ReadStructureExchange implements MessageExchange { +public abstract class ReadStructureExchange implements MessageExchange { @Override public String getId() { diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/ReadTableDataExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/ReadTableDataExchange.java index 9cadb7ea1..051a11dd4 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/ReadTableDataExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/ReadTableDataExchange.java @@ -4,7 +4,7 @@ import io.xpipe.beacon.message.RequestMessage; import io.xpipe.beacon.message.ResponseMessage; import io.xpipe.core.source.DataSourceId; -public class ReadTableDataExchange implements MessageExchange { +public abstract class ReadTableDataExchange implements MessageExchange { @Override public String getId() { @@ -21,7 +21,7 @@ public class ReadTableDataExchange implements MessageExchange { +public abstract class ReadTableInfoExchange implements MessageExchange { @Override public String getId() { diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/StatusExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/StatusExchange.java index a8e2a333d..f2c352512 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/StatusExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/StatusExchange.java @@ -3,7 +3,7 @@ package io.xpipe.beacon.exchange; import io.xpipe.beacon.message.RequestMessage; import io.xpipe.beacon.message.ResponseMessage; -public class StatusExchange implements MessageExchange { +public abstract class StatusExchange implements MessageExchange { @Override public String getId() { diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/StopExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/StopExchange.java new file mode 100644 index 000000000..1d16e50cb --- /dev/null +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/StopExchange.java @@ -0,0 +1,30 @@ +package io.xpipe.beacon.exchange; + +import io.xpipe.beacon.message.RequestMessage; +import io.xpipe.beacon.message.ResponseMessage; + +public abstract class StopExchange implements MessageExchange { + + @Override + public String getId() { + return "stop"; + } + + @Override + public Class getRequestClass() { + return StopExchange.Request.class; + } + + @Override + public Class getResponseClass() { + return StopExchange.Response.class; + } + + public static record Request(int timeout, boolean force) implements RequestMessage { + + } + + public static record Response() implements ResponseMessage { + + } +} diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/VersionExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/VersionExchange.java index 6e7bee624..367466b51 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/VersionExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/VersionExchange.java @@ -3,7 +3,7 @@ package io.xpipe.beacon.exchange; import io.xpipe.beacon.message.RequestMessage; import io.xpipe.beacon.message.ResponseMessage; -public class VersionExchange implements MessageExchange { +public abstract class VersionExchange implements MessageExchange { @Override public String getId() {