From b7df6f88c51ce10220bfb332137c9b7d2347cfb5 Mon Sep 17 00:00:00 2001 From: Alex Leigh Date: Sun, 17 Sep 2023 22:43:56 -0700 Subject: [PATCH] lc-esp-viewpoint-service: Added this new module for the Viewpoint service. --- .../main/java/lc/esp/eo/EOTransaction.java | 1 + java/lc-esp-viewpoint-service/build.gradle | 20 +++++++++++++++++ .../viewpoint/service/ViewpointService.java | 22 +++++++++++++++++++ java/settings.gradle | 1 + 4 files changed, 44 insertions(+) create mode 100644 java/lc-esp-viewpoint-service/build.gradle create mode 100644 java/lc-esp-viewpoint-service/src/main/java/lc/esp/viewpoint/service/ViewpointService.java diff --git a/java/lc-esp-eo-engine/src/main/java/lc/esp/eo/EOTransaction.java b/java/lc-esp-eo-engine/src/main/java/lc/esp/eo/EOTransaction.java index 41b3a03d6..2cb30b293 100644 --- a/java/lc-esp-eo-engine/src/main/java/lc/esp/eo/EOTransaction.java +++ b/java/lc-esp-eo-engine/src/main/java/lc/esp/eo/EOTransaction.java @@ -492,6 +492,7 @@ public class EOTransaction implements AutoCloseable { EOId lastId = parentId; Path p = Path.of(path); + // FIXME: Need to check if these are duplicate entries (or get an index?) for (Path part : p) { EOId newId = objAdd(TYPE_INODE); if (bottomDirectory == null) bottomDirectory = newId; diff --git a/java/lc-esp-viewpoint-service/build.gradle b/java/lc-esp-viewpoint-service/build.gradle new file mode 100644 index 000000000..b99d4eb59 --- /dev/null +++ b/java/lc-esp-viewpoint-service/build.gradle @@ -0,0 +1,20 @@ +plugins { + id 'java' +} + +version = '20.0-SNAPSHOT' + +repositories { + mavenCentral() +} + +dependencies { + implementation project(':lc-esp-eo-engine') + implementation project(':lc-esp-engine') + testImplementation platform('org.junit:junit-bom:5.9.1') + testImplementation 'org.junit.jupiter:junit-jupiter' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/java/lc-esp-viewpoint-service/src/main/java/lc/esp/viewpoint/service/ViewpointService.java b/java/lc-esp-viewpoint-service/src/main/java/lc/esp/viewpoint/service/ViewpointService.java new file mode 100644 index 000000000..f5901f294 --- /dev/null +++ b/java/lc-esp-viewpoint-service/src/main/java/lc/esp/viewpoint/service/ViewpointService.java @@ -0,0 +1,22 @@ +package lc.esp.viewpoint.service; + +import lc.esp.engine.ESPEngine; +import lc.mecha.fabric.HandlerStatus; +import lc.mecha.http.server.HttpTransaction; +import lc.mecha.http.server.PrefixedHandler; + +import java.util.Set; + +public class ViewpointService { + public static void main(String[] args) throws Exception { + ESPEngine esp = new ESPEngine(); + esp.register(new PrefixedHandler(Set.of("/api/example")) { + @Override + public HandlerStatus handlePrefixedWebRequest(HttpTransaction request) throws Throwable { + request.httpServletResponse.getOutputStream().write("Hello World\n".getBytes()); + return HandlerStatus.BREAK; + } + }); + esp.runDangerously(); + } +} diff --git a/java/settings.gradle b/java/settings.gradle index bbb5edcb5..fd9f01984 100644 --- a/java/settings.gradle +++ b/java/settings.gradle @@ -30,4 +30,5 @@ include 'lc-esp-engine' include 'lc-esp-example-service' include 'lc-esp-script-engine' include 'lc-esp-eo-service' +include 'lc-esp-viewpoint-service' -- GitLab