diff --git a/lc-esp-sdk/build.gradle b/lc-esp-sdk/build.gradle
index a1e7c6ed692cadda3dd635ad424c0006dcae6e08..390f875efbf3286eb4952fce0ca652ceb83459d4 100644
--- a/lc-esp-sdk/build.gradle
+++ b/lc-esp-sdk/build.gradle
@@ -15,6 +15,7 @@ targetCompatibility = JavaVersion.VERSION_11
dependencies {
api project(':lc-zero-sdk')
+ api project(':lc-eo-json')
// https://mvnrepository.com/artifact/org.apache.activemq/activemq-client
api group: 'org.apache.activemq', name: 'activemq-client', version: '5.17.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
diff --git a/lc-esp-sdk/src/main/java/lc/esp/sdk/ESPMessage.java b/lc-esp-sdk/src/main/java/lc/esp/sdk/ESPMessage.java
index 0553d1995a689c93d28998a7d3fb71e32ecaf2cf..cce9f11223af9bcd11b2925455e38c1189dc5c86 100644
--- a/lc-esp-sdk/src/main/java/lc/esp/sdk/ESPMessage.java
+++ b/lc-esp-sdk/src/main/java/lc/esp/sdk/ESPMessage.java
@@ -1,5 +1,7 @@
package lc.esp.sdk;
+import lc.eo.EO;
+import lc.eo.EOJsonSerializer;
import lc.mecha.json.JSONArray;
import lc.mecha.json.JSONObject;
import lc.mecha.log.MechaLogger;
@@ -127,6 +129,10 @@ public class ESPMessage {
this(payload, null, null);
}
+ public ESPMessage(EO payload) {
+ this(EOJsonSerializer.toJson(payload));
+ }
+
public String getCorrelationId() {
return correlationId;
}
diff --git a/lc-hello-app/build.gradle b/lc-hello-app/build.gradle
index 6ddaee9099d1bf0520b64794f5a597b39a541fb4..21d8a9a4393ae4579d150227b1b72c868912d05f 100644
--- a/lc-hello-app/build.gradle
+++ b/lc-hello-app/build.gradle
@@ -12,6 +12,7 @@ repositories {
dependencies {
implementation project(':lc-esp-sdk')
+ implementation project(':lc-eo-schema')
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
diff --git a/lc-hello-app/src/main/java/lc/hello/app/HelloApp.java b/lc-hello-app/src/main/java/lc/hello/app/HelloApp.java
index d17afbcc918b98da8383b7ddc09c729175128b76..1ca34f777edaed502fe6ede6b8c46df98a798308 100644
--- a/lc-hello-app/src/main/java/lc/hello/app/HelloApp.java
+++ b/lc-hello-app/src/main/java/lc/hello/app/HelloApp.java
@@ -1,7 +1,8 @@
package lc.hello.app;
+import lc.eo.EO;
import lc.esp.sdk.*;
-import lc.mecha.json.JSONObject;
+import lc.hello.app.schema.RequestElementDAO;
import lc.mecha.log.MechaLogger;
import lc.mecha.log.MechaLoggerFactory;
@@ -21,7 +22,11 @@ public class HelloApp {
try (ESPSession session = esp.createSession()) {
ESPConsumer consumer = session.createConsumer(src);
ESPProducer producer = session.createProducer(dst);
- ESPMessage request = new ESPMessage(new JSONObject().put("name", "Alex"));
+
+ EO req = RequestElementDAO.create();
+ RequestElementDAO.setName(req, "Alex");
+
+ ESPMessage request = new ESPMessage(req);
request.setCorrelationId(UUID.randomUUID().toString());
request.setReplyTo(src);
producer.send(request);
diff --git a/lc-hello-app/src/main/java/lc/hello/app/SchemaGenerator.java b/lc-hello-app/src/main/java/lc/hello/app/SchemaGenerator.java
new file mode 100644
index 0000000000000000000000000000000000000000..29b2dfb3cb2a480dc77e3ac76839c9539c258daf
--- /dev/null
+++ b/lc-hello-app/src/main/java/lc/hello/app/SchemaGenerator.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2004-2017, by Alex Leigh.
+ * All rights reserved.
+ *
+ * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
+ * The copyright notice above does not evidence any
+ * actual or intended publication of such source code.
+ */
+
+package lc.hello.app;
+
+import lc.eo.EO;
+import lc.eo.schema.DAOGenerator;
+import lc.eo.schema.ElementElementDAO;
+import lc.eo.schema.SchemaElementDAO;
+import lc.eo.schema.util.AttributeUtil;
+import lc.mecha.log.MechaLogger;
+import lc.mecha.log.MechaLoggerFactory;
+import lc.mecha.util.UniversalJob;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+/**
+ * This class generates the schema^2 (that is, the schema for the schema). In turn this schema can be used to generateJava
+ * the DAO objects for the schema components (Element, Loop, Field, etc). These schema DAOs are used throughout
+ * the ESP codebase.
+ *
+ * @author Alex Leigh
+ */
+public final class SchemaGenerator {
+ private static final MechaLogger logger = MechaLoggerFactory.getLogger(SchemaGenerator.class);
+
+ // Observe the procedures of a general alert
+
+ public static EO generate() {
+ final EO schema = lc.eo.schema.util.SchemaUtil.create("hello.schema");
+
+ final EO helloRequest = ElementElementDAO.create();
+ SchemaElementDAO.getElements(schema).add(helloRequest);
+ ElementElementDAO.setEoType(helloRequest, "hello.request");
+ ElementElementDAO.getAttributes(helloRequest).add(AttributeUtil.create("name", "Name"));
+
+ final EO helloResponse = ElementElementDAO.create();
+ SchemaElementDAO.getElements(schema).add(helloResponse);
+ ElementElementDAO.setEoType(helloResponse, "hello.response");
+ ElementElementDAO.getAttributes(helloResponse).add(AttributeUtil.create("message", "Message"));
+
+ return schema;
+ }
+
+ public static void main(final String... args) throws FileNotFoundException {
+ UniversalJob.banner(logger, "Apotheosis mk3", "2014-2022 Alex Leigh");
+ final EO schema = generate();
+ final DAOGenerator gen = new DAOGenerator(new File("lc-hello-app/src/main/java"));
+ gen.generateJava("lc.hello.app.schema", schema);
+
+ logger.info("Generated schema: {}", schema);
+ }
+}
diff --git a/lc-hello-app/src/main/java/lc/hello/app/schema/RequestElementDAO.java b/lc-hello-app/src/main/java/lc/hello/app/schema/RequestElementDAO.java
new file mode 100644
index 0000000000000000000000000000000000000000..28e35f1dab3602dcf9f683f911f675f202e5df10
--- /dev/null
+++ b/lc-hello-app/src/main/java/lc/hello/app/schema/RequestElementDAO.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2014-2022, by Alex Leigh.
+ * All rights reserved.
+ *
+ * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
+ * The copyright notice above does not evidence any
+ * actual or intended publication of such source code.
+ */
+
+package lc.hello.app.schema;
+
+import lc.eo.EO;
+
+/**
+ * This is a dynamically generated DAO class for accessing objects within an ESP graph. This class
+ * has been generated by DAOGenerator
and should not be modified.
+ *
+ * @author DAOGenerator (synthetically generated class)
+ */
+public final class RequestElementDAO {
+ public static final String API_TYPE = "hello.request";
+
+ public static EO create() {
+ EO eo = new EO(API_TYPE);
+ return eo;
+ }
+
+ public static boolean assertType(final EO eo) {
+ return eo.getApiType().equals(API_TYPE);
+ }
+
+ public static final String KEY_NAME = "name";
+
+ public static String apiType(final EO eo) {
+ return eo.getApiType();
+ }
+
+
+ /* EO{typeName='lc.eo.schema.Field', data={eoType=name, label=EOLoop{array=[EO{typeName='lc.eo.schema.Text', data={text=Name, locale=en}, meta=null}]} , type=string}, meta=null} */
+
+
+ public static java.lang.String getName(EO eo) {
+ if (!assertType(eo))
+ throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
+ return eo.getValueString(KEY_NAME);
+ }
+
+ public static void setName(final EO eo, java.lang.String value) {
+ if (!assertType(eo))
+ throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
+ eo.setValue(KEY_NAME, value);
+ }
+
+ public static void setNameLabel(final EO eo, final String label) {
+ if (!assertType(eo))
+ throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
+ eo.setLabel(KEY_NAME, label);
+ }
+
+ public static void getLabelOrValueName(final EO eo, java.lang.String value) {
+ if (!assertType(eo))
+ throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
+ eo.getLabelOrValue(KEY_NAME);
+ }
+
+ public static void setIfUnsetName(final EO eo, java.lang.String value) {
+ if (!assertType(eo))
+ throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
+ eo.setValueIfUnset(KEY_NAME, value);
+ }
+
+
+}
\ No newline at end of file
diff --git a/lc-hello-app/src/main/java/lc/hello/app/schema/ResponseElementDAO.java b/lc-hello-app/src/main/java/lc/hello/app/schema/ResponseElementDAO.java
new file mode 100644
index 0000000000000000000000000000000000000000..404373c7c8629b37f973ae08cd99a47dc3f4fcbb
--- /dev/null
+++ b/lc-hello-app/src/main/java/lc/hello/app/schema/ResponseElementDAO.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2014-2022, by Alex Leigh.
+ * All rights reserved.
+ *
+ * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
+ * The copyright notice above does not evidence any
+ * actual or intended publication of such source code.
+ */
+
+package lc.hello.app.schema;
+
+import lc.eo.EO;
+
+/**
+ * This is a dynamically generated DAO class for accessing objects within an ESP graph. This class
+ * has been generated by DAOGenerator
and should not be modified.
+ *
+ * @author DAOGenerator (synthetically generated class)
+ */
+public final class ResponseElementDAO {
+ public static final String API_TYPE = "hello.response";
+
+ public static EO create() {
+ EO eo = new EO(API_TYPE);
+ return eo;
+ }
+
+ public static boolean assertType(final EO eo) {
+ return eo.getApiType().equals(API_TYPE);
+ }
+
+ public static final String KEY_MESSAGE = "message";
+
+ public static String apiType(final EO eo) {
+ return eo.getApiType();
+ }
+
+
+ /* EO{typeName='lc.eo.schema.Field', data={eoType=message, label=EOLoop{array=[EO{typeName='lc.eo.schema.Text', data={text=Message, locale=en}, meta=null}]} , type=string}, meta=null} */
+
+
+ public static java.lang.String getMessage(EO eo) {
+ if (!assertType(eo))
+ throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
+ return eo.getValueString(KEY_MESSAGE);
+ }
+
+ public static void setMessage(final EO eo, java.lang.String value) {
+ if (!assertType(eo))
+ throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
+ eo.setValue(KEY_MESSAGE, value);
+ }
+
+ public static void setMessageLabel(final EO eo, final String label) {
+ if (!assertType(eo))
+ throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
+ eo.setLabel(KEY_MESSAGE, label);
+ }
+
+ public static void getLabelOrValueMessage(final EO eo, java.lang.String value) {
+ if (!assertType(eo))
+ throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
+ eo.getLabelOrValue(KEY_MESSAGE);
+ }
+
+ public static void setIfUnsetMessage(final EO eo, java.lang.String value) {
+ if (!assertType(eo))
+ throw new IllegalArgumentException("Mismatched EO type: [found: " + eo.getApiType() + "] [expected: " + API_TYPE + "]");
+ eo.setValueIfUnset(KEY_MESSAGE, value);
+ }
+
+
+}
\ No newline at end of file
diff --git a/lc-hello-svc/build.gradle b/lc-hello-svc/build.gradle
index 6ddaee9099d1bf0520b64794f5a597b39a541fb4..9f86fa741bcc713a24a5e90e78c52216bec095e6 100644
--- a/lc-hello-svc/build.gradle
+++ b/lc-hello-svc/build.gradle
@@ -12,6 +12,7 @@ repositories {
dependencies {
implementation project(':lc-esp-sdk')
+ implementation project(':lc-hello-app')
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}