mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Remove api module
This commit is contained in:
parent
1c43bece80
commit
965dfe04e8
14 changed files with 0 additions and 348 deletions
|
@ -1,7 +0,0 @@
|
||||||
Copyright 2022 Christopher Schnick
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
@ -1,20 +0,0 @@
|
||||||
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.xpipe/xpipe-api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.xpipe/xpipe-api)
|
|
||||||
[![javadoc](https://javadoc.io/badge2/io.xpipe/xpipe-api/javadoc.svg)](https://javadoc.io/doc/io.xpipe/xpipe-api)
|
|
||||||
|
|
||||||
## XPipe Java API
|
|
||||||
|
|
||||||
The XPipe API for Java allows you to use most of the XPipe functionality from Java applications:
|
|
||||||
|
|
||||||
- Create data stores and data sources
|
|
||||||
- Query and work with the contents of data sources
|
|
||||||
- Write data to data sources
|
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
Either install the [maven dependency](https://maven-badges.herokuapp.com/maven-central/io.xpipe/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/releases/latest) and add them to the classpath.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
See [the API documentation](https://xpipe-io.readthedocs.io/en/latest/dev/api/java/index.html).
|
|
|
@ -1,38 +0,0 @@
|
||||||
plugins {
|
|
||||||
id 'java-library'
|
|
||||||
id 'maven-publish'
|
|
||||||
id 'signing'
|
|
||||||
}
|
|
||||||
|
|
||||||
apply from: "$rootDir/gradle/gradle_scripts/java.gradle"
|
|
||||||
apply from: "$rootDir/gradle/gradle_scripts/junit.gradle"
|
|
||||||
|
|
||||||
version = rootProject.versionString
|
|
||||||
group = 'io.xpipe'
|
|
||||||
archivesBaseName = 'xpipe-api'
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testImplementation project(':api')
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api project(':core')
|
|
||||||
implementation project(':beacon')
|
|
||||||
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.16.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
testImplementation.extendsFrom(dep)
|
|
||||||
}
|
|
||||||
|
|
||||||
task dist(type: Copy) {
|
|
||||||
from jar.archiveFile
|
|
||||||
into "${project(':dist').buildDir}/dist/libraries"
|
|
||||||
}
|
|
||||||
|
|
||||||
apply from: 'publish.gradle'
|
|
||||||
apply from: "$rootDir/gradle/gradle_scripts/publish-base.gradle"
|
|
|
@ -1,40 +0,0 @@
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
mavenJava(MavenPublication) {
|
|
||||||
artifactId = project.archivesBaseName
|
|
||||||
|
|
||||||
from components.java
|
|
||||||
|
|
||||||
pom.withXml {
|
|
||||||
def pomNode = asNode()
|
|
||||||
pomNode.dependencies.'*'.findAll().each() {
|
|
||||||
it.scope*.value = 'compile'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pom {
|
|
||||||
name = 'XPipe Java API'
|
|
||||||
description = 'Contains everything necessary to interact with XPipe from Java applications.'
|
|
||||||
url = 'https://github.com/xpipe-io/xpipe/api'
|
|
||||||
licenses {
|
|
||||||
license {
|
|
||||||
name = 'The MIT License (MIT)'
|
|
||||||
url = 'https://github.com/xpipe-io/xpipe/LICENSE.md'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id = 'crschnick'
|
|
||||||
name = 'Christopher Schnick'
|
|
||||||
email = 'crschnick@xpipe.io'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scm {
|
|
||||||
connection = 'scm:git:git://github.com/xpipe-io/xpipe.git'
|
|
||||||
developerConnection = 'scm:git:ssh://github.com/xpipe-io/xpipe.git'
|
|
||||||
url = 'https://github.com/xpipe-io/xpipe'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package io.xpipe.api;
|
|
||||||
|
|
||||||
import io.xpipe.api.connector.XPipeApiConnection;
|
|
||||||
import io.xpipe.beacon.exchange.cli.StoreAddExchange;
|
|
||||||
import io.xpipe.beacon.util.QuietDialogHandler;
|
|
||||||
import io.xpipe.core.store.DataStore;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class DataStores {
|
|
||||||
|
|
||||||
public static void addNamedStore(DataStore store, String name) {
|
|
||||||
XPipeApiConnection.execute(con -> {
|
|
||||||
var req = StoreAddExchange.Request.builder()
|
|
||||||
.storeInput(store)
|
|
||||||
.name(name)
|
|
||||||
.build();
|
|
||||||
StoreAddExchange.Response res = con.performSimpleExchange(req);
|
|
||||||
|
|
||||||
new QuietDialogHandler(res.getConfig(), con, Map.of()).handle();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,150 +0,0 @@
|
||||||
package io.xpipe.api.connector;
|
|
||||||
|
|
||||||
import io.xpipe.beacon.BeaconClient;
|
|
||||||
import io.xpipe.beacon.BeaconConnection;
|
|
||||||
import io.xpipe.beacon.BeaconException;
|
|
||||||
import io.xpipe.beacon.BeaconServer;
|
|
||||||
import io.xpipe.beacon.exchange.cli.DialogExchange;
|
|
||||||
import io.xpipe.core.dialog.DialogReference;
|
|
||||||
import io.xpipe.core.util.XPipeDaemonMode;
|
|
||||||
import io.xpipe.core.util.XPipeInstallation;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public final class XPipeApiConnection extends BeaconConnection {
|
|
||||||
|
|
||||||
private XPipeApiConnection() {}
|
|
||||||
|
|
||||||
public static XPipeApiConnection open() {
|
|
||||||
var con = new XPipeApiConnection();
|
|
||||||
con.constructSocket();
|
|
||||||
return con;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void finishDialog(DialogReference reference) {
|
|
||||||
try (var con = new XPipeApiConnection()) {
|
|
||||||
con.constructSocket();
|
|
||||||
var element = reference.getStart();
|
|
||||||
while (true) {
|
|
||||||
if (element != null && element.requiresExplicitUserInput()) {
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogExchange.Response response = con.performSimpleExchange(DialogExchange.Request.builder()
|
|
||||||
.dialogKey(reference.getDialogId())
|
|
||||||
.build());
|
|
||||||
element = response.getElement();
|
|
||||||
if (response.getElement() == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (BeaconException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new BeaconException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void execute(Handler handler) {
|
|
||||||
try (var con = new XPipeApiConnection()) {
|
|
||||||
con.constructSocket();
|
|
||||||
handler.handle(con);
|
|
||||||
} catch (BeaconException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new BeaconException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T execute(Mapper<T> mapper) {
|
|
||||||
try (var con = new XPipeApiConnection()) {
|
|
||||||
con.constructSocket();
|
|
||||||
return mapper.handle(con);
|
|
||||||
} catch (BeaconException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new BeaconException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<BeaconClient> waitForStartup(Process process) {
|
|
||||||
for (int i = 0; i < 160; i++) {
|
|
||||||
if (process != null && !process.isAlive() && process.exitValue() != 0) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(500);
|
|
||||||
} catch (InterruptedException ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
var s = BeaconClient.tryEstablishConnection(BeaconClient.ApiClientInformation.builder()
|
|
||||||
.version("?")
|
|
||||||
.language("Java")
|
|
||||||
.build());
|
|
||||||
if (s.isPresent()) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void waitForShutdown() {
|
|
||||||
for (int i = 0; i < 40; i++) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(500);
|
|
||||||
} catch (InterruptedException ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
var r = BeaconServer.isReachable();
|
|
||||||
if (!r) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void constructSocket() {
|
|
||||||
if (!BeaconServer.isReachable()) {
|
|
||||||
try {
|
|
||||||
start();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw new BeaconException("Unable to start xpipe daemon", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
var r = waitForStartup(null);
|
|
||||||
if (r.isEmpty()) {
|
|
||||||
throw new BeaconException("Wait for xpipe daemon timed out");
|
|
||||||
} else {
|
|
||||||
beaconClient = r.get();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
beaconClient = BeaconClient.establishConnection(BeaconClient.ApiClientInformation.builder()
|
|
||||||
.version("?")
|
|
||||||
.language("Java")
|
|
||||||
.build());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw new BeaconException("Unable to connect to running xpipe daemon", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void start() throws Exception {
|
|
||||||
var installation = XPipeInstallation.getLocalDefaultInstallationBasePath();
|
|
||||||
BeaconServer.start(installation, XPipeDaemonMode.TRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface Handler {
|
|
||||||
|
|
||||||
void handle(BeaconConnection con);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface Mapper<T> {
|
|
||||||
|
|
||||||
T handle(BeaconConnection con);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package io.xpipe.api.util;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class TypeDescriptor {
|
|
||||||
|
|
||||||
public static String create(List<String> names) {
|
|
||||||
return "[" + names.stream().map(n -> n != null ? "\"" + n + "\"" : null).collect(Collectors.joining(","))
|
|
||||||
+ "]\n";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
module io.xpipe.api {
|
|
||||||
exports io.xpipe.api;
|
|
||||||
exports io.xpipe.api.connector;
|
|
||||||
exports io.xpipe.api.util;
|
|
||||||
|
|
||||||
requires transitive io.xpipe.core;
|
|
||||||
requires io.xpipe.beacon;
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package io.xpipe.api.test;
|
|
||||||
|
|
||||||
import io.xpipe.beacon.test.BeaconDaemonController;
|
|
||||||
import io.xpipe.core.util.XPipeDaemonMode;
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
|
|
||||||
public class ApiTest {
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void setup() throws Exception {
|
|
||||||
BeaconDaemonController.start(XPipeDaemonMode.TRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void teardown() throws Exception {
|
|
||||||
BeaconDaemonController.stop();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package io.xpipe.api.test;
|
|
||||||
|
|
||||||
import io.xpipe.beacon.test.BeaconDaemonController;
|
|
||||||
import io.xpipe.core.util.XPipeDaemonMode;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
public class StartupTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() throws Exception {
|
|
||||||
BeaconDaemonController.start(XPipeDaemonMode.TRAY);
|
|
||||||
BeaconDaemonController.stop();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
module io.xpipe.api.test {
|
|
||||||
requires io.xpipe.api;
|
|
||||||
requires io.xpipe.beacon;
|
|
||||||
requires org.junit.jupiter.api;
|
|
||||||
|
|
||||||
opens io.xpipe.api.test;
|
|
||||||
|
|
||||||
exports io.xpipe.api.test;
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
Username;Identifier ;First name;Last name
|
|
||||||
booker12;9012;Rachel;Booker
|
|
||||||
grey07;2070;Laura;Grey
|
|
||||||
johnson81;4081;Craig;Johnson
|
|
||||||
jenkins46;9346;Mary;Jenkins
|
|
||||||
smith79;5079;Jamie;Smith
|
|
|
|
@ -130,7 +130,6 @@ def replaceVariablesInFile(String f, Map<String, String> replacements) {
|
||||||
|
|
||||||
def testTasks = [
|
def testTasks = [
|
||||||
project(':core').getTasksByName('test', true),
|
project(':core').getTasksByName('test', true),
|
||||||
project(':api').getTasksByName('test', true),
|
|
||||||
project(':app').getTasksByName('test', true),
|
project(':app').getTasksByName('test', true),
|
||||||
project(':base').getTasksByName('localTest', true),
|
project(':base').getTasksByName('localTest', true),
|
||||||
project(':jdbc').getTasksByName('localTest', true),
|
project(':jdbc').getTasksByName('localTest', true),
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
rootProject.name = 'xpipe'
|
rootProject.name = 'xpipe'
|
||||||
|
|
||||||
include 'api'
|
|
||||||
include 'core'
|
include 'core'
|
||||||
include 'beacon'
|
include 'beacon'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue