mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 17:10:27 +00:00
Fixes
This commit is contained in:
parent
8d95f451bb
commit
4216528a87
12 changed files with 89 additions and 25 deletions
|
@ -9,7 +9,7 @@ apply from: "$rootDir/deps/java.gradle"
|
||||||
apply from: "$rootDir/deps/junit.gradle"
|
apply from: "$rootDir/deps/junit.gradle"
|
||||||
|
|
||||||
System.setProperty('excludeExtensionLibrary', 'true')
|
System.setProperty('excludeExtensionLibrary', 'true')
|
||||||
apply from: "$rootDir/scripts/extension_test.gradle"
|
apply from: "$rootDir/deps/extension_test.gradle"
|
||||||
|
|
||||||
version = file('../misc/version').text
|
version = file('../misc/version').text
|
||||||
group = 'io.xpipe'
|
group = 'io.xpipe'
|
||||||
|
|
|
@ -19,6 +19,10 @@ public class BeaconFormat {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
|
if (isClosed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
finishBlock();
|
finishBlock();
|
||||||
out.flush();
|
out.flush();
|
||||||
index = -1;
|
index = -1;
|
||||||
|
@ -26,6 +30,10 @@ public class BeaconFormat {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
|
if (isClosed()) {
|
||||||
|
throw new IllegalStateException("Output is closed");
|
||||||
|
}
|
||||||
|
|
||||||
if (index == currentBytes.length) {
|
if (index == currentBytes.length) {
|
||||||
finishBlock();
|
finishBlock();
|
||||||
}
|
}
|
||||||
|
@ -34,7 +42,15 @@ public class BeaconFormat {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isClosed() {
|
||||||
|
return index == -1;
|
||||||
|
}
|
||||||
|
|
||||||
private void finishBlock() throws IOException {
|
private void finishBlock() throws IOException {
|
||||||
|
if (isClosed()) {
|
||||||
|
throw new IllegalStateException("Output is closed");
|
||||||
|
}
|
||||||
|
|
||||||
if (BeaconConfig.printMessages()) {
|
if (BeaconConfig.printMessages()) {
|
||||||
System.out.println("Sending data block of length " + index);
|
System.out.println("Sending data block of length " + index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,18 @@ public abstract class ValueNode extends DataStructureNode {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ValueNode ofText(String text) {
|
||||||
|
var created = of(text);
|
||||||
|
created.tag(IS_TEXT);
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ValueNode ofInteger(int integer) {
|
||||||
|
var created = of(integer);
|
||||||
|
created.tag(IS_INTEGER);
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
public static ValueNode ofInteger(BigInteger integer) {
|
public static ValueNode ofInteger(BigInteger integer) {
|
||||||
var created = of(integer);
|
var created = of(integer);
|
||||||
created.tag(IS_INTEGER);
|
created.tag(IS_INTEGER);
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package io.xpipe.core.impl;
|
||||||
|
|
||||||
|
import io.xpipe.core.data.generic.GenericDataStreamParser;
|
||||||
|
import io.xpipe.core.data.node.DataStructureNode;
|
||||||
|
import io.xpipe.core.source.StreamReadConnection;
|
||||||
|
import io.xpipe.core.source.StructureReadConnection;
|
||||||
|
|
||||||
|
public class XpbsReadConnection extends StreamReadConnection implements StructureReadConnection {
|
||||||
|
|
||||||
|
public XpbsReadConnection(XpbsSource source) {
|
||||||
|
super(source.getStore(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataStructureNode read() throws Exception {
|
||||||
|
return GenericDataStreamParser.parse(inputStream);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,18 +6,20 @@ import io.xpipe.core.source.StructureReadConnection;
|
||||||
import io.xpipe.core.source.StructureWriteConnection;
|
import io.xpipe.core.source.StructureWriteConnection;
|
||||||
import io.xpipe.core.store.StreamDataStore;
|
import io.xpipe.core.store.StreamDataStore;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import lombok.extern.jackson.Jacksonized;
|
||||||
|
|
||||||
@JsonTypeName("xpbs")
|
@JsonTypeName("xpbs")
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
|
@Jacksonized
|
||||||
public class XpbsSource extends StructureDataSource<StreamDataStore> {
|
public class XpbsSource extends StructureDataSource<StreamDataStore> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected StructureWriteConnection newWriteConnection() {
|
protected StructureWriteConnection newWriteConnection() {
|
||||||
return null;
|
return new XpbsWriteConnection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected StructureReadConnection newReadConnection() {
|
protected StructureReadConnection newReadConnection() {
|
||||||
return null;
|
return new XpbsReadConnection(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package io.xpipe.core.impl;
|
||||||
|
|
||||||
|
import io.xpipe.core.data.generic.GenericDataStreamWriter;
|
||||||
|
import io.xpipe.core.data.node.DataStructureNode;
|
||||||
|
import io.xpipe.core.source.StreamWriteConnection;
|
||||||
|
import io.xpipe.core.source.StructureWriteConnection;
|
||||||
|
|
||||||
|
public class XpbsWriteConnection extends StreamWriteConnection implements StructureWriteConnection {
|
||||||
|
|
||||||
|
public XpbsWriteConnection(XpbsSource source) {
|
||||||
|
super(source.getStore(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(DataStructureNode node) throws Exception {
|
||||||
|
GenericDataStreamWriter.writeStructure(outputStream,node);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,11 +6,15 @@ import io.xpipe.core.source.TableReadConnection;
|
||||||
import io.xpipe.core.source.TableWriteConnection;
|
import io.xpipe.core.source.TableWriteConnection;
|
||||||
import io.xpipe.core.store.StreamDataStore;
|
import io.xpipe.core.store.StreamDataStore;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import lombok.extern.jackson.Jacksonized;
|
||||||
|
|
||||||
@JsonTypeName("xpbt")
|
@JsonTypeName("xpbt")
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
|
@Jacksonized
|
||||||
public class XpbtSource extends TableDataSource<StreamDataStore> {
|
public class XpbtSource extends TableDataSource<StreamDataStore> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TableWriteConnection newWriteConnection() {
|
protected TableWriteConnection newWriteConnection() {
|
||||||
return new XpbtWriteConnection(store);
|
return new XpbtWriteConnection(store);
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package io.xpipe.core.store;
|
package io.xpipe.core.store;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import lombok.extern.jackson.Jacksonized;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -12,16 +13,13 @@ import java.util.Optional;
|
||||||
* The referenced store has to be resolved by the caller manually, as this class does not act as a resolver.
|
* The referenced store has to be resolved by the caller manually, as this class does not act as a resolver.
|
||||||
*/
|
*/
|
||||||
@JsonTypeName("named")
|
@JsonTypeName("named")
|
||||||
|
@SuperBuilder
|
||||||
|
@Jacksonized
|
||||||
public final class NamedStore implements DataStore {
|
public final class NamedStore implements DataStore {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
@JsonCreator
|
|
||||||
public NamedStore(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws Exception {
|
public void validate() throws Exception {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
|
|
@ -3,6 +3,7 @@ package io.xpipe.core.store;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import io.xpipe.core.util.JacksonizedValue;
|
import io.xpipe.core.util.JacksonizedValue;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import lombok.extern.jackson.Jacksonized;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -10,6 +11,7 @@ import java.io.OutputStream;
|
||||||
|
|
||||||
@JsonTypeName("stdin")
|
@JsonTypeName("stdin")
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
|
@Jacksonized
|
||||||
public class StdinDataStore extends JacksonizedValue implements StreamDataStore {
|
public class StdinDataStore extends JacksonizedValue implements StreamDataStore {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,12 +3,14 @@ package io.xpipe.core.store;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import io.xpipe.core.util.JacksonizedValue;
|
import io.xpipe.core.util.JacksonizedValue;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import lombok.extern.jackson.Jacksonized;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
@JsonTypeName("stdout")
|
@JsonTypeName("stdout")
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
|
@Jacksonized
|
||||||
public class StdoutDataStore extends JacksonizedValue implements StreamDataStore {
|
public class StdoutDataStore extends JacksonizedValue implements StreamDataStore {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
package io.xpipe.core.store;
|
package io.xpipe.core.store;
|
||||||
|
|
||||||
import lombok.Value;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import lombok.extern.jackson.Jacksonized;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
@Value
|
|
||||||
|
@JsonTypeName("url")
|
||||||
|
@SuperBuilder
|
||||||
|
@Jacksonized
|
||||||
public class URLDataStore implements StreamDataStore {
|
public class URLDataStore implements StreamDataStore {
|
||||||
|
|
||||||
URL url;
|
private final URL url;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream openInput() throws Exception {
|
public InputStream openInput() throws Exception {
|
||||||
|
|
|
@ -2,11 +2,7 @@ package io.xpipe.extension.util;
|
||||||
|
|
||||||
import io.xpipe.core.dialog.Dialog;
|
import io.xpipe.core.dialog.Dialog;
|
||||||
import io.xpipe.core.source.DataSource;
|
import io.xpipe.core.source.DataSource;
|
||||||
import io.xpipe.core.store.DataStore;
|
|
||||||
import io.xpipe.extension.DataSourceProvider;
|
import io.xpipe.extension.DataSourceProvider;
|
||||||
import io.xpipe.extension.ExtensionException;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public interface UniformDataSourceProvider<T extends DataSource<?>> extends DataSourceProvider<T> {
|
public interface UniformDataSourceProvider<T extends DataSource<?>> extends DataSourceProvider<T> {
|
||||||
|
|
||||||
|
@ -15,13 +11,4 @@ public interface UniformDataSourceProvider<T extends DataSource<?>> extends Data
|
||||||
return Dialog.empty().evaluateTo(() -> source);
|
return Dialog.empty().evaluateTo(() -> source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
default T createDefaultSource(DataStore input) throws Exception {
|
|
||||||
try {
|
|
||||||
return (T) getSourceClass().getDeclaredConstructors()[0].newInstance(input);
|
|
||||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
|
||||||
throw new ExtensionException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue