From 3cc527dfa3d67fd8aa50e3c8d36dfde53948af0c Mon Sep 17 00:00:00 2001 From: Christopher Schnick Date: Sat, 18 Jun 2022 00:29:41 +0200 Subject: [PATCH] Large refactor --- README.md | 13 +++ api/README.md | 15 +++ .../main/java/io/xpipe/api/DataSource.java | 2 +- .../java/io/xpipe/api/DataSourceConfig.java | 32 ++++++ .../java/io/xpipe/api/impl/DataRawImpl.java | 3 +- .../io/xpipe/api/impl/DataSourceImpl.java | 33 +++--- .../io/xpipe/api/impl/DataStructureImpl.java | 3 +- .../api/impl/DataTableAccumulatorImpl.java | 5 +- .../java/io/xpipe/api/impl/DataTableImpl.java | 3 +- .../java/io/xpipe/api/impl/DataTextImpl.java | 3 +- beacon/README.md | 7 +- .../java/io/xpipe/beacon/BeaconClient.java | 44 -------- .../io/xpipe/beacon/BeaconConnection.java | 3 - .../java/io/xpipe/beacon/BeaconServer.java | 2 +- .../beacon/{message => }/RequestMessage.java | 2 +- .../java/io/xpipe/beacon/ResponseMessage.java | 5 + .../java/io/xpipe/beacon/ServerException.java | 3 - .../xpipe/beacon/exchange/EditExchange.java | 4 +- .../beacon/exchange/MessageExchanges.java | 21 ++-- .../exchange/QueryDataSourceExchange.java | 4 +- .../beacon/exchange/ReadExecuteExchange.java | 7 +- .../exchange/ReadPreparationExchange.java | 4 +- .../xpipe/beacon/exchange/StopExchange.java | 4 +- .../beacon/exchange/StoreStreamExchange.java | 4 +- .../exchange/api/QueryRawDataExchange.java | 4 +- .../exchange/api/QueryTableDataExchange.java | 4 +- .../exchange/api/QueryTextDataExchange.java | 4 +- .../beacon/exchange/cli/ConvertExchange.java | 4 +- .../beacon/exchange/cli/DialogExchange.java | 4 +- .../exchange/cli/ListCollectionsExchange.java | 4 +- .../exchange/cli/ListEntriesExchange.java | 4 +- .../exchange/cli/ListStoresExchange.java | 4 +- .../beacon/exchange/cli/ModeExchange.java | 4 +- .../exchange/cli/ProviderListExchange.java | 4 +- .../cli/RemoveCollectionExchange.java | 4 +- .../exchange/cli/RemoveEntryExchange.java | 4 +- .../exchange/cli/RemoveStoreExchange.java | 4 +- .../cli/RenameCollectionExchange.java | 4 +- .../exchange/cli/RenameEntryExchange.java | 4 +- .../exchange/cli/RenameStoreExchange.java | 4 +- .../beacon/exchange/cli/SelectExchange.java | 4 +- .../beacon/exchange/cli/StatusExchange.java | 4 +- .../beacon/exchange/cli/StoreAddExchange.java | 4 +- .../beacon/exchange/cli/VersionExchange.java | 4 +- .../exchange/cli/WriteExecuteExchange.java | 8 +- .../cli/WritePreparationExchange.java | 4 +- .../exchange/data/ClientErrorMessage.java | 1 + .../exchange/data/ServerErrorMessage.java | 1 + .../xpipe/beacon/message/ResponseMessage.java | 10 -- beacon/src/main/java/module-info.java | 2 - charsetter/build.gradle | 16 --- charsetter/src/main/java/module-info.java | 8 -- core/README.md | 17 +-- core/build.gradle | 1 + .../xpipe/core}/charsetter/Charsettable.java | 2 +- .../io/xpipe/core}/charsetter/Charsetter.java | 62 +++++------ .../core}/charsetter/CharsetterContext.java | 2 +- .../core}/charsetter/CharsetterUniverse.java | 2 +- .../io/xpipe/core}/charsetter/NewLine.java | 2 +- .../data/generic/GenericDataStreamParser.java | 8 +- .../data/generic/GenericDataStreamWriter.java | 13 ++- .../core/data/node/DataStructureNodeIO.java | 4 + .../core/data/node/MutableValueNode.java | 9 ++ .../data/typed/TypedDataStreamParser.java | 8 +- .../data/typed/TypedDataStreamWriter.java | 7 +- .../io/xpipe/core/dialog/ConfigParameter.java | 26 ----- .../dialog/ConfigParameterSetInstance.java | 54 ---------- .../core/source/DataSourceConfigInstance.java | 47 -------- core/src/main/java/module-info.java | 2 +- extension/README.md | 14 ++- extension/build.gradle | 1 - .../xpipe/extension/DataSourceProvider.java | 2 +- .../io/xpipe/extension/ExtensionTest.java | 4 +- .../extension/comp/DynamicOptionsBuilder.java | 2 +- extension/src/main/java/module-info.java | 1 - jreleaser.gradle | 100 ++++++++++++++++++ 76 files changed, 359 insertions(+), 387 deletions(-) create mode 100644 api/src/main/java/io/xpipe/api/DataSourceConfig.java rename beacon/src/main/java/io/xpipe/beacon/{message => }/RequestMessage.java (53%) create mode 100644 beacon/src/main/java/io/xpipe/beacon/ResponseMessage.java delete mode 100644 beacon/src/main/java/io/xpipe/beacon/message/ResponseMessage.java delete mode 100644 charsetter/build.gradle delete mode 100644 charsetter/src/main/java/module-info.java rename {charsetter/src/main/java/io/xpipe => core/src/main/java/io/xpipe/core}/charsetter/Charsettable.java (73%) rename {charsetter/src/main/java/io/xpipe => core/src/main/java/io/xpipe/core}/charsetter/Charsetter.java (61%) rename {charsetter/src/main/java/io/xpipe => core/src/main/java/io/xpipe/core}/charsetter/CharsetterContext.java (93%) rename {charsetter/src/main/java/io/xpipe => core/src/main/java/io/xpipe/core}/charsetter/CharsetterUniverse.java (95%) rename {charsetter/src/main/java/io/xpipe => core/src/main/java/io/xpipe/core}/charsetter/NewLine.java (96%) delete mode 100644 core/src/main/java/io/xpipe/core/dialog/ConfigParameter.java delete mode 100644 core/src/main/java/io/xpipe/core/dialog/ConfigParameterSetInstance.java delete mode 100644 core/src/main/java/io/xpipe/core/source/DataSourceConfigInstance.java create mode 100644 jreleaser.gradle diff --git a/README.md b/README.md index 3789f434b..0c61ae14f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ ## X-Pipe Java +The fundamental components of the [X-Pipe project](). This repository contains the following four modules: - Core - Shared core classes of the Java API and the X-Pipe daemon implementation @@ -8,6 +9,18 @@ This repository contains the following four modules: and the client applications, for example the various programming language APIs and the CLI - Extension - An API to create all different kinds of extensions for the X-Pipe platform +## Installation / Usage + +The *core* and *extension* libraries are used in X-Pipe extension development. +For setup instructions, see the [X-Pipe extension development]() section. + +The *beacon* library handles all communication and serves as a +reference when implementing an API or program that communicates with the X-Pipe daemon. + +The *api* library serves as a reference implementation for other potential X-Pipe APIs +and is also used to enable your Java program to communicate with X-Pipe. +For setup instructions, see the [X-Pipe Java API Usage]() section. + ## Development All X-Pipe components target [JDK 17](https://openjdk.java.net/projects/jdk/17/) and make full use of the Java Module System (JPMS). diff --git a/api/README.md b/api/README.md index 023ebb029..4a48d4475 100644 --- a/api/README.md +++ b/api/README.md @@ -1,3 +1,18 @@ [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.xpipe/api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.xpipe/api) [![javadoc](https://javadoc.io/badge2/io.xpipe/api/javadoc.svg)](https://javadoc.io/doc/io.xpipe/api) [![Build Status](https://github.com/xpipe-io/xpipe_java/actions/workflows/api-build.yml/badge.svg)](https://github.com/xpipe-io/xpipe_java/actions/workflows/api-build.yml) + +## X-Pipe Java API + +The X-Pipe API for Java allows you to use most of the X-Pipe functionality from Java applications: + +- Create data stores and data sources +- Query and work with the contents of data sources +- Write and append to data sources + +## Setup + +Either install the [dependency](https://maven-badges.herokuapp.com/maven-central/io.xpipe/api) from Maven Central +using your favourite build tool or alternatively download the `xpipe-api.jar`, `xpipe-core.jar`, and `xpipe-beacon.jar` +from the [releases page](https://github.com/xpipe-io/xpipe_java/releases/latest) and add them to the classpath. + diff --git a/api/src/main/java/io/xpipe/api/DataSource.java b/api/src/main/java/io/xpipe/api/DataSource.java index b7343ba5a..393d17efb 100644 --- a/api/src/main/java/io/xpipe/api/DataSource.java +++ b/api/src/main/java/io/xpipe/api/DataSource.java @@ -152,7 +152,7 @@ public interface DataSource { DataSourceType getType(); - DataSourceConfigInstance getConfig(); + DataSourceConfig getConfig(); /** * Attempts to cast this object to a {@link DataTable}. diff --git a/api/src/main/java/io/xpipe/api/DataSourceConfig.java b/api/src/main/java/io/xpipe/api/DataSourceConfig.java new file mode 100644 index 000000000..f259d7232 --- /dev/null +++ b/api/src/main/java/io/xpipe/api/DataSourceConfig.java @@ -0,0 +1,32 @@ +package io.xpipe.api; + +import java.util.Map; + +/** + * Represents the current configuration of a data source. + */ +public final class DataSourceConfig { + + /** + * The data source provider id. + */ + private final String provider; + + /** + * The set configuration parameters. + */ + private final Map configInstance; + + public DataSourceConfig(String provider, Map configInstance) { + this.provider = provider; + this.configInstance = configInstance; + } + + public String getProvider() { + return provider; + } + + public Map getConfigInstance() { + return configInstance; + } +} diff --git a/api/src/main/java/io/xpipe/api/impl/DataRawImpl.java b/api/src/main/java/io/xpipe/api/impl/DataRawImpl.java index b23d59455..b740f6d0d 100644 --- a/api/src/main/java/io/xpipe/api/impl/DataRawImpl.java +++ b/api/src/main/java/io/xpipe/api/impl/DataRawImpl.java @@ -1,6 +1,7 @@ package io.xpipe.api.impl; import io.xpipe.api.DataRaw; +import io.xpipe.api.DataSourceConfig; import io.xpipe.core.source.*; import java.io.InputStream; @@ -9,7 +10,7 @@ public class DataRawImpl extends DataSourceImpl implements DataRaw { private final DataSourceInfo.Raw info; - public DataRawImpl(DataSourceId sourceId, DataSourceConfigInstance sourceConfig, DataSourceInfo.Raw info) { + public DataRawImpl(DataSourceId sourceId, DataSourceConfig sourceConfig, DataSourceInfo.Raw info) { super(sourceId, sourceConfig); this.info = info; } diff --git a/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java b/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java index 6355738ea..868bb2606 100644 --- a/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java +++ b/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java @@ -1,12 +1,11 @@ package io.xpipe.api.impl; import io.xpipe.api.DataSource; +import io.xpipe.api.DataSourceConfig; import io.xpipe.api.connector.XPipeConnection; -import io.xpipe.beacon.exchange.StoreStreamExchange; import io.xpipe.beacon.exchange.QueryDataSourceExchange; -import io.xpipe.beacon.exchange.ReadExecuteExchange; import io.xpipe.beacon.exchange.ReadPreparationExchange; -import io.xpipe.core.source.DataSourceConfigInstance; +import io.xpipe.beacon.exchange.StoreStreamExchange; import io.xpipe.core.source.DataSourceId; import io.xpipe.core.source.DataSourceReference; @@ -19,22 +18,23 @@ public abstract class DataSourceImpl implements DataSource { return XPipeConnection.execute(con -> { var req = QueryDataSourceExchange.Request.builder().ref(ds).build(); QueryDataSourceExchange.Response res = con.performSimpleExchange(req); + var config = new DataSourceConfig(res.getProvider(), res.getConfig()); switch (res.getInfo().getType()) { case TABLE -> { var data = res.getInfo().asTable(); - return new DataTableImpl(res.getId(), res.getConfig(), data); + return new DataTableImpl(res.getId(), config, data); } case STRUCTURE -> { var info = res.getInfo().asStructure(); - return new DataStructureImpl(res.getId(), res.getConfig(), info); + return new DataStructureImpl(res.getId(), config, info); } case TEXT -> { var info = res.getInfo().asText(); - return new DataTextImpl(res.getId(), res.getConfig(), info); + return new DataTextImpl(res.getId(), config, info); } case RAW -> { var info = res.getInfo().asRaw(); - return new DataRawImpl(res.getId(), res.getConfig(), info); + return new DataRawImpl(res.getId(), config, info); } } throw new AssertionError(); @@ -60,20 +60,21 @@ public abstract class DataSourceImpl implements DataSource { }); var configInstance = startRes.getConfig(); - configInstance.getConfigInstance().getCurrentValues().putAll(config); - var endReq = ReadExecuteExchange.Request.builder() - .target(id).dataStore(store).config(configInstance).build(); - XPipeConnection.execute(con -> { - con.performSimpleExchange(endReq); - }); + //TODO +// configInstance.getConfigInstance().getCurrentValues().putAll(config); +// var endReq = ReadExecuteExchange.Request.builder() +// .target(id).dataStore(store).config(configInstance).build(); +// XPipeConnection.execute(con -> { +// con.performSimpleExchange(endReq); +// }); var ref = id != null ? DataSourceReference.id(id) : DataSourceReference.latest(); return get(ref); } private final DataSourceId sourceId; - private final DataSourceConfigInstance config; + private final DataSourceConfig config; - public DataSourceImpl(DataSourceId sourceId, DataSourceConfigInstance config) { + public DataSourceImpl(DataSourceId sourceId, DataSourceConfig config) { this.sourceId = sourceId; this.config = config; } @@ -84,7 +85,7 @@ public abstract class DataSourceImpl implements DataSource { } @Override - public DataSourceConfigInstance getConfig() { + public DataSourceConfig getConfig() { return config; } } diff --git a/api/src/main/java/io/xpipe/api/impl/DataStructureImpl.java b/api/src/main/java/io/xpipe/api/impl/DataStructureImpl.java index f3441e59c..cfe9a8ca3 100644 --- a/api/src/main/java/io/xpipe/api/impl/DataStructureImpl.java +++ b/api/src/main/java/io/xpipe/api/impl/DataStructureImpl.java @@ -1,5 +1,6 @@ package io.xpipe.api.impl; +import io.xpipe.api.DataSourceConfig; import io.xpipe.api.DataStructure; import io.xpipe.core.data.node.DataStructureNode; import io.xpipe.core.source.*; @@ -8,7 +9,7 @@ public class DataStructureImpl extends DataSourceImpl implements DataStructure { private final DataSourceInfo.Structure info; - public DataStructureImpl(DataSourceId sourceId, DataSourceConfigInstance sourceConfig, DataSourceInfo.Structure info) { + public DataStructureImpl(DataSourceId sourceId, DataSourceConfig sourceConfig, DataSourceInfo.Structure info) { super(sourceId, sourceConfig); this.info = info; } diff --git a/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java b/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java index d9414cbeb..d1c9e32d4 100644 --- a/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java +++ b/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java @@ -5,14 +5,13 @@ import io.xpipe.api.DataTable; import io.xpipe.api.DataTableAccumulator; import io.xpipe.api.connector.XPipeConnection; import io.xpipe.api.util.TypeDescriptor; -import io.xpipe.beacon.exchange.StoreStreamExchange; import io.xpipe.beacon.exchange.ReadExecuteExchange; +import io.xpipe.beacon.exchange.StoreStreamExchange; import io.xpipe.core.data.node.DataStructureNode; import io.xpipe.core.data.node.DataStructureNodeAcceptor; import io.xpipe.core.data.node.TupleNode; import io.xpipe.core.data.type.TupleType; import io.xpipe.core.data.typed.TypedDataStreamWriter; -import io.xpipe.core.source.DataSourceConfigInstance; import io.xpipe.core.source.DataSourceId; import io.xpipe.core.source.DataSourceReference; @@ -40,7 +39,7 @@ public class DataTableAccumulatorImpl implements DataTableAccumulator { connection.close(); var req = ReadExecuteExchange.Request.builder() - .target(id).dataStore(res.getStore()).config(DataSourceConfigInstance.xpbt()).build(); + .target(id).dataStore(res.getStore()).build(); XPipeConnection.execute(con -> { con.performSimpleExchange(req); }); diff --git a/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java b/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java index 307bdc462..7194b0a75 100644 --- a/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java +++ b/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java @@ -1,5 +1,6 @@ package io.xpipe.api.impl; +import io.xpipe.api.DataSourceConfig; import io.xpipe.api.DataTable; import io.xpipe.api.connector.XPipeConnection; import io.xpipe.beacon.BeaconConnection; @@ -24,7 +25,7 @@ public class DataTableImpl extends DataSourceImpl implements DataTable { private final DataSourceInfo.Table info; - DataTableImpl(DataSourceId id, DataSourceConfigInstance sourceConfig, DataSourceInfo.Table info) { + DataTableImpl(DataSourceId id, DataSourceConfig sourceConfig, DataSourceInfo.Table info) { super(id, sourceConfig); this.info = info; } diff --git a/api/src/main/java/io/xpipe/api/impl/DataTextImpl.java b/api/src/main/java/io/xpipe/api/impl/DataTextImpl.java index ad397b3a4..217241cb4 100644 --- a/api/src/main/java/io/xpipe/api/impl/DataTextImpl.java +++ b/api/src/main/java/io/xpipe/api/impl/DataTextImpl.java @@ -1,5 +1,6 @@ package io.xpipe.api.impl; +import io.xpipe.api.DataSourceConfig; import io.xpipe.api.DataText; import io.xpipe.core.source.*; @@ -10,7 +11,7 @@ public class DataTextImpl extends DataSourceImpl implements DataText { private final DataSourceInfo.Text info; - public DataTextImpl(DataSourceId sourceId, DataSourceConfigInstance sourceConfig, DataSourceInfo.Text info) { + public DataTextImpl(DataSourceId sourceId, DataSourceConfig sourceConfig, DataSourceInfo.Text info) { super(sourceId, sourceConfig); this.info = info; } diff --git a/beacon/README.md b/beacon/README.md index 5ec54b13d..3b53b67ba 100644 --- a/beacon/README.md +++ b/beacon/README.md @@ -7,10 +7,10 @@ The X-Pipe beacon component is responsible for handling all communications between the X-Pipe daemon and the various programming language APIs and the CLI. It provides an API that supports all kinds of different operations. -The underlying inter-process communication is realized through TCP sockets on port `21721`. +The underlying inter-process communication is realized through TCP sockets on default port `21721`. The data structures and exchange protocols are specified in the `io.xpipe.beacon.exchange` package. -Every exchange is initiated from the outside by sending a request message to the daemon. +Every exchange is initiated from the outside by sending a request message to the X-Pipe daemon. The daemon then always sends a response message. The header information of a message is formatted in the json format. @@ -23,7 +23,7 @@ Each segment is preceded by four bytes that specify the length of the next segme In case the next segment has a length of less than `65536` bytes, we know that the end of the body has been reached. This way the socket communication can handle payloads of unknown length. -### Configuration +## Configuration The default port used by the beacon implementation of the X-Pipe daemon and APIs is `21721`. It can be changed by passing the property `io.xpipe.beacon.port=` to both the daemon and APIs. @@ -32,6 +32,7 @@ The beacon API also supports launching the daemon automatically in case it is no By default, it launches the daemon of the local X-Pipe installation. It is possible to pass a custom launch command with the property `io.xpipe.beacon.exec=`. This allows for a custom launch behaviour in a testing/development environment. +Note that the `` value has to be a single property string, which can be prone to formatting errors By passing the property `io.xpipe.beacon.debugOutput=true`, it is possible to print debug information about the underlying communications. diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java b/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java index 6ca4ef478..b8f3d60df 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java @@ -8,8 +8,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import io.xpipe.beacon.exchange.MessageExchanges; import io.xpipe.beacon.exchange.data.ClientErrorMessage; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; import io.xpipe.beacon.exchange.data.ServerErrorMessage; import io.xpipe.core.util.JacksonHelper; @@ -32,12 +30,6 @@ public class BeaconClient implements AutoCloseable { void accept(T var1, U var2) throws E; } - @FunctionalInterface - public interface FailableBiPredicate { - - boolean test(T var1, U var2) throws E; - } - @FunctionalInterface public interface FailableConsumer { @@ -76,30 +68,6 @@ public class BeaconClient implements AutoCloseable { } } - public void exchange( - REQ req, - FailableConsumer reqWriter, - FailableBiConsumer resReader) - throws ConnectorException, ClientException, ServerException { - try { - sendRequest(req); - if (reqWriter != null) { - out.write(BODY_SEPARATOR); - reqWriter.accept(out); - } - - var res = this.receiveResponse(); - var sep = in.readNBytes(BODY_SEPARATOR.length); - if (sep.length != 0 && !Arrays.equals(BODY_SEPARATOR, sep)) { - throw new ConnectorException("Invalid body separator"); - } - - resReader.accept(res, in); - } catch (IOException ex) { - throw new ConnectorException("Couldn't communicate with socket", ex); - } - } - public InputStream receiveBody() throws ConnectorException { try { var sep = in.readNBytes(BODY_SEPARATOR.length); @@ -238,16 +206,4 @@ public class BeaconClient implements AutoCloseable { throw new ConnectorException("Couldn't parse response", ex); } } - - public InputStream getInputStream() { - return in; - } - - public OutputStream getOutputStream() { - return out; - } - - public Socket getSocket() { - return socket; - } } diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconConnection.java b/beacon/src/main/java/io/xpipe/beacon/BeaconConnection.java index ca0d2e971..6adc47e0e 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconConnection.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconConnection.java @@ -1,8 +1,5 @@ package io.xpipe.beacon; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java b/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java index 0b9d5324c..717416bc3 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java @@ -13,7 +13,7 @@ import java.nio.file.Path; import java.util.Optional; /** - * Contains basic functionality to start, communicate, and stop a beacon server. + * Contains basic functionality to start, communicate, and stop a remote beacon server. */ @UtilityClass public class BeaconServer { diff --git a/beacon/src/main/java/io/xpipe/beacon/message/RequestMessage.java b/beacon/src/main/java/io/xpipe/beacon/RequestMessage.java similarity index 53% rename from beacon/src/main/java/io/xpipe/beacon/message/RequestMessage.java rename to beacon/src/main/java/io/xpipe/beacon/RequestMessage.java index 945ec169e..c6fd015a3 100644 --- a/beacon/src/main/java/io/xpipe/beacon/message/RequestMessage.java +++ b/beacon/src/main/java/io/xpipe/beacon/RequestMessage.java @@ -1,4 +1,4 @@ -package io.xpipe.beacon.message; +package io.xpipe.beacon; public interface RequestMessage { diff --git a/beacon/src/main/java/io/xpipe/beacon/ResponseMessage.java b/beacon/src/main/java/io/xpipe/beacon/ResponseMessage.java new file mode 100644 index 000000000..33b82e751 --- /dev/null +++ b/beacon/src/main/java/io/xpipe/beacon/ResponseMessage.java @@ -0,0 +1,5 @@ +package io.xpipe.beacon; + +public interface ResponseMessage { + +} diff --git a/beacon/src/main/java/io/xpipe/beacon/ServerException.java b/beacon/src/main/java/io/xpipe/beacon/ServerException.java index 080b32844..470f41205 100644 --- a/beacon/src/main/java/io/xpipe/beacon/ServerException.java +++ b/beacon/src/main/java/io/xpipe/beacon/ServerException.java @@ -1,11 +1,8 @@ package io.xpipe.beacon; -import lombok.experimental.StandardException; - /** * Indicates that an internal server error occurred. */ -@StandardException public class ServerException extends Exception { public ServerException() { diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/EditExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/EditExchange.java index e11fcd226..57e909c71 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/EditExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/EditExchange.java @@ -1,7 +1,7 @@ package io.xpipe.beacon.exchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.dialog.DialogReference; import io.xpipe.core.source.DataSourceId; import io.xpipe.core.source.DataSourceReference; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/MessageExchanges.java b/beacon/src/main/java/io/xpipe/beacon/exchange/MessageExchanges.java index 8efb17bff..c6e1be5b4 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/MessageExchanges.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/MessageExchanges.java @@ -1,7 +1,7 @@ package io.xpipe.beacon.exchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import java.util.Optional; import java.util.ServiceLoader; @@ -15,26 +15,23 @@ public class MessageExchanges { private static void loadAll() { if (ALL == null) { ALL = ServiceLoader.load(MessageExchange.class).stream() - .map(s -> (MessageExchange) s.get()).collect(Collectors.toSet()); + .map(ServiceLoader.Provider::get).collect(Collectors.toSet()); } } - public static Optional byId(String name) { + public static Optional byId(String name) { loadAll(); - var r = ALL.stream().filter(d -> d.getId().equals(name)).findAny(); - return Optional.ofNullable((MessageExchange) r.orElse(null)); + return ALL.stream().filter(d -> d.getId().equals(name)).findAny(); } - public static Optional byRequest(RQ req) { + public static Optional byRequest(RQ req) { loadAll(); - var r = ALL.stream().filter(d -> d.getRequestClass().equals(req.getClass())).findAny(); - return r; + return ALL.stream().filter(d -> d.getRequestClass().equals(req.getClass())).findAny(); } - public static Optional byResponse(RP rep) { + public static Optional byResponse(RP rep) { loadAll(); - var r = ALL.stream().filter(d -> d.getResponseClass().equals(rep.getClass())).findAny(); - return r; + return ALL.stream().filter(d -> d.getResponseClass().equals(rep.getClass())).findAny(); } public static Set getAll() { diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/QueryDataSourceExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/QueryDataSourceExchange.java index 991ec94a4..b7498bb4e 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/QueryDataSourceExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/QueryDataSourceExchange.java @@ -1,7 +1,7 @@ package io.xpipe.beacon.exchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.source.DataSourceId; import io.xpipe.core.source.DataSourceInfo; import io.xpipe.core.source.DataSourceReference; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/ReadExecuteExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/ReadExecuteExchange.java index 3215b551f..e0f8ffef9 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/ReadExecuteExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/ReadExecuteExchange.java @@ -1,8 +1,7 @@ package io.xpipe.beacon.exchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; -import io.xpipe.core.source.DataSourceConfigInstance; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.source.DataSourceId; import io.xpipe.core.store.DataStore; import lombok.Builder; @@ -26,8 +25,6 @@ public class ReadExecuteExchange implements MessageExchange { public static class Request implements RequestMessage { @NonNull DataStore dataStore; - @NonNull - DataSourceConfigInstance config; DataSourceId target; } diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/ReadPreparationExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/ReadPreparationExchange.java index 270caa582..a54153a5c 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/ReadPreparationExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/ReadPreparationExchange.java @@ -1,7 +1,7 @@ package io.xpipe.beacon.exchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.dialog.DialogReference; import io.xpipe.core.store.DataStore; import lombok.Builder; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/StopExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/StopExchange.java index d6945b69d..116b27bef 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/StopExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/StopExchange.java @@ -1,7 +1,7 @@ package io.xpipe.beacon.exchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.Value; import lombok.extern.jackson.Jacksonized; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/StoreStreamExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/StoreStreamExchange.java index bc2cabe13..471a5989b 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/StoreStreamExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/StoreStreamExchange.java @@ -1,7 +1,7 @@ package io.xpipe.beacon.exchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.store.FileStore; import lombok.Builder; import lombok.Value; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryRawDataExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryRawDataExchange.java index 6e95ec48f..726fa4151 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryRawDataExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryRawDataExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.api; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.source.DataSourceReference; import lombok.Builder; import lombok.NonNull; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryTableDataExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryTableDataExchange.java index af4910cfb..8408f9d88 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryTableDataExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryTableDataExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.api; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.source.DataSourceReference; import lombok.Builder; import lombok.NonNull; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryTextDataExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryTextDataExchange.java index 997b1f7e7..a47036300 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryTextDataExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryTextDataExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.api; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.source.DataSourceReference; import lombok.Builder; import lombok.NonNull; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ConvertExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ConvertExchange.java index c59a97b6a..d30087fd0 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ConvertExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ConvertExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.dialog.DialogReference; import io.xpipe.core.source.DataSourceId; import io.xpipe.core.source.DataSourceReference; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/DialogExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/DialogExchange.java index 9557790ac..a25507b48 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/DialogExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/DialogExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.dialog.DialogElement; import lombok.Builder; import lombok.Value; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListCollectionsExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListCollectionsExchange.java index 7ebae2303..1cc11f292 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListCollectionsExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListCollectionsExchange.java @@ -2,8 +2,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; import io.xpipe.beacon.exchange.data.CollectionListEntry; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.Value; import lombok.extern.jackson.Jacksonized; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListEntriesExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListEntriesExchange.java index 1a74b3f37..2a649b5ca 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListEntriesExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListEntriesExchange.java @@ -2,8 +2,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; import io.xpipe.beacon.exchange.data.EntryListEntry; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.Value; import lombok.extern.jackson.Jacksonized; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListStoresExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListStoresExchange.java index ffa807605..06934c104 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListStoresExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ListStoresExchange.java @@ -2,8 +2,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; import io.xpipe.beacon.exchange.data.StoreListEntry; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.Value; import lombok.extern.jackson.Jacksonized; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ModeExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ModeExchange.java index 1d3fd204c..650df0c84 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ModeExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ModeExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.NonNull; import lombok.Value; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ProviderListExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ProviderListExchange.java index 4bd333119..5f60af397 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ProviderListExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/ProviderListExchange.java @@ -2,8 +2,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; import io.xpipe.beacon.exchange.data.ProviderEntry; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.source.DataSourceType; import lombok.Builder; import lombok.NonNull; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveCollectionExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveCollectionExchange.java index 3f4983c42..9cf3c2a17 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveCollectionExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveCollectionExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.NonNull; import lombok.Value; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveEntryExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveEntryExchange.java index f6f655a9d..ce2ce4a43 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveEntryExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveEntryExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.source.DataSourceId; import io.xpipe.core.source.DataSourceReference; import lombok.Builder; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveStoreExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveStoreExchange.java index b5aa793db..c4aad66d4 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveStoreExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RemoveStoreExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.NonNull; import lombok.Value; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameCollectionExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameCollectionExchange.java index 73e78ec00..f233d3463 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameCollectionExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameCollectionExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.NonNull; import lombok.Value; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameEntryExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameEntryExchange.java index 3715ab872..d39d2b0f5 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameEntryExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameEntryExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.source.DataSourceId; import io.xpipe.core.source.DataSourceReference; import lombok.Builder; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameStoreExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameStoreExchange.java index 18a13138f..7552dbabf 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameStoreExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/RenameStoreExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.NonNull; import lombok.Value; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/SelectExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/SelectExchange.java index 0b35ae393..ef021202f 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/SelectExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/SelectExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.source.DataSourceReference; import lombok.Builder; import lombok.NonNull; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/StatusExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/StatusExchange.java index 13cc80b43..014d0b153 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/StatusExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/StatusExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.Value; import lombok.extern.jackson.Jacksonized; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/StoreAddExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/StoreAddExchange.java index b74861841..6ef354037 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/StoreAddExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/StoreAddExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.dialog.DialogReference; import io.xpipe.core.store.DataStore; import lombok.Builder; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/VersionExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/VersionExchange.java index 503bf30da..deb1a30d8 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/VersionExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/VersionExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import lombok.Builder; import lombok.Value; import lombok.extern.jackson.Jacksonized; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/WriteExecuteExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/WriteExecuteExchange.java index 4347e9a39..11dda1ef5 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/WriteExecuteExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/WriteExecuteExchange.java @@ -1,9 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; -import io.xpipe.core.source.DataSourceConfigInstance; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.source.DataSourceReference; import lombok.Builder; import lombok.NonNull; @@ -26,9 +25,6 @@ public class WriteExecuteExchange implements MessageExchange { public static class Request implements RequestMessage { @NonNull DataSourceReference ref; - - @NonNull - DataSourceConfigInstance config; } @Jacksonized diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/WritePreparationExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/WritePreparationExchange.java index 40007f458..3549b34a1 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/cli/WritePreparationExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/cli/WritePreparationExchange.java @@ -1,8 +1,8 @@ package io.xpipe.beacon.exchange.cli; import io.xpipe.beacon.exchange.MessageExchange; -import io.xpipe.beacon.message.RequestMessage; -import io.xpipe.beacon.message.ResponseMessage; +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; import io.xpipe.core.dialog.DialogReference; import io.xpipe.core.source.DataSourceReference; import io.xpipe.core.store.StreamDataStore; diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/data/ClientErrorMessage.java b/beacon/src/main/java/io/xpipe/beacon/exchange/data/ClientErrorMessage.java index d86e4231e..5abc922ee 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/data/ClientErrorMessage.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/data/ClientErrorMessage.java @@ -6,6 +6,7 @@ import lombok.Builder; import lombok.Value; import lombok.extern.jackson.Jacksonized; +@SuppressWarnings("ClassCanBeRecord") @Value @Builder @Jacksonized diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/data/ServerErrorMessage.java b/beacon/src/main/java/io/xpipe/beacon/exchange/data/ServerErrorMessage.java index 0a5433886..f238ec5ec 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/data/ServerErrorMessage.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/data/ServerErrorMessage.java @@ -8,6 +8,7 @@ import lombok.extern.jackson.Jacksonized; import java.util.UUID; +@SuppressWarnings("ClassCanBeRecord") @Value @Builder @Jacksonized diff --git a/beacon/src/main/java/io/xpipe/beacon/message/ResponseMessage.java b/beacon/src/main/java/io/xpipe/beacon/message/ResponseMessage.java deleted file mode 100644 index 787b9e76b..000000000 --- a/beacon/src/main/java/io/xpipe/beacon/message/ResponseMessage.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.xpipe.beacon.message; - -import io.xpipe.beacon.BeaconHandler; - -public interface ResponseMessage { - - default void postSend(BeaconHandler handler) throws Exception { - - } -} diff --git a/beacon/src/main/java/module-info.java b/beacon/src/main/java/module-info.java index bf698dc05..4e373d875 100644 --- a/beacon/src/main/java/module-info.java +++ b/beacon/src/main/java/module-info.java @@ -5,7 +5,6 @@ import io.xpipe.beacon.exchange.cli.*; module io.xpipe.beacon { exports io.xpipe.beacon; exports io.xpipe.beacon.exchange; - exports io.xpipe.beacon.message; exports io.xpipe.beacon.exchange.api; exports io.xpipe.beacon.exchange.data; exports io.xpipe.beacon.exchange.cli; @@ -13,7 +12,6 @@ module io.xpipe.beacon { opens io.xpipe.beacon; opens io.xpipe.beacon.exchange; opens io.xpipe.beacon.exchange.api; - opens io.xpipe.beacon.message; opens io.xpipe.beacon.exchange.data; opens io.xpipe.beacon.exchange.cli; diff --git a/charsetter/build.gradle b/charsetter/build.gradle deleted file mode 100644 index 4c1ebe294..000000000 --- a/charsetter/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id 'java' - id "org.moditect.gradleplugin" version "1.0.0-rc3" -} - -apply from: "$rootDir/deps/java.gradle" -apply from: "$rootDir/deps/commons.gradle" -apply from: "$rootDir/deps/junit.gradle" -apply from: "$rootDir/deps/lombok.gradle" -apply from: "$rootDir/deps/jackson.gradle" - - -configurations { - compileOnly.extendsFrom(dep) -} - diff --git a/charsetter/src/main/java/module-info.java b/charsetter/src/main/java/module-info.java deleted file mode 100644 index db84c86b0..000000000 --- a/charsetter/src/main/java/module-info.java +++ /dev/null @@ -1,8 +0,0 @@ -module io.xpipe.charsetter { - exports io.xpipe.charsetter; - - requires org.apache.commons.io; - requires org.apache.commons.lang3; - requires static lombok; - requires com.fasterxml.jackson.databind; -} \ No newline at end of file diff --git a/core/README.md b/core/README.md index 9d107cf94..c868b0ce7 100644 --- a/core/README.md +++ b/core/README.md @@ -2,19 +2,20 @@ [![javadoc](https://javadoc.io/badge2/io.xpipe/core/javadoc.svg)](https://javadoc.io/doc/io.xpipe/core) [![Build Status](https://github.com/xpipe-io/xpipe_java/actions/workflows/core-build.yml/badge.svg)](https://github.com/xpipe-io/xpipe_java/actions/workflows/core-build.yml) - ## X-Pipe Core -The X-Pipe core component contains all the shared core classes used by the API, beacon, and daemon. +The X-Pipe core module contains all the shared core classes used by the API, beacon, and daemon implementation. -The main part can be found in the [data package](). +The main component is the [data package](src/main/java/io/xpipe/core/data). It contains all definitions of the internal X-Pipe data model and all IO functionality for these data structures. -The [source package]() contains the basic data source model classes. -These have to be used by every custom data source implementation. +The [source package](src/main/java/io/xpipe/core/source) contains the basic data source classes, +which are used by every data source implementation. -The [store package]() contains the basic data store model classes. -These have to be used by every custom data store implementation. +The [store package](src/main/java/io/xpipe/core/store) contains the basic data store classes, +which are used by every data store implementation. Every class is expected to be potentially used in the context of files and message exchanges. -As a result, all data structures exchanged must be serializable/deserializable with jackson. \ No newline at end of file +As a result, all data structures exchanged must be serializable/deserializable with jackson. + + diff --git a/core/build.gradle b/core/build.gradle index cd76f6065..3a88d39f8 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -14,6 +14,7 @@ apply from: "$rootDir/deps/publish-base.gradle" configurations { compileOnly.extendsFrom(dep) + testImplementation.extendsFrom(dep) } version = file('../version').text diff --git a/charsetter/src/main/java/io/xpipe/charsetter/Charsettable.java b/core/src/main/java/io/xpipe/core/charsetter/Charsettable.java similarity index 73% rename from charsetter/src/main/java/io/xpipe/charsetter/Charsettable.java rename to core/src/main/java/io/xpipe/core/charsetter/Charsettable.java index 42da3d4df..3a78f0a3a 100644 --- a/charsetter/src/main/java/io/xpipe/charsetter/Charsettable.java +++ b/core/src/main/java/io/xpipe/core/charsetter/Charsettable.java @@ -1,4 +1,4 @@ -package io.xpipe.charsetter; +package io.xpipe.core.charsetter; import java.nio.charset.Charset; diff --git a/charsetter/src/main/java/io/xpipe/charsetter/Charsetter.java b/core/src/main/java/io/xpipe/core/charsetter/Charsetter.java similarity index 61% rename from charsetter/src/main/java/io/xpipe/charsetter/Charsetter.java rename to core/src/main/java/io/xpipe/core/charsetter/Charsetter.java index 86a1d32fa..95ad86e5f 100644 --- a/charsetter/src/main/java/io/xpipe/charsetter/Charsetter.java +++ b/core/src/main/java/io/xpipe/core/charsetter/Charsetter.java @@ -1,10 +1,6 @@ -package io.xpipe.charsetter; +package io.xpipe.core.charsetter; import lombok.Value; -import org.apache.commons.io.ByteOrderMark; -import org.apache.commons.io.input.BOMInputStream; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableSupplier; import java.io.InputStream; import java.io.InputStreamReader; @@ -15,52 +11,46 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Map; -public class Charsetter { +public abstract class Charsetter { private static CharsetterUniverse universe; - private static final int MAX_BYTES = 8192; - public static void init(CharsetterContext ctx) { - universe = CharsetterUniverse.create(ctx); - } - - private static void checkInit() { + protected static void checkInit() { if (universe == null) { throw new IllegalStateException("Charsetter not initialized"); } } + public static void init(CharsetterContext ctx) { + universe = CharsetterUniverse.create(ctx); + } + @Value public static class Result { Charset charset; NewLine newLine; } - public static Result read(FailableSupplier in, FailableConsumer con) throws Exception { - checkInit(); + public static Charsetter INSTANCE; - try (var is = in.get(); - var bin = new BOMInputStream(is)) { - ByteOrderMark bom = bin.getBOM(); - String charsetName = bom == null ? null : bom.getCharsetName(); - var charset = charsetName != null ? Charset.forName(charsetName) : null; - - bin.mark(MAX_BYTES); - var bytes = bin.readNBytes(MAX_BYTES); - bin.reset(); - if (charset == null) { - charset = inferCharset(bytes); - } - var nl = inferNewLine(bytes); - - if (con != null) { - con.accept(new InputStreamReader(bin, charset)); - } - return new Result(charset, nl); - } + public static Charsetter get() { + return INSTANCE; } - public static NewLine inferNewLine(byte[] content) { + @FunctionalInterface + public interface FailableSupplier { + R get() throws E; + } + + @FunctionalInterface + public interface FailableConsumer { + + void accept(T var1) throws E; + } + + public abstract Result read(FailableSupplier in, FailableConsumer con) throws Exception; + + public NewLine inferNewLine(byte[] content) { Map count = new HashMap<>(); for (var nl : NewLine.values()) { var nlBytes = nl.getNewLine().getBytes(StandardCharsets.UTF_8); @@ -75,7 +65,7 @@ public class Charsetter { .orElseThrow().getKey(); } - public static int count(byte[] outerArray, byte[] smallerArray) { + private static int count(byte[] outerArray, byte[] smallerArray) { int count = 0; for(int i = 0; i < outerArray.length - smallerArray.length+1; ++i) { boolean found = true; @@ -92,7 +82,7 @@ public class Charsetter { return count; } - public static Charset inferCharset(byte[] content) { + public Charset inferCharset(byte[] content) { checkInit(); for (Charset c : universe.getCharsets()) { diff --git a/charsetter/src/main/java/io/xpipe/charsetter/CharsetterContext.java b/core/src/main/java/io/xpipe/core/charsetter/CharsetterContext.java similarity index 93% rename from charsetter/src/main/java/io/xpipe/charsetter/CharsetterContext.java rename to core/src/main/java/io/xpipe/core/charsetter/CharsetterContext.java index a69689d2d..0dbf39c3c 100644 --- a/charsetter/src/main/java/io/xpipe/charsetter/CharsetterContext.java +++ b/core/src/main/java/io/xpipe/core/charsetter/CharsetterContext.java @@ -1,4 +1,4 @@ -package io.xpipe.charsetter; +package io.xpipe.core.charsetter; import lombok.AllArgsConstructor; import lombok.Value; diff --git a/charsetter/src/main/java/io/xpipe/charsetter/CharsetterUniverse.java b/core/src/main/java/io/xpipe/core/charsetter/CharsetterUniverse.java similarity index 95% rename from charsetter/src/main/java/io/xpipe/charsetter/CharsetterUniverse.java rename to core/src/main/java/io/xpipe/core/charsetter/CharsetterUniverse.java index 471c0b4ef..c19c1eee7 100644 --- a/charsetter/src/main/java/io/xpipe/charsetter/CharsetterUniverse.java +++ b/core/src/main/java/io/xpipe/core/charsetter/CharsetterUniverse.java @@ -1,4 +1,4 @@ -package io.xpipe.charsetter; +package io.xpipe.core.charsetter; import lombok.AllArgsConstructor; import lombok.Value; diff --git a/charsetter/src/main/java/io/xpipe/charsetter/NewLine.java b/core/src/main/java/io/xpipe/core/charsetter/NewLine.java similarity index 96% rename from charsetter/src/main/java/io/xpipe/charsetter/NewLine.java rename to core/src/main/java/io/xpipe/core/charsetter/NewLine.java index 158552c3d..2844bc4bf 100644 --- a/charsetter/src/main/java/io/xpipe/charsetter/NewLine.java +++ b/core/src/main/java/io/xpipe/core/charsetter/NewLine.java @@ -1,4 +1,4 @@ -package io.xpipe.charsetter; +package io.xpipe.core.charsetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamParser.java b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamParser.java index ce442bc9f..dd77c9d59 100644 --- a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamParser.java +++ b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamParser.java @@ -79,7 +79,13 @@ public class GenericDataStreamParser { } private static void parseValue(InputStream in, GenericDataStreamCallback cb) throws IOException { - var textual = in.read() != 0; + var type = in.read(); + if (type == DataStructureNodeIO.VALUE_TYPE_NULL) { + cb.onValue(null, false); + return; + } + + var textual = type == DataStructureNodeIO.VALUE_TYPE_TEXT; var size = in.read(); var data = in.readNBytes(size); cb.onValue(data, textual); diff --git a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamWriter.java b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamWriter.java index b05f45306..e39a01c05 100644 --- a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamWriter.java +++ b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamWriter.java @@ -51,10 +51,15 @@ public class GenericDataStreamWriter { } } - private static void writeValue(OutputStream out, ValueNode value) throws IOException { + private static void writeValue(OutputStream out, ValueNode n) throws IOException { out.write(DataStructureNodeIO.GENERIC_VALUE_ID); - out.write(value.isTextual() ? 1 : 0); - out.write(value.getRawData().length); - out.write(value.getRawData()); + if (n.isNull()) { + out.write(DataStructureNodeIO.VALUE_TYPE_NULL); + return; + } + + out.write(n.isTextual() ? DataStructureNodeIO.VALUE_TYPE_TEXT : DataStructureNodeIO.VALUE_TYPE_BARE); + out.write(n.getRawData().length); + out.write(n.getRawData()); } } diff --git a/core/src/main/java/io/xpipe/core/data/node/DataStructureNodeIO.java b/core/src/main/java/io/xpipe/core/data/node/DataStructureNodeIO.java index bd9b2b08b..28572cde8 100644 --- a/core/src/main/java/io/xpipe/core/data/node/DataStructureNodeIO.java +++ b/core/src/main/java/io/xpipe/core/data/node/DataStructureNodeIO.java @@ -12,4 +12,8 @@ public class DataStructureNodeIO { public static final int TYPED_TUPLE_ID = 6; public static final int TYPED_ARRAY_ID = 7; public static final int TYPED_VALUE_ID = 8; + + public static final int VALUE_TYPE_BARE = 0; + public static final int VALUE_TYPE_TEXT = 1; + public static final int VALUE_TYPE_NULL = 2; } diff --git a/core/src/main/java/io/xpipe/core/data/node/MutableValueNode.java b/core/src/main/java/io/xpipe/core/data/node/MutableValueNode.java index 32bf8aa42..6341046b5 100644 --- a/core/src/main/java/io/xpipe/core/data/node/MutableValueNode.java +++ b/core/src/main/java/io/xpipe/core/data/node/MutableValueNode.java @@ -21,9 +21,18 @@ public class MutableValueNode extends ValueNode { @Override public String toString(int indent) { + if (isNull()) { + return "null (M)"; + } + return (textual ? "\"" : "") + new String(data) + (textual ? "\"" : "") + " (M)"; } + @Override + public boolean isNull() { + return data == null; + } + @Override public boolean isTextual() { return textual; diff --git a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamParser.java b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamParser.java index eb06e68ad..4c9e4df48 100644 --- a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamParser.java +++ b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamParser.java @@ -129,7 +129,13 @@ public class TypedDataStreamParser { } private void parseValue(InputStream in, TypedDataStreamCallback cb) throws IOException { - var textual = in.read() != 0; + var type = in.read(); + if (type == DataStructureNodeIO.VALUE_TYPE_NULL) { + cb.onValue(null, false); + return; + } + + var textual = type == DataStructureNodeIO.VALUE_TYPE_TEXT; var size = in.read(); var data = in.readNBytes(size); cb.onValue(data, textual); diff --git a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamWriter.java b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamWriter.java index c6cd19f28..6b543645a 100644 --- a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamWriter.java +++ b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamWriter.java @@ -32,7 +32,12 @@ public class TypedDataStreamWriter { private static void writeValue(OutputStream out, ValueNode n) throws IOException { out.write(DataStructureNodeIO.TYPED_VALUE_ID); - out.write(n.isTextual() ? 1 : 0); + if (n.isNull()) { + out.write(DataStructureNodeIO.VALUE_TYPE_NULL); + return; + } + + out.write(n.isTextual() ? DataStructureNodeIO.VALUE_TYPE_TEXT : DataStructureNodeIO.VALUE_TYPE_BARE); out.write(n.getRawData().length); out.write(n.getRawData()); } diff --git a/core/src/main/java/io/xpipe/core/dialog/ConfigParameter.java b/core/src/main/java/io/xpipe/core/dialog/ConfigParameter.java deleted file mode 100644 index c242c281a..000000000 --- a/core/src/main/java/io/xpipe/core/dialog/ConfigParameter.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.xpipe.core.dialog; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.AllArgsConstructor; -import lombok.Value; - -@Value -@AllArgsConstructor -public class ConfigParameter { - String key; - - @JsonCreator - public ConfigParameter(String key) { - this.key = key; - this.converter = null; - } - - @JsonIgnore - QueryConverter converter; - - @SuppressWarnings("unchecked") - public QueryConverter getConverter() { - return (QueryConverter) converter; - } -} diff --git a/core/src/main/java/io/xpipe/core/dialog/ConfigParameterSetInstance.java b/core/src/main/java/io/xpipe/core/dialog/ConfigParameterSetInstance.java deleted file mode 100644 index 3cdae12d1..000000000 --- a/core/src/main/java/io/xpipe/core/dialog/ConfigParameterSetInstance.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.xpipe.core.dialog; - -import com.fasterxml.jackson.annotation.JsonCreator; -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -@Value -@AllArgsConstructor(onConstructor_={@JsonCreator}) -public class ConfigParameterSetInstance { - - /** - * The available configuration parameters. - */ - List configParameters; - - /** - * The current configuration options that are set. - */ - Map currentValues; - - public ConfigParameterSetInstance(Map map) { - configParameters = map.keySet().stream().toList(); - currentValues = map.entrySet().stream().collect(Collectors.toMap( - e -> e.getKey().getKey(), - e -> e.getKey().getConverter().convertToString(e.getValue()))); - } - - public > ConfigParameterSetInstance(Map map, Object v) { - configParameters = map.keySet().stream().toList(); - currentValues = map.entrySet().stream().collect(Collectors.toMap( - e -> e.getKey().getKey(), - e -> e.getKey().getConverter().convertToString(apply(e.getValue(), v)))); - } - - @SuppressWarnings("unchecked") - private static , V> Object apply(T func, Object v) { - return func.apply((X) v); - } - - public void update(ConfigParameter p, String val) { - currentValues.put(p.getKey(), val); - } - - public Map evaluate() { - return configParameters.stream().collect(Collectors.toMap( - p -> p, - p -> p.getConverter().convertFromString(currentValues.get(p.getKey())))); - } -} diff --git a/core/src/main/java/io/xpipe/core/source/DataSourceConfigInstance.java b/core/src/main/java/io/xpipe/core/source/DataSourceConfigInstance.java deleted file mode 100644 index 57276d83b..000000000 --- a/core/src/main/java/io/xpipe/core/source/DataSourceConfigInstance.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.xpipe.core.source; - -import com.fasterxml.jackson.annotation.JsonCreator; -import io.xpipe.core.dialog.ConfigParameter; -import io.xpipe.core.dialog.ConfigParameterSetInstance; -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.util.Map; -import java.util.function.Function; - -/** - * Represents the current configuration of a data source. - * This configuration can either be in progress or complete. - */ -@Value -@AllArgsConstructor(onConstructor_={@JsonCreator}) -public class DataSourceConfigInstance { - - public static DataSourceConfigInstance xpbt() { - return new DataSourceConfigInstance("xpbt", new ConfigParameterSetInstance(Map.of())); - } - - /** - * The data source provider id. - */ - String provider; - - /** - * The available configuration parameters. - */ - ConfigParameterSetInstance configInstance; - - public DataSourceConfigInstance(String provider, Map map) { - this.provider = provider; - this.configInstance = new ConfigParameterSetInstance(map); - } - - public > DataSourceConfigInstance(String provider, Map map, Object val) { - this.provider = provider; - this.configInstance = new ConfigParameterSetInstance(map, val); - } - - public Map evaluate() { - return configInstance.evaluate(); - } -} diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java index dc34cb1ee..8b899a0de 100644 --- a/core/src/main/java/module-info.java +++ b/core/src/main/java/module-info.java @@ -9,7 +9,6 @@ module io.xpipe.core { exports io.xpipe.core.data.node; exports io.xpipe.core.data.typed; exports io.xpipe.core.dialog; - exports io.xpipe.core.connection; opens io.xpipe.core.store; opens io.xpipe.core.source; @@ -19,6 +18,7 @@ module io.xpipe.core { opens io.xpipe.core.data.node; opens io.xpipe.core.data.typed; opens io.xpipe.core.dialog; + exports io.xpipe.core.charsetter; requires com.fasterxml.jackson.core; requires com.fasterxml.jackson.databind; diff --git a/extension/README.md b/extension/README.md index 2f9644374..b266b4327 100644 --- a/extension/README.md +++ b/extension/README.md @@ -5,16 +5,14 @@ ## X-Pipe Extension API The X-Pipe extension API allows you to create extensions of any kind for X-Pipe. - +This includes: +- Custom data stores, including configuration GUI and CLI +- Custom data sources, including configuration GUI and CLI +- Custom preferences entries ### Custom data sources -A custom data source type can be implemented by creating a custom [DataSourceProvider](). +A custom data source type can be implemented by creating a custom +[DataSourceProvider](src/main/java/io/xpipe/extension/DataSourceProvider.java). This provider contains all the information required for proper handling of your custom data sources, whether you access it from the CLI, any API, or the X-Pipe commander gui. - -### Custom data sinks - -A custom data sink type can be implemented by creating a custom [DataSinkProvider](). -As the notion of a sink is abstract, it allows you to basically implement any type of sink you want. -Whether the target is a programming language, another application, a database, or a regular file. \ No newline at end of file diff --git a/extension/build.gradle b/extension/build.gradle index 1742727a0..0b3f8daaf 100644 --- a/extension/build.gradle +++ b/extension/build.gradle @@ -32,7 +32,6 @@ repositories { dependencies { compileOnly 'org.junit.jupiter:junit-jupiter-api:5.8.2' implementation project(':core') - implementation project(':charsetter') implementation 'io.xpipe:fxcomps:0.1' implementation 'com.google.code.gson:gson:2.9.0' diff --git a/extension/src/main/java/io/xpipe/extension/DataSourceProvider.java b/extension/src/main/java/io/xpipe/extension/DataSourceProvider.java index 2aba60d9a..b185bb818 100644 --- a/extension/src/main/java/io/xpipe/extension/DataSourceProvider.java +++ b/extension/src/main/java/io/xpipe/extension/DataSourceProvider.java @@ -1,6 +1,6 @@ package io.xpipe.extension; -import io.xpipe.charsetter.NewLine; +import io.xpipe.core.charsetter.NewLine; import io.xpipe.core.dialog.Dialog; import io.xpipe.core.dialog.QueryConverter; import io.xpipe.core.source.DataSource; diff --git a/extension/src/main/java/io/xpipe/extension/ExtensionTest.java b/extension/src/main/java/io/xpipe/extension/ExtensionTest.java index fcd292b88..bfa1eb2e4 100644 --- a/extension/src/main/java/io/xpipe/extension/ExtensionTest.java +++ b/extension/src/main/java/io/xpipe/extension/ExtensionTest.java @@ -1,7 +1,7 @@ package io.xpipe.extension; -import io.xpipe.charsetter.Charsetter; -import io.xpipe.charsetter.CharsetterContext; +import io.xpipe.core.charsetter.Charsetter; +import io.xpipe.core.charsetter.CharsetterContext; import io.xpipe.core.util.JacksonHelper; import io.xpipe.extension.util.ModuleHelper; import org.junit.jupiter.api.AfterAll; diff --git a/extension/src/main/java/io/xpipe/extension/comp/DynamicOptionsBuilder.java b/extension/src/main/java/io/xpipe/extension/comp/DynamicOptionsBuilder.java index 4f68dd5c9..ca3e9c1ae 100644 --- a/extension/src/main/java/io/xpipe/extension/comp/DynamicOptionsBuilder.java +++ b/extension/src/main/java/io/xpipe/extension/comp/DynamicOptionsBuilder.java @@ -1,6 +1,6 @@ package io.xpipe.extension.comp; -import io.xpipe.charsetter.NewLine; +import io.xpipe.core.charsetter.NewLine; import io.xpipe.core.source.DataSource; import io.xpipe.extension.I18n; import io.xpipe.fxcomps.Comp; diff --git a/extension/src/main/java/module-info.java b/extension/src/main/java/module-info.java index e461d08c2..84676f8a7 100644 --- a/extension/src/main/java/module-info.java +++ b/extension/src/main/java/module-info.java @@ -28,7 +28,6 @@ module io.xpipe.extension { requires org.kordamp.ikonli.javafx; requires com.fasterxml.jackson.databind; requires static org.junit.jupiter.api; - requires io.xpipe.charsetter; uses DataSourceProvider; uses SupportedApplicationProvider; diff --git a/jreleaser.gradle b/jreleaser.gradle new file mode 100644 index 000000000..c19cc619a --- /dev/null +++ b/jreleaser.gradle @@ -0,0 +1,100 @@ +def isPreRelease = project.version.endsWith('-pre') +def isFullRelease = !isPreRelease && !project.version.endsWith('-SNAPSHOT') +def proj = project +def canonicalVersion = file('canonical_version').text + +jreleaser { + environment { + properties.put('rawChangelog', file("changelogs/${canonicalVersion}.txt").exists() ? + file("changelogs/${canonicalVersion}.txt").text.replace('\r\n', '\n') : "") + } + + project { + name = 'Pdx-Unlimiter' + description = 'A smart savegame manager, editor, and toolbox for all current major Paradox Grand Strategy games.' + longDescription = 'The Pdx-Unlimiter is a tool for all major Paradox Grand Strategy games that provides a ' + + 'powerful and smart savegame manager to quickly organize and play all of your savegames with ease. ' + + 'Furthermore, it also comes with an Ironman converter, a powerful savegame editor, some savescumming ' + + 'tools, integrations for various other great community-made tools for all major Paradox games.' + website = 'https://github.com/crschnick/pdx_unlimiter' + authors = ['Christopher Schnick'] + license = 'GPL3' + copyright = ' ' + + java { + groupId = 'com.crschnick.pdxu' + version = '17' + multiProject = true + } + + snapshot { + enabled = true + pattern = '.*-SNAPSHOT' + label = 'early-access' + } + } + + release { + github { + skipRelease = !isFullRelease && !isPreRelease + skipTag = !isFullRelease && !isPreRelease + owner = 'crschnick' + overwrite = false + tagName = '{{projectVersion}}' + releaseName = '{{tagName}}' + token = proj.hasProperty("PDXU_GITHUB_TOKEN") ? proj.property("PDXU_GITHUB_TOKEN") : System.getenv("JRELEASER_GITHUB_TOKEN") + + files = true + artifacts = true + checksums = false + signatures = false + + // Always set a pre-release, as drafts do not fully work + prerelease { + enabled = true + pattern = '.*' + } + + update { + enabled = true + section('ASSETS') + section('TITLE') + section('BODY') + } + + changelog { + enabled = true + formatted = 'ALWAYS' + contentTemplate = isFullRelease ? file('misc/github_full.tpl') : file('misc/github_pre.tpl') + } + } + } + distributions { + app { + if (org.gradle.internal.os.OperatingSystem.current().isWindows()) { + artifact { + distributionType = 'BINARY' + path = 'build/pdx_unlimiter-windows.zip' + platform = 'windows' + } + } else { + artifact { + distributionType = 'BINARY' + path = 'build/pdx_unlimiter-linux.zip' + platform = 'linux' + } + } + } + } + + announce { + enabled = isFullRelease || isPreRelease + discord { + active = 'ALWAYS' + + webhook = proj.hasProperty("PDXU_DISCORD_WEBHOOK") ? proj.property("PDXU_DISCORD_WEBHOOK") : System.getenv("JRELEASER_DISCORD_WEBHOOK") + + messageTemplate = isFullRelease ? 'misc/discord_full.tpl' : 'misc/discord_pre.tpl' + } + } +}