From aaf07d251cbc228ec047fcd726d4b1d8df067572 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 10 Apr 2023 08:20:56 +0000 Subject: [PATCH 001/228] updating poms for 9.0.2-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 95f320347..6864637dd 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.1-SNAPSHOT + 9.0.2-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index d3a93a0df..d504b83a2 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.1-SNAPSHOT + 9.0.2-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 61dd8604b..ecdc01106 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.1-SNAPSHOT + 9.0.2-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 41e86bcf3..823ff2128 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.1-SNAPSHOT + 9.0.2-SNAPSHOT ../parent-root/pom.xml From 2b4cebb51bef6e01cafc09b0cc7cdca94cacb54e Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 10 Apr 2023 08:24:06 +0000 Subject: [PATCH 002/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 6864637dd..04631cc0a 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.2-SNAPSHOT + 9.0.1 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index d504b83a2..c0720c1e1 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.2-SNAPSHOT + 9.0.1 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index ecdc01106..abee28910 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.2-SNAPSHOT + 9.0.1 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 823ff2128..c05ff6b3d 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.2-SNAPSHOT + 9.0.1 ../parent-root/pom.xml From a377ade060138c43f58d9660a697101b50b96b7b Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 10 Apr 2023 08:24:07 +0000 Subject: [PATCH 003/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 04631cc0a..6864637dd 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.1 + 9.0.2-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index c0720c1e1..d504b83a2 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.1 + 9.0.2-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index abee28910..ecdc01106 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.1 + 9.0.2-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index c05ff6b3d..823ff2128 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.1 + 9.0.2-SNAPSHOT ../parent-root/pom.xml From 41477b53bd8b332f5a853ff7e7b4ee961d99994b Mon Sep 17 00:00:00 2001 From: command-line Date: Mon, 10 Apr 2023 21:24:25 +0100 Subject: [PATCH 004/228] update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 108cf73bd..959eeaa1d 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ [![Github build](https://github.com/v12technology/fluxtion/workflows/MavenCI/badge.svg)](https://github.com/v12technology/fluxtion/actions) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/runtime/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/runtime) +## [User documentation](https://v12technology.github.io/fluxtion/) # Lightweight event stream processor - Pure java in memory complex event processing From ea6b06b9424a0901ba12f247167571ab35981195 Mon Sep 17 00:00:00 2001 From: greg higgins Date: Wed, 24 May 2023 07:03:24 +0100 Subject: [PATCH 005/228] add audit log support to Lifecycle methods (#231) Co-authored-by: command-line --- .../targets/InMemoryEventProcessor.java | 12 ++ .../resources/template/base/javaTemplate.vsl | 14 ++- .../generation/afterevent/PostEventTest.java | 2 + .../generation/audit/FactoryAuditorTest.java | 2 +- .../generation/audit/LifecycleAuditTest.java | 105 ++++++++++++++++++ .../bufferevent/BufferEventGeneratedTest.java | 10 +- .../subclass/EventHandlerSubClassTest.java | 10 +- .../fluxtion/runtime/lifecycle/Lifecycle.java | 2 + 8 files changed, 145 insertions(+), 12 deletions(-) create mode 100644 compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java index 0db085996..eb64db16e 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java @@ -281,12 +281,16 @@ private void auditNewEvent(Object event) { @Override public void batchPause() { + auditNewEvent(Name.BatchPause); simpleEventProcessorModel.getBatchPauseMethods().forEach(this::invokeRunnable); + postEventProcessing(); } @Override public void batchEnd() { + auditNewEvent(Name.BatchEnd); simpleEventProcessorModel.getBatchEndMethods().forEach(this::invokeRunnable); + postEventProcessing(); } @Override @@ -312,7 +316,9 @@ public void removeEventFeed(EventFeed eventProcessorFeed) { public void init() { initCalled = true; buildDispatch(); + auditNewEvent(Name.Init); simpleEventProcessorModel.getInitialiseMethods().forEach(this::invokeRunnable); + postEventProcessing(); } @Override @@ -320,7 +326,9 @@ public void start() { if (!initCalled) { throw new RuntimeException("init() must be called before start()"); } + auditNewEvent(Name.Start); simpleEventProcessorModel.getStartMethods().forEach(this::invokeRunnable); + postEventProcessing(); } @Override @@ -328,13 +336,17 @@ public void stop() { if (!initCalled) { throw new RuntimeException("init() must be called before start()"); } + auditNewEvent(Name.Stop); simpleEventProcessorModel.getStopMethods().forEach(this::invokeRunnable); + postEventProcessing(); } @Override public void tearDown() { initCalled = false; + auditNewEvent(Name.TearDown); simpleEventProcessorModel.getTearDownMethods().forEach(this::invokeRunnable); + postEventProcessing(); } diff --git a/compiler/src/main/resources/template/base/javaTemplate.vsl b/compiler/src/main/resources/template/base/javaTemplate.vsl index 0a8a19129..68b1d8ab5 100644 --- a/compiler/src/main/resources/template/base/javaTemplate.vsl +++ b/compiler/src/main/resources/template/base/javaTemplate.vsl @@ -111,9 +111,11 @@ private final IdentityHashMap> dirtyFlagUpdateMap = ne @Override public void init() { initCalled = true; + auditEvent(Lifecycle.Name.Init); //initialise dirty lookup map isDirty("test"); ${MODEL.initialiseMethods} + afterEvent(); } @Override @@ -121,7 +123,9 @@ private final IdentityHashMap> dirtyFlagUpdateMap = ne if(!initCalled){ throw new RuntimeException("init() must be called before start()"); } + auditEvent(Lifecycle.Name.Start); ${MODEL.startMethods} + afterEvent(); } @Override @@ -129,23 +133,31 @@ private final IdentityHashMap> dirtyFlagUpdateMap = ne if(!initCalled){ throw new RuntimeException("init() must be called before stop()"); } + auditEvent(Lifecycle.Name.Stop); ${MODEL.stopMethods} + afterEvent(); } @Override public void tearDown() { initCalled = false; - ${MODEL.tearDownMethods} + auditEvent(Lifecycle.Name.TearDown); + ${MODEL.tearDownMethods} + afterEvent(); } @Override public void batchPause() { + auditEvent(Lifecycle.Name.BatchPause); ${MODEL.batchPauseMethods} + afterEvent(); } @Override public void batchEnd() { + auditEvent(Lifecycle.Name.BatchEnd); ${MODEL.batchEndMethods} + afterEvent(); } @Override diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/afterevent/PostEventTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/afterevent/PostEventTest.java index d2771e073..5bb492169 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/afterevent/PostEventTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/afterevent/PostEventTest.java @@ -42,6 +42,8 @@ public void afterEventTest() { onEvent("helloWorld"); assertThat(postInvocationTrace, is( Arrays.asList( + "Child::afterEvent", + "Parent::afterEvent", "Parent::newEvent", "Child::onEvent", "Child::eventComplete", diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/audit/FactoryAuditorTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/audit/FactoryAuditorTest.java index b529b6735..77ea6dbdb 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/audit/FactoryAuditorTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/audit/FactoryAuditorTest.java @@ -37,7 +37,7 @@ public void test() { MyNode myNode = getAuditor("myNode"); Assert.assertTrue(myNode.registerCalled); onEvent(new CharEvent('a')); - assertThat(myNode.eventAuditCount, is(1)); + assertThat(myNode.eventAuditCount, is(2)); } public static class ParentNode { diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java new file mode 100644 index 000000000..f52801807 --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java @@ -0,0 +1,105 @@ +package com.fluxtion.compiler.generation.audit; + +import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; +import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; +import com.fluxtion.runtime.annotations.Initialise; +import com.fluxtion.runtime.annotations.OnEventHandler; +import com.fluxtion.runtime.annotations.Start; +import com.fluxtion.runtime.annotations.Stop; +import com.fluxtion.runtime.annotations.TearDown; +import com.fluxtion.runtime.audit.EventLogNode; +import com.fluxtion.runtime.audit.LogRecord; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +public class LifecycleAuditTest extends MultipleSepTargetInProcessTest { + public LifecycleAuditTest(SepTestConfig testConfig) { + super(testConfig); + } + + @Test + public void lifecycleLog() { + List logSink = new ArrayList<>(); + addAuditor(); + sep(c -> c.addNode(new MyNode(new Parent()))); + sep.setAuditLogProcessor(logSink::add); + logSink.clear(); + start(); + Assert.assertEquals(1, logSink.size()); + onEvent("test"); + Assert.assertEquals(2, logSink.size()); + onEvent("test2"); + Assert.assertEquals(3, logSink.size()); + stop(); + Assert.assertEquals(4, logSink.size()); + tearDown(); + Assert.assertEquals(5, logSink.size()); + } + + public static class Parent extends EventLogNode { + @Initialise + public void init() { + auditLog.info("lifecycle", "init"); + } + + @Start + public void start() { + auditLog.info("lifecycle", "started"); + } + + @Stop + public void stop() { + auditLog.info("lifecycle", "stop"); + } + + @TearDown + public void teardown() { + auditLog.info("lifecycle", "teardown"); + } + + @OnEventHandler + public boolean eventHandler(String in) { + auditLog.info("lifecycle", "eventHandler"); + return false; + } + } + + public static class MyNode extends EventLogNode { + + private final Parent parent; + + public MyNode(Parent parent) { + this.parent = parent; + } + + @Initialise + public void init() { + auditLog.info("lifecycle", "init"); + } + + @Start + public void start() { + auditLog.info("lifecycle", "started"); + } + + @Stop + public void stop() { + auditLog.info("lifecycle", "stop"); + } + + @TearDown + public void teardown() { + auditLog.info("lifecycle", "teardown"); + } + + @OnEventHandler + public boolean eventHandler(String in) { + auditLog.info("lifecycle", "eventHandler"); + return false; + } + + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/bufferevent/BufferEventGeneratedTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/bufferevent/BufferEventGeneratedTest.java index b5d1f561b..16df7e377 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/bufferevent/BufferEventGeneratedTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/bufferevent/BufferEventGeneratedTest.java @@ -38,7 +38,7 @@ public void triggeredOnlyCbListTest() { MatcherAssert.assertThat(child.triggerCount, CoreMatchers.is(0)); //parent MatcherAssert.assertThat(eventHolder.eventCount, CoreMatchers.is(3)); - MatcherAssert.assertThat(eventHolder.afterEventCount, CoreMatchers.is(0)); + MatcherAssert.assertThat(eventHolder.afterEventCount, CoreMatchers.is(1)); MatcherAssert.assertThat(eventHolder.afterTriggerCount, CoreMatchers.is(0)); @@ -50,7 +50,7 @@ public void triggeredOnlyCbListTest() { MatcherAssert.assertThat(child.triggerCount, CoreMatchers.is(0)); //parent MatcherAssert.assertThat(eventHolder.eventCount, CoreMatchers.is(3)); - MatcherAssert.assertThat(eventHolder.afterEventCount, CoreMatchers.is(0)); + MatcherAssert.assertThat(eventHolder.afterEventCount, CoreMatchers.is(1)); MatcherAssert.assertThat(eventHolder.afterTriggerCount, CoreMatchers.is(0)); @@ -61,7 +61,7 @@ public void triggeredOnlyCbListTest() { MatcherAssert.assertThat(child.triggerCount, CoreMatchers.is(1)); //parent MatcherAssert.assertThat(eventHolder.eventCount, CoreMatchers.is(3)); - MatcherAssert.assertThat(eventHolder.afterEventCount, CoreMatchers.is(1)); + MatcherAssert.assertThat(eventHolder.afterEventCount, CoreMatchers.is(2)); MatcherAssert.assertThat(eventHolder.afterTriggerCount, CoreMatchers.is(1)); } @@ -82,12 +82,12 @@ public void noTriggerClassWithAfterTest() { bufferEvent("test"); EventHolder eventHolder = getField("eventHolder"); MatcherAssert.assertThat(eventHolder.eventCount, CoreMatchers.is(3)); - MatcherAssert.assertThat(eventHolder.afterEventCount, CoreMatchers.is(0)); + MatcherAssert.assertThat(eventHolder.afterEventCount, CoreMatchers.is(1)); MatcherAssert.assertThat(eventHolder.afterTriggerCount, CoreMatchers.is(0)); triggerCalculation(); MatcherAssert.assertThat(eventHolder.eventCount, CoreMatchers.is(3)); - MatcherAssert.assertThat(eventHolder.afterEventCount, CoreMatchers.is(1)); + MatcherAssert.assertThat(eventHolder.afterEventCount, CoreMatchers.is(2)); MatcherAssert.assertThat(eventHolder.afterTriggerCount, CoreMatchers.is(1)); } diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/subclass/EventHandlerSubClassTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/subclass/EventHandlerSubClassTest.java index 8156cb3ac..717977570 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/subclass/EventHandlerSubClassTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/subclass/EventHandlerSubClassTest.java @@ -49,19 +49,19 @@ public void testSubClassOnEvent() { //init assertThat(node.eventCount, is(0)); assertThat(node.initCount, is(1)); - assertThat(node.afterEvent, is(0)); + assertThat(node.afterEvent, is(1)); assertThat(node.batchEnd, is(0)); assertThat(node.batchPause, is(0)); assertThat(node.tearDownCount, is(0)); //event + after event onEvent("test string"); assertThat(node.eventCount, is(1)); - assertThat(node.afterEvent, is(1)); + assertThat(node.afterEvent, is(2)); //batch pause batchPause(); assertThat(node.eventCount, is(1)); assertThat(node.initCount, is(1)); - assertThat(node.afterEvent, is(1)); + assertThat(node.afterEvent, is(3)); assertThat(node.batchEnd, is(0)); assertThat(node.batchPause, is(1)); assertThat(node.tearDownCount, is(0)); @@ -69,7 +69,7 @@ public void testSubClassOnEvent() { batchEnd(); assertThat(node.eventCount, is(1)); assertThat(node.initCount, is(1)); - assertThat(node.afterEvent, is(1)); + assertThat(node.afterEvent, is(4)); assertThat(node.batchEnd, is(1)); assertThat(node.batchPause, is(1)); assertThat(node.tearDownCount, is(0)); @@ -77,7 +77,7 @@ public void testSubClassOnEvent() { tearDown(); assertThat(node.eventCount, is(1)); assertThat(node.initCount, is(1)); - assertThat(node.afterEvent, is(1)); + assertThat(node.afterEvent, is(5)); assertThat(node.batchEnd, is(1)); assertThat(node.batchPause, is(1)); assertThat(node.tearDownCount, is(1)); diff --git a/runtime/src/main/java/com/fluxtion/runtime/lifecycle/Lifecycle.java b/runtime/src/main/java/com/fluxtion/runtime/lifecycle/Lifecycle.java index 46794fb6d..ebd950bb6 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/lifecycle/Lifecycle.java +++ b/runtime/src/main/java/com/fluxtion/runtime/lifecycle/Lifecycle.java @@ -64,4 +64,6 @@ default void start() { */ default void stop() { } + + enum Name {Init, TearDown, Start, Stop, BatchPause, BatchEnd} } From 234668dc54e28e63304a7f95df0ae686d2b3328c Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 24 May 2023 06:20:37 +0000 Subject: [PATCH 006/228] updating poms for 9.0.3-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 6864637dd..427aca3cb 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.2-SNAPSHOT + 9.0.3-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index d504b83a2..cefca5d3f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.2-SNAPSHOT + 9.0.3-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index ecdc01106..3a5d7dda9 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.2-SNAPSHOT + 9.0.3-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 823ff2128..06d71aeb1 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.2-SNAPSHOT + 9.0.3-SNAPSHOT ../parent-root/pom.xml From b0214fa6655da8e353a6b67f4adaf755e79c3dcf Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 24 May 2023 06:20:41 +0000 Subject: [PATCH 007/228] updating poms for branch'release/9.0.2' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 6864637dd..ef92fbd90 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.2-SNAPSHOT + 9.0.2 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index d504b83a2..137edf51c 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.2-SNAPSHOT + 9.0.2 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index ecdc01106..cf2c1b65e 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.2-SNAPSHOT + 9.0.2 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 823ff2128..ad53f21bc 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.2-SNAPSHOT + 9.0.2 ../parent-root/pom.xml From d1353039ca13eff90a7c9dc8b91473b49b905898 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 24 May 2023 06:24:20 +0000 Subject: [PATCH 008/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 427aca3cb..ef92fbd90 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.3-SNAPSHOT + 9.0.2 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index cefca5d3f..137edf51c 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.3-SNAPSHOT + 9.0.2 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 3a5d7dda9..cf2c1b65e 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.3-SNAPSHOT + 9.0.2 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 06d71aeb1..ad53f21bc 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.3-SNAPSHOT + 9.0.2 ../parent-root/pom.xml From 3c431e8735d139a29a14186e04ea90f471929d23 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 24 May 2023 06:24:20 +0000 Subject: [PATCH 009/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index ef92fbd90..427aca3cb 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.2 + 9.0.3-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 137edf51c..cefca5d3f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.2 + 9.0.3-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index cf2c1b65e..3a5d7dda9 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.2 + 9.0.3-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index ad53f21bc..06d71aeb1 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.2 + 9.0.3-SNAPSHOT ../parent-root/pom.xml From eac092b9c5f793e80567be311e5a62e87de18e06 Mon Sep 17 00:00:00 2001 From: greg higgins Date: Wed, 24 May 2023 10:55:25 +0100 Subject: [PATCH 010/228] Feature/233 lifecycle support re entrancy (#234) * rename Lifecycle.LifecycleEvent for better logging * support re-entrant event processing from lifecycle methods start, stop, batchPause and batchEnd fixes #233 --------- Co-authored-by: command-line --- .../targets/InMemoryEventProcessor.java | 24 ++++++--- .../resources/template/base/javaTemplate.vsl | 32 ++++++++---- .../generation/reentrant/ReEntrantTest.java | 51 +++++++++++++++++++ .../fluxtion/runtime/lifecycle/Lifecycle.java | 2 +- 4 files changed, 92 insertions(+), 17 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java index eb64db16e..b76da2183 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java @@ -281,16 +281,22 @@ private void auditNewEvent(Object event) { @Override public void batchPause() { - auditNewEvent(Name.BatchPause); + processing = true; + auditNewEvent(LifecycleEvent.BatchPause); simpleEventProcessorModel.getBatchPauseMethods().forEach(this::invokeRunnable); postEventProcessing(); + callbackDispatcher.dispatchQueuedCallbacks(); + processing = false; } @Override public void batchEnd() { - auditNewEvent(Name.BatchEnd); + processing = true; + auditNewEvent(LifecycleEvent.BatchEnd); simpleEventProcessorModel.getBatchEndMethods().forEach(this::invokeRunnable); postEventProcessing(); + callbackDispatcher.dispatchQueuedCallbacks(); + processing = false; } @Override @@ -316,7 +322,7 @@ public void removeEventFeed(EventFeed eventProcessorFeed) { public void init() { initCalled = true; buildDispatch(); - auditNewEvent(Name.Init); + auditNewEvent(LifecycleEvent.Init); simpleEventProcessorModel.getInitialiseMethods().forEach(this::invokeRunnable); postEventProcessing(); } @@ -326,9 +332,12 @@ public void start() { if (!initCalled) { throw new RuntimeException("init() must be called before start()"); } - auditNewEvent(Name.Start); + processing = true; + auditNewEvent(LifecycleEvent.Start); simpleEventProcessorModel.getStartMethods().forEach(this::invokeRunnable); postEventProcessing(); + callbackDispatcher.dispatchQueuedCallbacks(); + processing = false; } @Override @@ -336,15 +345,18 @@ public void stop() { if (!initCalled) { throw new RuntimeException("init() must be called before start()"); } - auditNewEvent(Name.Stop); + processing = true; + auditNewEvent(LifecycleEvent.Stop); simpleEventProcessorModel.getStopMethods().forEach(this::invokeRunnable); postEventProcessing(); + callbackDispatcher.dispatchQueuedCallbacks(); + processing = false; } @Override public void tearDown() { initCalled = false; - auditNewEvent(Name.TearDown); + auditNewEvent(LifecycleEvent.TearDown); simpleEventProcessorModel.getTearDownMethods().forEach(this::invokeRunnable); postEventProcessing(); } diff --git a/compiler/src/main/resources/template/base/javaTemplate.vsl b/compiler/src/main/resources/template/base/javaTemplate.vsl index 68b1d8ab5..e636f5ddd 100644 --- a/compiler/src/main/resources/template/base/javaTemplate.vsl +++ b/compiler/src/main/resources/template/base/javaTemplate.vsl @@ -111,7 +111,7 @@ private final IdentityHashMap> dirtyFlagUpdateMap = ne @Override public void init() { initCalled = true; - auditEvent(Lifecycle.Name.Init); + auditEvent(Lifecycle.LifecycleEvent.Init); //initialise dirty lookup map isDirty("test"); ${MODEL.initialiseMethods} @@ -123,9 +123,12 @@ private final IdentityHashMap> dirtyFlagUpdateMap = ne if(!initCalled){ throw new RuntimeException("init() must be called before start()"); } - auditEvent(Lifecycle.Name.Start); + processing = true; + auditEvent(Lifecycle.LifecycleEvent.Start); ${MODEL.startMethods} afterEvent(); + callbackDispatcher.dispatchQueuedCallbacks(); + processing = false; } @Override @@ -133,31 +136,40 @@ private final IdentityHashMap> dirtyFlagUpdateMap = ne if(!initCalled){ throw new RuntimeException("init() must be called before stop()"); } - auditEvent(Lifecycle.Name.Stop); + processing = true; + auditEvent(Lifecycle.LifecycleEvent.Stop); ${MODEL.stopMethods} afterEvent(); + callbackDispatcher.dispatchQueuedCallbacks(); + processing = false; } @Override public void tearDown() { initCalled = false; - auditEvent(Lifecycle.Name.TearDown); + auditEvent(Lifecycle.LifecycleEvent.TearDown); ${MODEL.tearDownMethods} afterEvent(); } @Override public void batchPause() { - auditEvent(Lifecycle.Name.BatchPause); - ${MODEL.batchPauseMethods} - afterEvent(); + auditEvent(Lifecycle.LifecycleEvent.BatchPause); + processing = true; + ${MODEL.batchPauseMethods} + afterEvent(); + callbackDispatcher.dispatchQueuedCallbacks(); + processing = false; } @Override public void batchEnd() { - auditEvent(Lifecycle.Name.BatchEnd); - ${MODEL.batchEndMethods} - afterEvent(); + auditEvent(Lifecycle.LifecycleEvent.BatchEnd); + processing = true; + ${MODEL.batchEndMethods} + afterEvent(); + callbackDispatcher.dispatchQueuedCallbacks(); + processing = false; } @Override diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/reentrant/ReEntrantTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/reentrant/ReEntrantTest.java index cdd6155c4..7bd805fae 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/reentrant/ReEntrantTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/reentrant/ReEntrantTest.java @@ -3,6 +3,12 @@ import com.fluxtion.compiler.builder.dataflow.DataFlow; import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; +import com.fluxtion.runtime.annotations.OnEventHandler; +import com.fluxtion.runtime.annotations.Start; +import com.fluxtion.runtime.annotations.Stop; +import com.fluxtion.runtime.annotations.builder.Inject; +import com.fluxtion.runtime.callback.EventDispatcher; +import com.fluxtion.runtime.output.SinkPublisher; import org.junit.Test; import java.util.ArrayList; @@ -46,4 +52,49 @@ public void queueEventsInOrderTest() { assertThat(results, is(expected)); } + + @Test + public void queueStartReentrantTest() { + List results = new ArrayList<>(); + sep(c -> { + c.addNode(new StartClass()); + }); + addSink("lifecycleSink", (String s) -> results.add(s)); + onEvent("event1"); + start(); + stop(); + + List expected = Arrays.asList( + "event1", + "started", "reentrant-start", + "stopped", "reentrant-stop" + ); + + assertThat(results, is(expected)); + } + + public static class StartClass { + public SinkPublisher publisher = new SinkPublisher<>("lifecycleSink"); + @Inject + public EventDispatcher dispatcher; + + @Start + public void start() { + dispatcher.processAsNewEventCycle("reentrant-start"); + publisher.publish("started"); + } + + @Stop + public void stop() { + dispatcher.processAsNewEventCycle("reentrant-stop"); + publisher.publish("stopped"); + } + + @OnEventHandler + public boolean stringUpdate(String in) { + publisher.publish(in); + return false; + } + + } } diff --git a/runtime/src/main/java/com/fluxtion/runtime/lifecycle/Lifecycle.java b/runtime/src/main/java/com/fluxtion/runtime/lifecycle/Lifecycle.java index ebd950bb6..01265d800 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/lifecycle/Lifecycle.java +++ b/runtime/src/main/java/com/fluxtion/runtime/lifecycle/Lifecycle.java @@ -65,5 +65,5 @@ default void start() { default void stop() { } - enum Name {Init, TearDown, Start, Stop, BatchPause, BatchEnd} + enum LifecycleEvent {Init, TearDown, Start, Stop, BatchPause, BatchEnd} } From efe8cde12ca2ab219a54d83160bdb80019fb267f Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 24 May 2023 10:01:22 +0000 Subject: [PATCH 011/228] updating poms for 9.0.4-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 427aca3cb..c207b09ec 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.3-SNAPSHOT + 9.0.4-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index cefca5d3f..8f0ff8b32 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.3-SNAPSHOT + 9.0.4-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 3a5d7dda9..d5cade235 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.3-SNAPSHOT + 9.0.4-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 06d71aeb1..96f7f1297 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.3-SNAPSHOT + 9.0.4-SNAPSHOT ../parent-root/pom.xml From 3619310909fb816dc2259d5e4c03d21f57f55cea Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 24 May 2023 10:01:26 +0000 Subject: [PATCH 012/228] updating poms for branch'release/9.0.3' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 427aca3cb..0785b1c85 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.3-SNAPSHOT + 9.0.3 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index cefca5d3f..1905898af 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.3-SNAPSHOT + 9.0.3 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 3a5d7dda9..0824d5c58 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.3-SNAPSHOT + 9.0.3 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 06d71aeb1..c01d06e7f 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.3-SNAPSHOT + 9.0.3 ../parent-root/pom.xml From b432c08a76089e4bffd7eb3b53010f2354150551 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 24 May 2023 10:06:40 +0000 Subject: [PATCH 013/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c207b09ec..0785b1c85 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.4-SNAPSHOT + 9.0.3 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 8f0ff8b32..1905898af 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.4-SNAPSHOT + 9.0.3 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index d5cade235..0824d5c58 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.4-SNAPSHOT + 9.0.3 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 96f7f1297..c01d06e7f 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.4-SNAPSHOT + 9.0.3 ../parent-root/pom.xml From c45c067d3fd4be0956029ac5564722d68d305a1f Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 24 May 2023 10:06:41 +0000 Subject: [PATCH 014/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 0785b1c85..c207b09ec 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.3 + 9.0.4-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 1905898af..8f0ff8b32 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.3 + 9.0.4-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 0824d5c58..d5cade235 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.3 + 9.0.4-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index c01d06e7f..96f7f1297 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.3 + 9.0.4-SNAPSHOT ../parent-root/pom.xml From 76c7a6707f8e3ff0d01a53bf858418aaa86665c6 Mon Sep 17 00:00:00 2001 From: greg higgins Date: Sun, 28 May 2023 11:52:48 +0100 Subject: [PATCH 015/228] Feature/235 dataflow merge and no argument filter (#236) * closes #235 filter with no arg predicate. Static functions for DataFlow.merge. Refactor some tests * fix assign to function for MergeFlowFunction --------- Co-authored-by: command-line --- .../builder/dataflow/AbstractFlowBuilder.java | 6 + .../compiler/builder/dataflow/DataFlow.java | 25 ++++ .../fluxtion/compiler/builder/PricerTest.java | 110 ++++++++++++++++++ .../dataflow/EventStreamBuildTest.java | 8 -- .../compiler/builder/dataflow/FilterTest.java | 63 +++++++++- .../compiler/builder/dataflow/MergeTest.java | 62 ++++++++++ .../forkjoin/ForkJoinDataFlowTest.java | 7 +- .../dataflow/function/MergeFlowFunction.java | 5 +- .../runtime/dataflow/helpers/Predicates.java | 11 +- 9 files changed, 280 insertions(+), 17 deletions(-) create mode 100644 compiler/src/test/java/com/fluxtion/compiler/builder/PricerTest.java create mode 100644 compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/MergeTest.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/AbstractFlowBuilder.java b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/AbstractFlowBuilder.java index 91963f344..ea8bf5f05 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/AbstractFlowBuilder.java +++ b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/AbstractFlowBuilder.java @@ -16,11 +16,13 @@ import com.fluxtion.runtime.dataflow.function.PushFlowFunction; import com.fluxtion.runtime.dataflow.helpers.InternalEventDispatcher; import com.fluxtion.runtime.dataflow.helpers.Peekers; +import com.fluxtion.runtime.dataflow.helpers.Predicates.PredicateWrapper; import com.fluxtion.runtime.output.SinkPublisher; import com.fluxtion.runtime.partition.LambdaReflection; import com.fluxtion.runtime.partition.LambdaReflection.SerializableBiFunction; import com.fluxtion.runtime.partition.LambdaReflection.SerializableConsumer; import com.fluxtion.runtime.partition.LambdaReflection.SerializableFunction; +import com.fluxtion.runtime.partition.LambdaReflection.SerializableSupplier; public abstract class AbstractFlowBuilder> { @@ -68,6 +70,10 @@ public B filter(SerializableFunction filterFunction) { return connect(new FilterFlowFunction<>(eventStream, filterFunction)); } + public B filter(SerializableSupplier filterFunction) { + return filter(new PredicateWrapper(filterFunction)::test); + } + public

B filterByProperty(SerializableFunction accessor, SerializableFunction filterFunction) { return connect(new FilterByPropertyFlowFunction<>(eventStream, accessor, filterFunction)); } diff --git a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/DataFlow.java b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/DataFlow.java index 3b3913feb..050bed310 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/DataFlow.java +++ b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/DataFlow.java @@ -197,4 +197,29 @@ static FlowBuilder mergeMap(MergeAndMapFlowBuilder builder) { MergeMapFlowFunction build = builder.build(); return new FlowBuilder<>(build); } + + /** + * Merges two {@link FlowBuilder}'s into a single event stream of type T + * + * @param streamAToMerge stream A to merge + * @param streamBToMerge stream B to merge + * @param type of stream A + * @param type of stream B + * @return An {@link FlowBuilder} that can used to construct stream processing logic + */ + static FlowBuilder merge(FlowBuilder streamAToMerge, FlowBuilder streamBToMerge) { + return streamAToMerge.merge(streamBToMerge); + } + + @SuppressWarnings("unchecked") + static FlowBuilder merge( + FlowBuilder streamAToMerge, + FlowBuilder streamBToMerge, + FlowBuilder... streamsToMerge) { + FlowBuilder mergedStream = streamAToMerge.merge(streamBToMerge); + for (FlowBuilder streamToMerge : streamsToMerge) { + mergedStream = mergedStream.merge(streamToMerge); + } + return mergedStream; + } } diff --git a/compiler/src/test/java/com/fluxtion/compiler/builder/PricerTest.java b/compiler/src/test/java/com/fluxtion/compiler/builder/PricerTest.java new file mode 100644 index 000000000..5a293036b --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/builder/PricerTest.java @@ -0,0 +1,110 @@ +package com.fluxtion.compiler.builder; + +import com.fluxtion.compiler.builder.dataflow.DataFlow; +import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; +import com.fluxtion.compiler.generation.util.CompiledOnlySepTest; +import com.fluxtion.runtime.annotations.OnTrigger; +import com.fluxtion.runtime.time.FixedRateTrigger; +import lombok.Data; +import org.junit.Test; + +public class PricerTest extends CompiledOnlySepTest { + public PricerTest(SepTestConfig compile) { + super(compile); + } + + @Test + public void pricer() { + writeOutputsToFile(true); + sep(c -> { + ParamsChecker checker = new ParamsChecker(); + PriceCalc priceCalc = new PriceCalc(); + StepAway stepAway = new StepAway(); + + + DataFlow.subscribe(MktData.class) + .filter(checker::paramsValid) + .map(priceCalc::marketUpdate) + .merge( + DataFlow.subscribe(Position.class) + .filter(checker::paramsValid) + .map(priceCalc::posUpdate) + ) + .filter(PricerTest::sanityCheck) + .map(stepAway::applyStepaway) + .filter(new ThrottlePublisher()::canPublish); + + + }); + + } + + public static boolean sanityCheck(PriceLadder priceLadder) { + return true; + } + + public static class StepAway { + + public FixedRateTrigger rollTrigger; + + public PriceLadder applyStepaway(PriceLadder priceLadder) { + return priceLadder; + } + + } + + public static class ThrottlePublisher { + public boolean canPublish(Object o) { + return true; + } + } + + @Data + public static class PriceCalc { + + MktData mktData; + Position position; + + public PriceLadder marketUpdate(MktData mktData) { + return null; + } + + public PriceLadder posUpdate(Position position) { + return null; + } + + public PriceLadder calc() { + return null; + } + + @OnTrigger + public boolean calcTrigger() { + return true; + } + + } + + @Data + public static class PriceLadder { + + } + + @Data + public static class MktData { + String symbol; + double mid; + } + + @Data + public static class Position { + String book; + double value; + } + + public static class ParamsChecker { + + public boolean paramsValid(Object o) { + return true; + } + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/EventStreamBuildTest.java b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/EventStreamBuildTest.java index 7114c7580..2559511c0 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/EventStreamBuildTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/EventStreamBuildTest.java @@ -986,14 +986,6 @@ public static PostMap mapToPostMap(PreMap preMap, String lookupValue) { return new PostMap(preMap.getName(), lookupValue); } - public static boolean isTrue(String in) { - return Boolean.parseBoolean(in); - } - - public static boolean gt5(int val) { - return val > 5; - } - public static int parseInt(String in) { return Integer.parseInt(in); } diff --git a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/FilterTest.java b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/FilterTest.java index 62be32e0e..14d63e969 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/FilterTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/FilterTest.java @@ -8,6 +8,9 @@ import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; import com.fluxtion.runtime.dataflow.helpers.Mappers; import com.fluxtion.runtime.dataflow.helpers.Predicates; +import com.fluxtion.runtime.node.SingleNamedNode; +import lombok.Getter; +import lombok.Setter; import org.junit.Assert; import org.junit.Test; @@ -24,7 +27,7 @@ public FilterTest(SepTestConfig compiledSep) { @Test public void filterTest() { sep(c -> subscribe(String.class) - .filter(EventStreamBuildTest::isTrue) + .filter(FilterTest::isTrue) .notify(new NotifyAndPushTarget()) ); NotifyAndPushTarget notifyTarget = getField("notifyTarget"); @@ -35,10 +38,43 @@ public void filterTest() { assertThat(notifyTarget.getOnEventCount(), is(1)); } + @Test + public void filterInstanceNoArgumentTest() { + sep(c -> subscribe(String.class) + .filter(new FilterNoArgs("filter")::isValid) + .notify(new NotifyAndPushTarget()) + ); + NotifyAndPushTarget notifyTarget = getField("notifyTarget"); + assertThat(notifyTarget.getOnEventCount(), is(0)); + onEvent("86"); + assertThat(notifyTarget.getOnEventCount(), is(0)); + onEvent("true"); + assertThat(notifyTarget.getOnEventCount(), is(0)); + getField("filter", FilterNoArgs.class).setValid(true); + onEvent("86"); + assertThat(notifyTarget.getOnEventCount(), is(1)); + onEvent("true"); + assertThat(notifyTarget.getOnEventCount(), is(2)); + } + + @Test + public void filterNoArgumentTest() { + sep(c -> subscribe(String.class) + .filter(FilterTest::alwaysTrue) + .notify(new NotifyAndPushTarget()) + ); + NotifyAndPushTarget notifyTarget = getField("notifyTarget"); + assertThat(notifyTarget.getOnEventCount(), is(0)); + onEvent("86"); + assertThat(notifyTarget.getOnEventCount(), is(1)); + onEvent("true"); + assertThat(notifyTarget.getOnEventCount(), is(2)); + } + @Test public void filterByPropertyTest() { sep(c -> subscribe(String.class) - .filterByProperty(String::length, EventStreamBuildTest::gt5) + .filterByProperty(String::length, FilterTest::gt5) .notify(new NotifyAndPushTarget()) ); NotifyAndPushTarget notifyTarget = getField("notifyTarget"); @@ -185,7 +221,30 @@ public void filterFunctionWithPrimitiveArgumentTest() { Assert.assertEquals(2, (int) getStreamed("count")); } + @Setter + @Getter + public static class FilterNoArgs extends SingleNamedNode { + private boolean valid = false; + + public FilterNoArgs(String name) { + super(name); + } + + } + public static boolean filterMutableNumber(MutableNumber number, int check) { return number.intValue() > check; } + + public static boolean isTrue(String in) { + return Boolean.parseBoolean(in); + } + + public static boolean alwaysTrue() { + return true; + } + + public static boolean gt5(int val) { + return val > 5; + } } diff --git a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/MergeTest.java b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/MergeTest.java new file mode 100644 index 000000000..825d0d0d7 --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/MergeTest.java @@ -0,0 +1,62 @@ +package com.fluxtion.compiler.builder.dataflow; + +import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; +import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; +import org.junit.Test; + +import java.util.concurrent.atomic.LongAdder; + +import static com.fluxtion.compiler.builder.dataflow.DataFlow.subscribe; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +public class MergeTest extends MultipleSepTargetInProcessTest { + public MergeTest(SepTestConfig testConfig) { + super(testConfig); + } + + @Test + public void mergeTest() { + LongAdder adder = new LongAdder(); + sep(c -> subscribe(Long.class) + .merge(subscribe(String.class).map(EventStreamBuildTest::parseLong)) + .sink("integers")); + addSink("integers", adder::add); + onEvent(200L); + onEvent("300"); + assertThat(adder.intValue(), is(500)); + } + + @Test + public void mergeTestStaticMethod() { + LongAdder adder = new LongAdder(); + sep(c -> + DataFlow.merge( + subscribe(Long.class), + subscribe(String.class).map(EventStreamBuildTest::parseLong) + ) + .sink("integers")); + addSink("integers", adder::add); + onEvent(200L); + onEvent("300"); + assertThat(adder.intValue(), is(500)); + } + + @SuppressWarnings("unchecked") + @Test + public void mergeTestVarArgStaticMethod() { + LongAdder adder = new LongAdder(); + sep(c -> + DataFlow.merge( + subscribe(Long.class), + subscribe(String.class).map(EventStreamBuildTest::parseLong), + subscribe(Integer.class).map(Integer::longValue) + ) + .sink("integers")); + addSink("integers", adder::add); + onEvent(200L); + onEvent("300"); + onEvent(500); + assertThat(adder.intValue(), is(1_000)); + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/forkjoin/ForkJoinDataFlowTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/forkjoin/ForkJoinDataFlowTest.java index 85d167078..5c2e8fcb9 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/forkjoin/ForkJoinDataFlowTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/forkjoin/ForkJoinDataFlowTest.java @@ -34,7 +34,6 @@ public static String toUpper(Object in) { @Test public void testSimple() { - writeSourceFile = true; sep(c -> { AsyncProcess asynch1 = new AsyncProcess("asynch_1", 200); AsyncProcess asynch2 = new AsyncProcess("asynch_1", 100); @@ -53,8 +52,7 @@ public void testSimple() { @Test public void testSimple2() { - writeSourceFile = true; - writeOutputsToFile(true); +// writeOutputsToFile(true); sep(c -> { c.addNode(SyncCollectorMulti.builder().name("multiCollector") .parent(new AsyncProcess("asynch_1", 45)) @@ -74,8 +72,7 @@ public void log(LogRecord logRecord) { @Test public void parallelMap() { - writeSourceFile = true; - writeOutputsToFile(true); +// writeOutputsToFile(true); // addAuditor(); sep(c -> { c.addNode(SyncCollectorMulti.builder().name("multiCollector") diff --git a/runtime/src/main/java/com/fluxtion/runtime/dataflow/function/MergeFlowFunction.java b/runtime/src/main/java/com/fluxtion/runtime/dataflow/function/MergeFlowFunction.java index e53cac972..8075cde13 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/dataflow/function/MergeFlowFunction.java +++ b/runtime/src/main/java/com/fluxtion/runtime/dataflow/function/MergeFlowFunction.java @@ -2,6 +2,7 @@ import com.fluxtion.runtime.annotations.OnParentUpdate; import com.fluxtion.runtime.annotations.OnTrigger; +import com.fluxtion.runtime.annotations.builder.AssignToField; import com.fluxtion.runtime.annotations.builder.Inject; import com.fluxtion.runtime.audit.EventLogNode; import com.fluxtion.runtime.callback.DirtyStateMonitor; @@ -17,7 +18,9 @@ public class MergeFlowFunction, R extends FlowFunct @Inject public DirtyStateMonitor dirtyStateMonitor; - public MergeFlowFunction(S inputEventStream1, R inputEventStream2) { + public MergeFlowFunction( + @AssignToField("inputEventStream1") S inputEventStream1, + @AssignToField("inputEventStream2") R inputEventStream2) { this.inputEventStream1 = inputEventStream1; this.inputEventStream2 = inputEventStream2; } diff --git a/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/Predicates.java b/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/Predicates.java index 6823ae249..2878208f0 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/Predicates.java +++ b/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/Predicates.java @@ -4,8 +4,8 @@ import com.fluxtion.runtime.annotations.OnParentUpdate; import com.fluxtion.runtime.annotations.OnTrigger; import com.fluxtion.runtime.annotations.builder.AssignToField; -import com.fluxtion.runtime.partition.LambdaReflection; import com.fluxtion.runtime.dataflow.Stateful; +import com.fluxtion.runtime.partition.LambdaReflection; import lombok.Value; import java.util.ArrayList; @@ -241,4 +241,13 @@ public void reset() { init(); } } + + @Value + class PredicateWrapper { + SerializableSupplier predicate; + + public boolean test(Object o) { + return predicate.get(); + } + } } From 00c14253c1131ffca0601473792c5917fce25c73 Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 28 May 2023 10:57:52 +0000 Subject: [PATCH 016/228] updating poms for 9.0.5-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c207b09ec..c7b81ce12 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.4-SNAPSHOT + 9.0.5-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 8f0ff8b32..6e98a15bf 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.4-SNAPSHOT + 9.0.5-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index d5cade235..c7708d1e4 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.4-SNAPSHOT + 9.0.5-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 96f7f1297..7ae2ac9ab 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.4-SNAPSHOT + 9.0.5-SNAPSHOT ../parent-root/pom.xml From 3fe0e47cda75a0c02fe88a15a1a0e82f9411c713 Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 28 May 2023 10:57:57 +0000 Subject: [PATCH 017/228] updating poms for branch'release/9.0.4' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c207b09ec..10af589d8 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.4-SNAPSHOT + 9.0.4 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 8f0ff8b32..65c911371 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.4-SNAPSHOT + 9.0.4 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index d5cade235..b5be24ab6 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.4-SNAPSHOT + 9.0.4 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 96f7f1297..056e58011 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.4-SNAPSHOT + 9.0.4 ../parent-root/pom.xml From 0cf226c6d21741d346fb9215be627b6534e8ef50 Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 28 May 2023 11:02:02 +0000 Subject: [PATCH 018/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c7b81ce12..10af589d8 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.5-SNAPSHOT + 9.0.4 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 6e98a15bf..65c911371 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.5-SNAPSHOT + 9.0.4 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index c7708d1e4..b5be24ab6 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.5-SNAPSHOT + 9.0.4 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 7ae2ac9ab..056e58011 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.5-SNAPSHOT + 9.0.4 ../parent-root/pom.xml From 4a06dd27105d7d58ecb83ed8b384f182e473cfd9 Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 28 May 2023 11:02:03 +0000 Subject: [PATCH 019/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 10af589d8..c7b81ce12 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.4 + 9.0.5-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 65c911371..6e98a15bf 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.4 + 9.0.5-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index b5be24ab6..c7708d1e4 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.4 + 9.0.5-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 056e58011..7ae2ac9ab 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.4 + 9.0.5-SNAPSHOT ../parent-root/pom.xml From 7404e53de42d7956f75be3c692a7deafc7cebfba Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 31 May 2023 09:38:41 +0100 Subject: [PATCH 020/228] Add static bi mapping function to DataFlow MergeFlowFunction supports list of dependencies to merge Add javadoc --- .../compiler/builder/dataflow/DataFlow.java | 267 +++++++++++++----- .../builder/dataflow/FlowBuilder.java | 13 + .../builder/dataflow/BinaryMapTest.java | 19 ++ .../dataflow/function/MergeFlowFunction.java | 28 +- 4 files changed, 238 insertions(+), 89 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/DataFlow.java b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/DataFlow.java index 050bed310..9b4e80a11 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/DataFlow.java +++ b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/DataFlow.java @@ -9,6 +9,7 @@ import com.fluxtion.runtime.event.Event; import com.fluxtion.runtime.event.Signal; import com.fluxtion.runtime.node.DefaultEventHandlerNode; +import com.fluxtion.runtime.partition.LambdaReflection.SerializableBiFunction; import com.fluxtion.runtime.partition.LambdaReflection.SerializableFunction; import com.fluxtion.runtime.partition.LambdaReflection.SerializableSupplier; @@ -69,122 +70,169 @@ static FlowBuilder subscribe(Class classSubscription, in ); } - static GroupByFlowBuilder groupBy(SerializableFunction keyFunction) { - @SuppressWarnings("unchecked") - Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); - return subscribe(classSubscription).groupBy(keyFunction); - } - - static > GroupByFlowBuilder groupBy( - SerializableFunction keyFunction, SerializableSupplier aggregateFunctionSupplier) { - @SuppressWarnings("unchecked") - Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); - return subscribe(classSubscription).groupBy(keyFunction, aggregateFunctionSupplier); - } - - //SerializableSupplier aggregateFunctionSupplier - static GroupByFlowBuilder> groupByToList(SerializableFunction keyFunction) { - @SuppressWarnings("unchecked") - Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); - return subscribe(classSubscription).groupByToList(keyFunction); - } - - static GroupByFlowBuilder> groupByToSet(SerializableFunction keyFunction) { - @SuppressWarnings("unchecked") - Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); - return subscribe(classSubscription).groupByToSet(keyFunction); + /** + * Subscribes to an internal node within the processing graph and presents it as an {@link FlowBuilder} + * for constructing stream processing logic. + * + * @param source The node to be wrapped and made head of this stream + * @param The type of the node + * @return An {@link FlowBuilder} that can used to construct stream processing logic + */ + static FlowBuilder subscribeToNode(T source) { + return new FlowBuilder<>(new NodeToFlowFunction<>(source)); } - static GroupByFlowBuilder groupBy( - SerializableFunction keyFunction, - SerializableFunction valueFunction) { - @SuppressWarnings("unchecked") - Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); - return subscribe(classSubscription).groupBy(keyFunction, valueFunction); + /** + * Subscribes to a property on an internal node within the processing graph and presents it as an {@link FlowBuilder} + * for constructing stream processing logic. The node will be created and added to the graph + * + * @param sourceProperty The property accessor + * @param The type of the node + * @param The type of the property that will be supplied in the stream + * @return An {@link FlowBuilder} that can used to construct stream processing logic + */ + static FlowBuilder subscribeToNodeProperty(SerializableFunction sourceProperty) { + T source; + if (sourceProperty.captured().length == 0) { + try { + source = (T) sourceProperty.getContainingClass().getDeclaredConstructor().newInstance(); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | + NoSuchMethodException e) { + throw new RuntimeException("no default constructor found for class:" + + sourceProperty.getContainingClass() + + " either add default constructor or pass in a node instance"); + } + } else { + source = (T) sourceProperty.captured()[0]; + } + return subscribeToNode(source).map(sourceProperty); } - static > GroupByFlowBuilder - groupBy(SerializableFunction keyFunction, - SerializableFunction valueFunction, - SerializableSupplier aggregateFunctionSupplier) { - @SuppressWarnings("unchecked") - Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); - return subscribe(classSubscription).groupBy(keyFunction, valueFunction, aggregateFunctionSupplier); + /** + * Subscribes to a property on an internal node within the processing graph and presents it as an {@link FlowBuilder} + * for constructing stream processing logic. + * + * @param propertySupplier The property accessor + * @param The type of the property that will be supplied in the stream + * @return An {@link FlowBuilder} that can used to construct stream processing logic + */ + static FlowBuilder subscribeToNodeProperty(SerializableSupplier propertySupplier) { + EventProcessorBuilderService.service().addOrReuse(propertySupplier.captured()[0]); + return new FlowBuilder<>(new NodePropertyToFlowFunction<>(propertySupplier)); } + /** + * See {@link DataFlow#subscribe(Class)} shortcut method to create a stream that subscribes to a filtered + * {@link Signal} event. Useful for invoking triggers on flows. + * + * @param filterId The filter string to apply + * @return An {@link FlowBuilder} that can used to construct stream processing logic + */ static FlowBuilder subscribeToSignal(String filterId) { return subscribe(Signal.class, filterId); } + /** + * See {@link DataFlow#subscribe(Class)} shortcut method to create a stream that subscribes to a filtered + * {@link Signal} event, containing an event of the type specified. Useful for invoking triggers on flows. + * + * @param filterId The filter string to apply + * @param signalType The type of value that is held by the {@link Signal} event + * @return An {@link FlowBuilder} that can used to construct stream processing logic + */ static FlowBuilder subscribeToSignal(String filterId, Class signalType) { - //subscribe(Signal.class, filterId); return subscribe(Signal.class, filterId).map(Signal::getValue); } + /** + * See {@link DataFlow#subscribe(Class)} shortcut method to create a stream that subscribes to a filtered + * {@link Signal} event, containing an event of the type specified. A default value is provided if the signal + * event contains a null value. Useful for invoking triggers on flows. + * + * @param filterId The filter string to apply + * @param signalType The type of value that is held by the {@link Signal} event + * @param defaultValue the value to use if the signal event value is null + * @return An {@link FlowBuilder} that can used to construct stream processing logic + */ static FlowBuilder subscribeToSignal(String filterId, Class signalType, T defaultValue) { return subscribe(Signal.class, filterId).map(Signal::getValue).defaultValue(defaultValue); } + /** + * See {@link DataFlow#subscribe(Class)} shortcut method to create a int stream that subscribes to a filtered + * {@link Signal} event. Useful for invoking triggers on flows. + * + * @param filterId The filter string to apply + * @return An {@link IntFlowBuilder} that can used to construct stream processing logic + */ static IntFlowBuilder subscribeToIntSignal(String filterId) { return subscribe(Signal.IntSignal.class, filterId).mapToInt(Signal.IntSignal::getValue); } + /** + * See {@link DataFlow#subscribe(Class)} shortcut method to create a int stream that subscribes to a filtered + * {@link Signal} event. Useful for invoking triggers on flows. A default value is provided if the signal + * event contains a 0 value + * + * @param filterId The filter string to apply + * @param defaultValue to use if the signal event value is 0 + * @return An {@link IntFlowBuilder} that can used to construct stream processing logic + */ static IntFlowBuilder subscribeToIntSignal(String filterId, int defaultValue) { return subscribe(Signal.IntSignal.class, filterId).mapToInt(Signal.IntSignal::getValue) .defaultValue(defaultValue); } + /** + * See {@link DataFlow#subscribe(Class)} shortcut method to create a double stream that subscribes to a filtered + * {@link Signal} event. Useful for invoking triggers on flows. + * + * @param filterId The filter string to apply + * @return An {@link DoubleFlowBuilder} that can used to construct stream processing logic + */ static DoubleFlowBuilder subscribeToDoubleSignal(String filterId) { return subscribe(Signal.DoubleSignal.class, filterId).mapToDouble(Signal.DoubleSignal::getValue); } + /** + * See {@link DataFlow#subscribe(Class)} shortcut method to create a double stream that subscribes to a filtered + * {@link Signal} event. Useful for invoking triggers on flows. A default value is provided if the signal + * event contains a 0 value + * + * @param filterId The filter string to apply + * @param defaultValue to use if the signal event value is 0 + * @return An {@link DoubleFlowBuilder} that can used to construct stream processing logic + */ static DoubleFlowBuilder subscribeToDoubleSignal(String filterId, double defaultValue) { return subscribe(Signal.DoubleSignal.class, filterId).mapToDouble(Signal.DoubleSignal::getValue) .defaultValue(defaultValue); } + /** + * See {@link DataFlow#subscribe(Class)} shortcut method to create a long stream that subscribes to a filtered + * {@link Signal} event. Useful for invoking triggers on flows. + * + * @param filterId The filter string to apply + * @return An {@link LongFlowBuilder} that can used to construct stream processing logic + */ static LongFlowBuilder subscribeToLongSignal(String filterId) { return subscribe(Signal.LongSignal.class, filterId).mapToLong(Signal.LongSignal::getValue); } - static LongFlowBuilder subscribeToLongSignal(String filterId, long defaultValue) { - return subscribe(Signal.LongSignal.class, filterId).mapToLong(Signal.LongSignal::getValue) - .defaultValue(defaultValue); - } - /** - * Subscribes to an internal node within the processing graph and presents it as an {@link FlowBuilder} - * for constructing stream processing logic. + * See {@link DataFlow#subscribe(Class)} shortcut method to create a long stream that subscribes to a filtered + * {@link Signal} event. Useful for invoking triggers on flows. A default value is provided if the signal + * event contains a 0 value * - * @param source The node to be wrapped and made head of this stream - * @param The type of the node - * @return An {@link FlowBuilder} that can used to construct stream processing logic + * @param filterId The filter string to apply + * @param defaultValue to use if the signal event value is 0 + * @return An {@link LongFlowBuilder} that can used to construct stream processing logic */ - static FlowBuilder subscribeToNode(T source) { - return new FlowBuilder<>(new NodeToFlowFunction<>(source)); - } - - static FlowBuilder subscribeToNodeProperty(SerializableFunction sourceProperty) { - T source; - if (sourceProperty.captured().length == 0) { - try { - source = (T) sourceProperty.getContainingClass().getDeclaredConstructor().newInstance(); - } catch (InstantiationException | IllegalAccessException | InvocationTargetException | - NoSuchMethodException e) { - throw new RuntimeException("no default constructor found for class:" - + sourceProperty.getContainingClass() - + " either add default constructor or pass in a node instance"); - } - } else { - source = (T) sourceProperty.captured()[0]; - } - return subscribeToNode(source).map(sourceProperty); + static LongFlowBuilder subscribeToLongSignal(String filterId, long defaultValue) { + return subscribe(Signal.LongSignal.class, filterId).mapToLong(Signal.LongSignal::getValue) + .defaultValue(defaultValue); } - static FlowBuilder subscribeToNodeProperty(SerializableSupplier propertySupplier) { - EventProcessorBuilderService.service().addOrReuse(propertySupplier.captured()[0]); - return new FlowBuilder<>(new NodePropertyToFlowFunction<>(propertySupplier)); - } /** * Merges and maps several {@link FlowFunction}'s into a single event stream of type T @@ -211,15 +259,82 @@ static FlowBuilder merge(FlowBuilder streamAToMerge, Flow return streamAToMerge.merge(streamBToMerge); } + /** + * Merges multiple {@link FlowBuilder}'s into a single event stream of type T + * + * @param streamAToMerge stream A to merge + * @param streamBToMerge stream B to merge + * @param streamsToMerge streams to merge + * @param type of stream A + * @param type of stream B + * @return An {@link FlowBuilder} that can used to construct stream processing logic + */ @SuppressWarnings("unchecked") static FlowBuilder merge( FlowBuilder streamAToMerge, FlowBuilder streamBToMerge, FlowBuilder... streamsToMerge) { - FlowBuilder mergedStream = streamAToMerge.merge(streamBToMerge); - for (FlowBuilder streamToMerge : streamsToMerge) { - mergedStream = mergedStream.merge(streamToMerge); - } - return mergedStream; + return streamAToMerge.merge(streamBToMerge, streamsToMerge); + } + + /** + * Applies a mapping bi function to a pair of streams, creating a stream that is the output of the function. The + * mapping function will be invoked whenever either stream triggers a notification + * + * @param biFunction The mapping {@link java.util.function.BiFunction} + * @param streamArg1 Stream providing the first argument to the mapping function + * @param streamArg2 Stream providing the second argument to the mapping function + * @param The type of argument 1 stream + * @param The type of argument 2 stream + * @param The return type of the mapping function + * @return An {@link FlowBuilder} that can used to construct stream processing logic + */ + static FlowBuilder mapBiFunction(SerializableBiFunction biFunction, + FlowBuilder streamArg1, + FlowBuilder streamArg2) { + return streamArg1.mapBiFunction(biFunction, streamArg2); + } + + static GroupByFlowBuilder groupBy(SerializableFunction keyFunction) { + @SuppressWarnings("unchecked") + Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); + return subscribe(classSubscription).groupBy(keyFunction); + } + + static > GroupByFlowBuilder groupBy( + SerializableFunction keyFunction, SerializableSupplier aggregateFunctionSupplier) { + @SuppressWarnings("unchecked") + Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); + return subscribe(classSubscription).groupBy(keyFunction, aggregateFunctionSupplier); + } + + //SerializableSupplier aggregateFunctionSupplier + static GroupByFlowBuilder> groupByToList(SerializableFunction keyFunction) { + @SuppressWarnings("unchecked") + Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); + return subscribe(classSubscription).groupByToList(keyFunction); + } + + static GroupByFlowBuilder> groupByToSet(SerializableFunction keyFunction) { + @SuppressWarnings("unchecked") + Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); + return subscribe(classSubscription).groupByToSet(keyFunction); + } + + static GroupByFlowBuilder groupBy( + SerializableFunction keyFunction, + SerializableFunction valueFunction) { + @SuppressWarnings("unchecked") + Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); + return subscribe(classSubscription).groupBy(keyFunction, valueFunction); + } + + static > GroupByFlowBuilder + groupBy(SerializableFunction keyFunction, + SerializableFunction valueFunction, + SerializableSupplier aggregateFunctionSupplier) { + @SuppressWarnings("unchecked") + Class classSubscription = (Class) keyFunction.method().getDeclaringClass(); + return subscribe(classSubscription).groupBy(keyFunction, valueFunction, aggregateFunctionSupplier); } } diff --git a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilder.java b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilder.java index 9f24da887..c4598bd95 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilder.java +++ b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilder.java @@ -1,6 +1,7 @@ package com.fluxtion.compiler.builder.dataflow; import com.fluxtion.runtime.EventProcessorBuilderService; +import com.fluxtion.runtime.dataflow.FlowFunction; import com.fluxtion.runtime.dataflow.FlowSupplier; import com.fluxtion.runtime.dataflow.TriggeredFlowFunction; import com.fluxtion.runtime.dataflow.aggregate.AggregateFlowFunction; @@ -27,6 +28,7 @@ import com.fluxtion.runtime.partition.LambdaReflection.SerializableFunction; import com.fluxtion.runtime.partition.LambdaReflection.SerializableSupplier; +import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -92,6 +94,17 @@ public FlowBuilder merge(FlowBuilder streamToMerge) { return new FlowBuilder<>(new MergeFlowFunction<>(eventStream, streamToMerge.eventStream)); } + @SuppressWarnings("unchecked") + public FlowBuilder merge(FlowBuilder streamToMerge, FlowBuilder... streamsToMerge) { + List> mergeList = new ArrayList<>(); + mergeList.add(eventStream); + mergeList.add(streamToMerge.eventStream); + for (FlowBuilder flowBuilder : streamsToMerge) { + mergeList.add(flowBuilder.eventStream); + } + return new FlowBuilder<>(new MergeFlowFunction<>(mergeList)); + } + public FlowBuilder flatMap(SerializableFunction> iterableFunction) { return new FlowBuilder<>(new FlatMapFlowFunction<>(eventStream, iterableFunction)); } diff --git a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/BinaryMapTest.java b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/BinaryMapTest.java index 0e4ee23f1..fbc2ee72c 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/BinaryMapTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/BinaryMapTest.java @@ -174,6 +174,25 @@ public void referenceTypesBiFunctionTest() { assertThat(getStreamed("formattedDate"), is("July-28-2022")); } + @Test + public void referenceTypesDataFlowBiFunctionTest() { + sep(c -> { + FlowBuilder stringStream = subscribe(String.class); + FlowBuilder dateStream = subscribe(Date.class); + DataFlow.mapBiFunction( + BinaryMapTest::dateFormat, stringStream, dateStream).id("formattedDate"); + }); + Calendar calendar = Calendar.getInstance(Locale.UK); + calendar.set(2022, 06, 28); + + onEvent("MMM-YYYY"); + onEvent(calendar.getTime()); + assertThat(getStreamed("formattedDate"), is("Jul-2022")); + + onEvent("MMMM-dd-YYYY"); + assertThat(getStreamed("formattedDate"), is("July-28-2022")); + } + @Value public static class Data_1 { int intValue; diff --git a/runtime/src/main/java/com/fluxtion/runtime/dataflow/function/MergeFlowFunction.java b/runtime/src/main/java/com/fluxtion/runtime/dataflow/function/MergeFlowFunction.java index 8075cde13..f82961c98 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/dataflow/function/MergeFlowFunction.java +++ b/runtime/src/main/java/com/fluxtion/runtime/dataflow/function/MergeFlowFunction.java @@ -2,37 +2,39 @@ import com.fluxtion.runtime.annotations.OnParentUpdate; import com.fluxtion.runtime.annotations.OnTrigger; -import com.fluxtion.runtime.annotations.builder.AssignToField; import com.fluxtion.runtime.annotations.builder.Inject; import com.fluxtion.runtime.audit.EventLogNode; import com.fluxtion.runtime.callback.DirtyStateMonitor; import com.fluxtion.runtime.dataflow.FlowFunction; import com.fluxtion.runtime.dataflow.TriggeredFlowFunction; +import java.util.ArrayList; +import java.util.List; + public class MergeFlowFunction, R extends FlowFunction> extends EventLogNode implements TriggeredFlowFunction { - private final S inputEventStream1; - private final R inputEventStream2; + private final List> mergeList; + private T update; @Inject public DirtyStateMonitor dirtyStateMonitor; public MergeFlowFunction( - @AssignToField("inputEventStream1") S inputEventStream1, - @AssignToField("inputEventStream2") R inputEventStream2) { - this.inputEventStream1 = inputEventStream1; - this.inputEventStream2 = inputEventStream2; + S inputEventStream1, + R inputEventStream2) { + mergeList = new ArrayList<>(); + mergeList.add(inputEventStream1); + mergeList.add(inputEventStream2); } - @OnParentUpdate("inputEventStream1") - public void inputStream1Updated(S inputEventStream1) { - update = inputEventStream1.get(); + public MergeFlowFunction(List> mergeList) { + this.mergeList = mergeList; } - @OnParentUpdate("inputEventStream2") - public void inputStream2Updated(R inputEventStream2) { - update = inputEventStream2.get(); + @OnParentUpdate("mergeList") + public void inputStreamUpdated(FlowFunction inputEventStream1) { + update = (T) inputEventStream1.get(); } @Override From 6abdeee4f49b3c09c34134879837fb1aab6a9f06 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 31 May 2023 08:51:46 +0000 Subject: [PATCH 021/228] updating poms for 9.0.6-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c7b81ce12..8f91dce9f 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.5-SNAPSHOT + 9.0.6-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 6e98a15bf..0a4b7f43f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.5-SNAPSHOT + 9.0.6-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index c7708d1e4..81c13882a 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.5-SNAPSHOT + 9.0.6-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 7ae2ac9ab..5d89312bc 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.5-SNAPSHOT + 9.0.6-SNAPSHOT ../parent-root/pom.xml From 05c02722e69676f6e971431f6d54d6537bea7e54 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 31 May 2023 08:51:51 +0000 Subject: [PATCH 022/228] updating poms for branch'release/9.0.5' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c7b81ce12..25845ca99 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.5-SNAPSHOT + 9.0.5 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 6e98a15bf..fabf2194c 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.5-SNAPSHOT + 9.0.5 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index c7708d1e4..5dc945efa 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.5-SNAPSHOT + 9.0.5 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 7ae2ac9ab..64c76eb57 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.5-SNAPSHOT + 9.0.5 ../parent-root/pom.xml From a44f77732b05e93570f224a403e63dfd66ea36a3 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 31 May 2023 08:56:47 +0000 Subject: [PATCH 023/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 8f91dce9f..25845ca99 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.6-SNAPSHOT + 9.0.5 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 0a4b7f43f..fabf2194c 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.6-SNAPSHOT + 9.0.5 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 81c13882a..5dc945efa 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.6-SNAPSHOT + 9.0.5 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 5d89312bc..64c76eb57 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.6-SNAPSHOT + 9.0.5 ../parent-root/pom.xml From cc1a66b17e043740afe9bf9f012d311b4bdae1f3 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 31 May 2023 08:56:47 +0000 Subject: [PATCH 024/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 25845ca99..8f91dce9f 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.5 + 9.0.6-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index fabf2194c..0a4b7f43f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.5 + 9.0.6-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 5dc945efa..81c13882a 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.5 + 9.0.6-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 64c76eb57..5d89312bc 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.5 + 9.0.6-SNAPSHOT ../parent-root/pom.xml From 65570a894da5b59562e61b9dc6e0223235e1caa4 Mon Sep 17 00:00:00 2001 From: command-line Date: Sun, 4 Jun 2023 16:45:58 +0100 Subject: [PATCH 025/228] Support maven plugin building, with configurtable classloader and conform to no compilation instruction in FluxtionCompilerConfig --- .../java/com/fluxtion/compiler/Fluxtion.java | 28 +++++++++++++++++++ .../generation/EventProcessorFactory.java | 5 ++-- .../compiler/EventProcessorCompilation.java | 3 ++ .../compiler/EventProcessorGenerator.java | 4 +-- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java b/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java index 7095c9c4b..ef3360032 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java +++ b/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java @@ -236,6 +236,7 @@ static int scanAndCompileFluxtionBuilders(File... files) { generationCount.increment(); System.out.println(generationCount.intValue() + ": invoking builder " + c.getName()); try { + final FluxtionGraphBuilder newInstance = (FluxtionGraphBuilder) c.loadClass().getDeclaredConstructor().newInstance(); compile(newInstance::buildGraph, newInstance::configureGeneration); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | @@ -246,4 +247,31 @@ static int scanAndCompileFluxtionBuilders(File... files) { } return generationCount.intValue(); } + + static int scanAndCompileFluxtionBuilders(ClassLoader classLoader, File... files) { + Objects.requireNonNull(files, "provide valid locations to search for fluxtion builders"); + LongAdder generationCount = new LongAdder(); + try (ScanResult scanResult = new ClassGraph() + .enableAllInfo() + .overrideClasspath(files) + .scan()) { + + ClassInfoList builderList = scanResult + .getClassesImplementing(FluxtionGraphBuilder.class) + .exclude(scanResult.getClassesWithAnnotation(Disabled.class.getCanonicalName())); + + builderList.forEach(c -> { + generationCount.increment(); + System.out.println(generationCount.intValue() + ": invoking builder " + c.getName()); + try { + final FluxtionGraphBuilder newInstance = (FluxtionGraphBuilder) classLoader.loadClass(c.getName()).getDeclaredConstructor().newInstance(); + compile(newInstance::buildGraph, newInstance::configureGeneration); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | + NoSuchMethodException | ClassNotFoundException e) { + throw new RuntimeException("cannot instantiate FluxtionGraphBuilder", e); + } + }); + } + return generationCount.intValue(); + } } diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/EventProcessorFactory.java b/compiler/src/main/java/com/fluxtion/compiler/generation/EventProcessorFactory.java index 65fbedf62..334673c73 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/EventProcessorFactory.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/EventProcessorFactory.java @@ -197,9 +197,8 @@ public static EventProcessor compile( cfgBuilder.accept(fluxtionCompilerConfig); EventProcessorCompilation compiler = new EventProcessorCompilation(); - Class sepClass = compiler.compile(fluxtionCompilerConfig, new InProcessEventProcessorConfig(sepConfig)); - EventProcessor sep = sepClass.getDeclaredConstructor().newInstance(); - return sep; + Class> sepClass = compiler.compile(fluxtionCompilerConfig, new InProcessEventProcessorConfig(sepConfig)); + return sepClass == null ? null : sepClass.getDeclaredConstructor().newInstance(); } public static EventProcessor compile( diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java index 25c9860ab..8ed5e5bdb 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java @@ -101,6 +101,9 @@ private Class generateSep() throws Exception { outFile.getParentFile().mkdirs(); if (outFile.exists()) { backupFile = new File(outFile.getParentFile(), outFile.getName() + ".backup"); + if (backupFile.exists()) { + throw new RuntimeException("Fluxtion generation problem backup file exists - please move or delete file:" + backupFile.getCanonicalPath()); + } FileUtils.moveFile(outFile, backupFile); } writer = new FileWriter(outFile); diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java index 023fb25c6..e46a4ceda 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java @@ -138,8 +138,8 @@ public SimpleEventProcessorModel getSimpleEventProcessorModel() { private static void initVelocity() { - Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); - Velocity.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); + Velocity.setProperty(RuntimeConstants.RESOURCE_LOADERS, "classpath"); + Velocity.setProperty("resource.loader.classpath.class", ClasspathResourceLoader.class.getName()); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(GenerationContext.SINGLETON.getClassLoader()); Velocity.init(); From cd8a540db61c2c703575e43ffebace941c3ea564 Mon Sep 17 00:00:00 2001 From: command-line Date: Sun, 4 Jun 2023 19:14:30 +0100 Subject: [PATCH 026/228] Generate without compile option added --- .../java/com/fluxtion/compiler/Fluxtion.java | 16 +++++++++++++++- .../main/java/com/fluxtion/compiler/Sample.java | 13 ------------- .../compiler/generation/RuntimeConstants.java | 6 ++++++ .../compiler/EventProcessorCompilation.java | 3 ++- .../classcompiler/StringCompilation.java | 16 +++++++++++++++- 5 files changed, 38 insertions(+), 16 deletions(-) delete mode 100644 compiler/src/main/java/com/fluxtion/compiler/Sample.java create mode 100644 compiler/src/main/java/com/fluxtion/compiler/generation/RuntimeConstants.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java b/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java index ef3360032..eaf3f3827 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java +++ b/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java @@ -1,6 +1,7 @@ package com.fluxtion.compiler; import com.fluxtion.compiler.generation.EventProcessorFactory; +import com.fluxtion.compiler.generation.RuntimeConstants; import com.fluxtion.runtime.EventProcessor; import com.fluxtion.runtime.StaticEventProcessor; import com.fluxtion.runtime.annotations.builder.Disabled; @@ -248,8 +249,21 @@ static int scanAndCompileFluxtionBuilders(File... files) { return generationCount.intValue(); } - static int scanAndCompileFluxtionBuilders(ClassLoader classLoader, File... files) { + /** + * Scans the supplied File resources for any classes that implement the {@link FluxtionGraphBuilder} interface + * and will generate an {@link EventProcessor} for any located builders. + *

+ * Any builder marked with the {@link Disabled} annotation will be ignored + *

+ * No compilations are carried out + * + * @param classLoader the classloader to be used for the generation + * @param files The locations to search for {@link FluxtionGraphBuilder} classes + * @return The number of processors generated + */ + static int scanAndGenerateFluxtionBuilders(ClassLoader classLoader, File... files) { Objects.requireNonNull(files, "provide valid locations to search for fluxtion builders"); + System.setProperty(RuntimeConstants.FLUXTION_NO_COMPILE, "true"); LongAdder generationCount = new LongAdder(); try (ScanResult scanResult = new ClassGraph() .enableAllInfo() diff --git a/compiler/src/main/java/com/fluxtion/compiler/Sample.java b/compiler/src/main/java/com/fluxtion/compiler/Sample.java deleted file mode 100644 index bb129d72b..000000000 --- a/compiler/src/main/java/com/fluxtion/compiler/Sample.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.fluxtion.compiler; - -public class Sample { - - public static String foo(Object bar) { -// return switch(bar) { -// case Integer i -> "I'm an Integer: " + i; -// case Long l -> "I'm a Long: " + l; -// default -> "I'm an object"; -// }; - return ""; - } -} diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/RuntimeConstants.java b/compiler/src/main/java/com/fluxtion/compiler/generation/RuntimeConstants.java new file mode 100644 index 000000000..6aec17cd2 --- /dev/null +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/RuntimeConstants.java @@ -0,0 +1,6 @@ +package com.fluxtion.compiler.generation; + +public interface RuntimeConstants { + String FLUXTION_NO_COMPILE = "FLUXTION.NO_COMPILE"; + String GENERATION_CLASSPATH = "FLUXTION.GENERATION.CLASSPATH"; +} diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java index 8ed5e5bdb..278e79d15 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java @@ -22,6 +22,7 @@ import com.fluxtion.compiler.builder.factory.NodeFactoryLocator; import com.fluxtion.compiler.builder.factory.NodeFactoryRegistration; import com.fluxtion.compiler.generation.GenerationContext; +import com.fluxtion.compiler.generation.RuntimeConstants; import com.fluxtion.compiler.generation.compiler.classcompiler.StringCompilation; import com.google.googlejavaformat.java.Formatter; import org.apache.commons.io.FileUtils; @@ -143,7 +144,7 @@ private Class generateSep() throws Exception { EventProcessorGenerator.formatSource(file); LOG.debug("completed formatting source"); } - if (compilerConfig.isCompileSource()) { + if (compilerConfig.isCompileSource() && !Boolean.getBoolean(RuntimeConstants.FLUXTION_NO_COMPILE)) { LOG.debug("start compiling source"); if (compilerConfig.isWriteSourceToFile()) { builderConfig.getCompilerOptions(); diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/classcompiler/StringCompilation.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/classcompiler/StringCompilation.java index d20bba3ec..22cbbb1c7 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/classcompiler/StringCompilation.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/classcompiler/StringCompilation.java @@ -1,11 +1,19 @@ package com.fluxtion.compiler.generation.compiler.classcompiler; +import com.fluxtion.compiler.generation.RuntimeConstants; import com.fluxtion.compiler.generation.annotationprocessor.ValidateEventHandlerAnnotations; import com.fluxtion.compiler.generation.annotationprocessor.ValidateLifecycleAnnotations; import com.fluxtion.compiler.generation.annotationprocessor.ValidateOnParentUpdateHandlerAnnotations; import com.fluxtion.compiler.generation.annotationprocessor.ValidateOnTriggerAnnotations; -import javax.tools.*; +import javax.tools.DiagnosticCollector; +import javax.tools.FileObject; +import javax.tools.ForwardingJavaFileManager; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileManager; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; import java.io.IOException; import java.net.URISyntaxException; import java.util.ArrayList; @@ -36,6 +44,12 @@ static Class compile(String className, String source, List option final JavaByteObject byteObject = new JavaByteObject(className); StandardJavaFileManager standardFileManager = compiler.getStandardFileManager(diagnostics, null, null); JavaFileManager fileManager = createFileManager(standardFileManager, byteObject); + String cp = System.getProperty(RuntimeConstants.GENERATION_CLASSPATH); + if (cp != null) { + optionList.add("-classpath"); + optionList.add(cp); + } + JavaCompiler.CompilationTask task = compiler.getTask( null, fileManager, diagnostics, optionList, null, Collections.singletonList(new JavaStringObject(className, source)) ); From 038e7ebba19c576f03bf3bdac1425e27de599dad Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 4 Jun 2023 18:27:15 +0000 Subject: [PATCH 027/228] updating poms for 9.0.7-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 8f91dce9f..66a234ebf 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.6-SNAPSHOT + 9.0.7-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 0a4b7f43f..2fe4219b0 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.6-SNAPSHOT + 9.0.7-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 81c13882a..0c86eb2d3 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.6-SNAPSHOT + 9.0.7-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 5d89312bc..a8d2be8ac 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.6-SNAPSHOT + 9.0.7-SNAPSHOT ../parent-root/pom.xml From d80ca5f8a1482797fff9113170261f9fbe6529fa Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 4 Jun 2023 18:27:19 +0000 Subject: [PATCH 028/228] updating poms for branch'release/9.0.6' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 8f91dce9f..b8fd2cd1b 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.6-SNAPSHOT + 9.0.6 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 0a4b7f43f..2b707c6a9 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.6-SNAPSHOT + 9.0.6 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 81c13882a..190ea5a2f 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.6-SNAPSHOT + 9.0.6 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 5d89312bc..c5073563e 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.6-SNAPSHOT + 9.0.6 ../parent-root/pom.xml From 29eab5293841c44cfcf4e805ad40b94ab7050837 Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 4 Jun 2023 18:30:44 +0000 Subject: [PATCH 029/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 66a234ebf..b8fd2cd1b 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.7-SNAPSHOT + 9.0.6 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2fe4219b0..2b707c6a9 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.7-SNAPSHOT + 9.0.6 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 0c86eb2d3..190ea5a2f 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.7-SNAPSHOT + 9.0.6 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index a8d2be8ac..c5073563e 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.7-SNAPSHOT + 9.0.6 ../parent-root/pom.xml From 931396ed749779aeb26ae8638d6ece17c655d9fc Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 4 Jun 2023 18:30:44 +0000 Subject: [PATCH 030/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index b8fd2cd1b..66a234ebf 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.6 + 9.0.7-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2b707c6a9..2fe4219b0 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.6 + 9.0.7-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 190ea5a2f..0c86eb2d3 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.6 + 9.0.7-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index c5073563e..a8d2be8ac 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.6 + 9.0.7-SNAPSHOT ../parent-root/pom.xml From ba6809422747a0f1777152e72bac62e5f5418188 Mon Sep 17 00:00:00 2001 From: command-line Date: Tue, 6 Jun 2023 21:37:59 +0100 Subject: [PATCH 031/228] initial instance callback feature --- .../generation/GenerationContext.java | 3 + .../generation/callback/CallbackNodeTest.java | 68 +++ .../runtime/callback/CallBackNode.java | 60 ++ .../runtime/callback/InstanceCallback.java | 536 ++++++++++++++++++ 4 files changed, 667 insertions(+) create mode 100644 compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java create mode 100644 runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java create mode 100644 runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallback.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/GenerationContext.java b/compiler/src/main/java/com/fluxtion/compiler/generation/GenerationContext.java index 6de4925fd..cca2da8af 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/GenerationContext.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/GenerationContext.java @@ -16,6 +16,7 @@ */ package com.fluxtion.compiler.generation; +import com.fluxtion.runtime.callback.InstanceCallback; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; @@ -185,6 +186,7 @@ private GenerationContext(String packageName, String sepClassName, File outputDi log.info("classloader:{}", this.classLoader); log.debug("built GenerationContext: {}", this); cacheMap = new HashMap<>(); + InstanceCallback.reset(); } private GenerationContext(ClassLoader classLoasder, String packageName, String sepClassName, File outputDirectory, File resourcesRootDirectory, File buildOutputDirectory) { @@ -194,6 +196,7 @@ private GenerationContext(ClassLoader classLoasder, String packageName, String s this.resourcesRootDirectory = resourcesRootDirectory; this.classLoader = classLoasder; cacheMap = new HashMap<>(); + InstanceCallback.reset(); log.debug("built GenerationContext: {}", this); } diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java new file mode 100644 index 000000000..ab7a0a05c --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java @@ -0,0 +1,68 @@ +package com.fluxtion.compiler.generation.callback; + +import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; +import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; +import com.fluxtion.runtime.annotations.OnTrigger; +import com.fluxtion.runtime.callback.CallBackNode; +import lombok.Value; +import org.junit.Test; + +public class CallbackNodeTest extends MultipleSepTargetInProcessTest { + public CallbackNodeTest(SepTestConfig testConfig) { + super(testConfig); + } + + @Test + public void directInvokeTest() { + writeOutputsToFile(true); + sep(c -> { + c.addNode(new Child(new ExternalCallback("callback1"))); + c.addNode(new Child(new ExternalCallback("callback2"))); + }); + + ExternalCallback callback1 = getField("callback1"); + callback1.doubleEvent(new MyEvent<>(32.4)); + callback1.stringEvent(new MyEvent<>("jjjj")); + + ExternalCallback callback2 = getField("callback2"); + callback2.doubleEvent(new MyEvent<>(32.4)); + callback2.stringEvent(new MyEvent<>("jjjj")); + } + + + public static class ExternalCallback extends CallBackNode { + + Object update; + + public ExternalCallback(String name) { + super(name); + } + + public void stringEvent(MyEvent myEvent) { + update = myEvent.getData(); + triggerGraphCycle(); + } + + public void doubleEvent(MyEvent myEvent) { + update = myEvent.getData(); + triggerGraphCycle(); + } + + } + + @Value + public static class Child { + ExternalCallback externalCallback; + + @OnTrigger + public boolean triggered() { + System.out.println("parent:" + externalCallback.getName() + " updated:" + externalCallback.update); + return true; + } + } + + @Value + public static class MyEvent { + T data; + } +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java b/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java new file mode 100644 index 000000000..e0e9a2d2b --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java @@ -0,0 +1,60 @@ +package com.fluxtion.runtime.callback; + +import com.fluxtion.runtime.annotations.Initialise; +import com.fluxtion.runtime.annotations.builder.Inject; +import com.fluxtion.runtime.node.EventHandlerNode; +import com.fluxtion.runtime.node.SingleNamedNode; +import lombok.SneakyThrows; + +/** + * Extend this node to expose instance callback outside the {@link com.fluxtion.runtime.EventProcessor}. + * Use the protected methods + */ +public abstract class CallBackNode extends SingleNamedNode implements EventHandlerNode { + + private transient Class cbClass; + private transient Object event; + public String eventClassName; + @Inject + public EventDispatcher dispatcher; + @Inject + public DirtyStateMonitor dirtyStateMonitor; + + @SneakyThrows + public CallBackNode(String name) { + super(name); + } + + @Override + public boolean onEvent(Object e) { + return true; + } + + @Override + @SneakyThrows + public final Class eventClass() { + if (cbClass == null) { + cbClass = InstanceCallback.cbClassList.remove(0); + eventClassName = cbClass.getName(); + } + return cbClass; + } + + @Initialise + @SneakyThrows + public void init() { + event = Class.forName(eventClassName).getDeclaredConstructor().newInstance(); + } + + /** + * Trigger a callback calculation with this node as the root of the + */ + protected final void triggerGraphCycle() { + dispatcher.processAsNewEventCycle(event); + } + + protected final void markDirty() { + dirtyStateMonitor.markDirty(this); + } + +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallback.java b/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallback.java new file mode 100644 index 000000000..6171a8b3c --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallback.java @@ -0,0 +1,536 @@ +package com.fluxtion.runtime.callback; + +import java.util.ArrayList; +import java.util.List; + +public interface InstanceCallback { + + List> cbClassList = new ArrayList<>(); + + static void main(String[] args) { + for (int i = 0; i < 128; i++) { + System.out.printf("class InstanceCallback_%d {}%n", i); + } + for (int i = 0; i < 128; i++) { + System.out.printf("cbClassList.add(InstanceCallback_%d.class);%n", i); + } + } + + static void reset() { +// System.out.println("FunctionTriggerNode::reset"); + cbClassList.clear(); + cbClassList.add(InstanceCallback_0.class); + cbClassList.add(InstanceCallback_1.class); + cbClassList.add(InstanceCallback_2.class); + cbClassList.add(InstanceCallback_3.class); + cbClassList.add(InstanceCallback_4.class); + cbClassList.add(InstanceCallback_5.class); + cbClassList.add(InstanceCallback_6.class); + cbClassList.add(InstanceCallback_7.class); + cbClassList.add(InstanceCallback_8.class); + cbClassList.add(InstanceCallback_9.class); + cbClassList.add(InstanceCallback_10.class); + cbClassList.add(InstanceCallback_11.class); + cbClassList.add(InstanceCallback_12.class); + cbClassList.add(InstanceCallback_13.class); + cbClassList.add(InstanceCallback_14.class); + cbClassList.add(InstanceCallback_15.class); + cbClassList.add(InstanceCallback_16.class); + cbClassList.add(InstanceCallback_17.class); + cbClassList.add(InstanceCallback_18.class); + cbClassList.add(InstanceCallback_19.class); + cbClassList.add(InstanceCallback_20.class); + cbClassList.add(InstanceCallback_21.class); + cbClassList.add(InstanceCallback_22.class); + cbClassList.add(InstanceCallback_23.class); + cbClassList.add(InstanceCallback_24.class); + cbClassList.add(InstanceCallback_25.class); + cbClassList.add(InstanceCallback_26.class); + cbClassList.add(InstanceCallback_27.class); + cbClassList.add(InstanceCallback_28.class); + cbClassList.add(InstanceCallback_29.class); + cbClassList.add(InstanceCallback_30.class); + cbClassList.add(InstanceCallback_31.class); + cbClassList.add(InstanceCallback_32.class); + cbClassList.add(InstanceCallback_33.class); + cbClassList.add(InstanceCallback_34.class); + cbClassList.add(InstanceCallback_35.class); + cbClassList.add(InstanceCallback_36.class); + cbClassList.add(InstanceCallback_37.class); + cbClassList.add(InstanceCallback_38.class); + cbClassList.add(InstanceCallback_39.class); + cbClassList.add(InstanceCallback_40.class); + cbClassList.add(InstanceCallback_41.class); + cbClassList.add(InstanceCallback_42.class); + cbClassList.add(InstanceCallback_43.class); + cbClassList.add(InstanceCallback_44.class); + cbClassList.add(InstanceCallback_45.class); + cbClassList.add(InstanceCallback_46.class); + cbClassList.add(InstanceCallback_47.class); + cbClassList.add(InstanceCallback_48.class); + cbClassList.add(InstanceCallback_49.class); + cbClassList.add(InstanceCallback_50.class); + cbClassList.add(InstanceCallback_51.class); + cbClassList.add(InstanceCallback_52.class); + cbClassList.add(InstanceCallback_53.class); + cbClassList.add(InstanceCallback_54.class); + cbClassList.add(InstanceCallback_55.class); + cbClassList.add(InstanceCallback_56.class); + cbClassList.add(InstanceCallback_57.class); + cbClassList.add(InstanceCallback_58.class); + cbClassList.add(InstanceCallback_59.class); + cbClassList.add(InstanceCallback_60.class); + cbClassList.add(InstanceCallback_61.class); + cbClassList.add(InstanceCallback_62.class); + cbClassList.add(InstanceCallback_63.class); + cbClassList.add(InstanceCallback_64.class); + cbClassList.add(InstanceCallback_65.class); + cbClassList.add(InstanceCallback_66.class); + cbClassList.add(InstanceCallback_67.class); + cbClassList.add(InstanceCallback_68.class); + cbClassList.add(InstanceCallback_69.class); + cbClassList.add(InstanceCallback_70.class); + cbClassList.add(InstanceCallback_71.class); + cbClassList.add(InstanceCallback_72.class); + cbClassList.add(InstanceCallback_73.class); + cbClassList.add(InstanceCallback_74.class); + cbClassList.add(InstanceCallback_75.class); + cbClassList.add(InstanceCallback_76.class); + cbClassList.add(InstanceCallback_77.class); + cbClassList.add(InstanceCallback_78.class); + cbClassList.add(InstanceCallback_79.class); + cbClassList.add(InstanceCallback_80.class); + cbClassList.add(InstanceCallback_81.class); + cbClassList.add(InstanceCallback_82.class); + cbClassList.add(InstanceCallback_83.class); + cbClassList.add(InstanceCallback_84.class); + cbClassList.add(InstanceCallback_85.class); + cbClassList.add(InstanceCallback_86.class); + cbClassList.add(InstanceCallback_87.class); + cbClassList.add(InstanceCallback_88.class); + cbClassList.add(InstanceCallback_89.class); + cbClassList.add(InstanceCallback_90.class); + cbClassList.add(InstanceCallback_91.class); + cbClassList.add(InstanceCallback_92.class); + cbClassList.add(InstanceCallback_93.class); + cbClassList.add(InstanceCallback_94.class); + cbClassList.add(InstanceCallback_95.class); + cbClassList.add(InstanceCallback_96.class); + cbClassList.add(InstanceCallback_97.class); + cbClassList.add(InstanceCallback_98.class); + cbClassList.add(InstanceCallback_99.class); + cbClassList.add(InstanceCallback_100.class); + cbClassList.add(InstanceCallback_101.class); + cbClassList.add(InstanceCallback_102.class); + cbClassList.add(InstanceCallback_103.class); + cbClassList.add(InstanceCallback_104.class); + cbClassList.add(InstanceCallback_105.class); + cbClassList.add(InstanceCallback_106.class); + cbClassList.add(InstanceCallback_107.class); + cbClassList.add(InstanceCallback_108.class); + cbClassList.add(InstanceCallback_109.class); + cbClassList.add(InstanceCallback_110.class); + cbClassList.add(InstanceCallback_111.class); + cbClassList.add(InstanceCallback_112.class); + cbClassList.add(InstanceCallback_113.class); + cbClassList.add(InstanceCallback_114.class); + cbClassList.add(InstanceCallback_115.class); + cbClassList.add(InstanceCallback_116.class); + cbClassList.add(InstanceCallback_117.class); + cbClassList.add(InstanceCallback_118.class); + cbClassList.add(InstanceCallback_119.class); + cbClassList.add(InstanceCallback_120.class); + cbClassList.add(InstanceCallback_121.class); + cbClassList.add(InstanceCallback_122.class); + cbClassList.add(InstanceCallback_123.class); + cbClassList.add(InstanceCallback_124.class); + cbClassList.add(InstanceCallback_125.class); + cbClassList.add(InstanceCallback_126.class); + cbClassList.add(InstanceCallback_127.class); + } + + + class InstanceCallback_0 { + } + + class InstanceCallback_1 { + } + + class InstanceCallback_2 { + } + + class InstanceCallback_3 { + } + + class InstanceCallback_4 { + } + + class InstanceCallback_5 { + } + + class InstanceCallback_6 { + } + + class InstanceCallback_7 { + } + + class InstanceCallback_8 { + } + + class InstanceCallback_9 { + } + + class InstanceCallback_10 { + } + + class InstanceCallback_11 { + } + + class InstanceCallback_12 { + } + + class InstanceCallback_13 { + } + + class InstanceCallback_14 { + } + + class InstanceCallback_15 { + } + + class InstanceCallback_16 { + } + + class InstanceCallback_17 { + } + + class InstanceCallback_18 { + } + + class InstanceCallback_19 { + } + + class InstanceCallback_20 { + } + + class InstanceCallback_21 { + } + + class InstanceCallback_22 { + } + + class InstanceCallback_23 { + } + + class InstanceCallback_24 { + } + + class InstanceCallback_25 { + } + + class InstanceCallback_26 { + } + + class InstanceCallback_27 { + } + + class InstanceCallback_28 { + } + + class InstanceCallback_29 { + } + + class InstanceCallback_30 { + } + + class InstanceCallback_31 { + } + + class InstanceCallback_32 { + } + + class InstanceCallback_33 { + } + + class InstanceCallback_34 { + } + + class InstanceCallback_35 { + } + + class InstanceCallback_36 { + } + + class InstanceCallback_37 { + } + + class InstanceCallback_38 { + } + + class InstanceCallback_39 { + } + + class InstanceCallback_40 { + } + + class InstanceCallback_41 { + } + + class InstanceCallback_42 { + } + + class InstanceCallback_43 { + } + + class InstanceCallback_44 { + } + + class InstanceCallback_45 { + } + + class InstanceCallback_46 { + } + + class InstanceCallback_47 { + } + + class InstanceCallback_48 { + } + + class InstanceCallback_49 { + } + + class InstanceCallback_50 { + } + + class InstanceCallback_51 { + } + + class InstanceCallback_52 { + } + + class InstanceCallback_53 { + } + + class InstanceCallback_54 { + } + + class InstanceCallback_55 { + } + + class InstanceCallback_56 { + } + + class InstanceCallback_57 { + } + + class InstanceCallback_58 { + } + + class InstanceCallback_59 { + } + + class InstanceCallback_60 { + } + + class InstanceCallback_61 { + } + + class InstanceCallback_62 { + } + + class InstanceCallback_63 { + } + + class InstanceCallback_64 { + } + + class InstanceCallback_65 { + } + + class InstanceCallback_66 { + } + + class InstanceCallback_67 { + } + + class InstanceCallback_68 { + } + + class InstanceCallback_69 { + } + + class InstanceCallback_70 { + } + + class InstanceCallback_71 { + } + + class InstanceCallback_72 { + } + + class InstanceCallback_73 { + } + + class InstanceCallback_74 { + } + + class InstanceCallback_75 { + } + + class InstanceCallback_76 { + } + + class InstanceCallback_77 { + } + + class InstanceCallback_78 { + } + + class InstanceCallback_79 { + } + + class InstanceCallback_80 { + } + + class InstanceCallback_81 { + } + + class InstanceCallback_82 { + } + + class InstanceCallback_83 { + } + + class InstanceCallback_84 { + } + + class InstanceCallback_85 { + } + + class InstanceCallback_86 { + } + + class InstanceCallback_87 { + } + + class InstanceCallback_88 { + } + + class InstanceCallback_89 { + } + + class InstanceCallback_90 { + } + + class InstanceCallback_91 { + } + + class InstanceCallback_92 { + } + + class InstanceCallback_93 { + } + + class InstanceCallback_94 { + } + + class InstanceCallback_95 { + } + + class InstanceCallback_96 { + } + + class InstanceCallback_97 { + } + + class InstanceCallback_98 { + } + + class InstanceCallback_99 { + } + + class InstanceCallback_100 { + } + + class InstanceCallback_101 { + } + + class InstanceCallback_102 { + } + + class InstanceCallback_103 { + } + + class InstanceCallback_104 { + } + + class InstanceCallback_105 { + } + + class InstanceCallback_106 { + } + + class InstanceCallback_107 { + } + + class InstanceCallback_108 { + } + + class InstanceCallback_109 { + } + + class InstanceCallback_110 { + } + + class InstanceCallback_111 { + } + + class InstanceCallback_112 { + } + + class InstanceCallback_113 { + } + + class InstanceCallback_114 { + } + + class InstanceCallback_115 { + } + + class InstanceCallback_116 { + } + + class InstanceCallback_117 { + } + + class InstanceCallback_118 { + } + + class InstanceCallback_119 { + } + + class InstanceCallback_120 { + } + + class InstanceCallback_121 { + } + + class InstanceCallback_122 { + } + + class InstanceCallback_123 { + } + + class InstanceCallback_124 { + } + + class InstanceCallback_125 { + } + + class InstanceCallback_126 { + } + + class InstanceCallback_127 { + } +} From 5a22fc401f7503679a5fabe5c8f692f46d8ac550 Mon Sep 17 00:00:00 2001 From: command-line Date: Tue, 6 Jun 2023 22:18:55 +0100 Subject: [PATCH 032/228] add test --- .../generation/callback/CallbackNodeTest.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java index ab7a0a05c..3fe95142b 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java @@ -4,7 +4,9 @@ import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; import com.fluxtion.runtime.annotations.OnTrigger; import com.fluxtion.runtime.callback.CallBackNode; +import lombok.Data; import lombok.Value; +import org.junit.Assert; import org.junit.Test; public class CallbackNodeTest extends MultipleSepTargetInProcessTest { @@ -14,19 +16,37 @@ public CallbackNodeTest(SepTestConfig testConfig) { @Test public void directInvokeTest() { - writeOutputsToFile(true); sep(c -> { - c.addNode(new Child(new ExternalCallback("callback1"))); - c.addNode(new Child(new ExternalCallback("callback2"))); + c.addNode(new Child(new ExternalCallback("callback1")), "child1"); + c.addNode(new Child(new ExternalCallback("callback2")), "child2"); }); + Child child1 = getField("child1"); + Child child2 = getField("child2"); + ExternalCallback callback1 = getField("callback1"); + ExternalCallback callback2 = getField("callback2"); + + callback1.doubleEvent(new MyEvent<>(32.4)); + Assert.assertEquals(32.4, (Double) child1.getResult(), 0.0001); + Assert.assertNull(child2.getResult()); + callback1.stringEvent(new MyEvent<>("jjjj")); + Assert.assertEquals("jjjj", child1.getResult()); + Assert.assertNull(child2.getResult()); + + child1.setResult(null); + child2.setResult(null); - ExternalCallback callback2 = getField("callback2"); callback2.doubleEvent(new MyEvent<>(32.4)); + Assert.assertNull(child1.getResult()); + Assert.assertEquals(32.4, (Double) child2.getResult(), 0.0001); + + callback2.stringEvent(new MyEvent<>("jjjj")); + Assert.assertNull(child1.getResult()); + Assert.assertEquals("jjjj", child2.getResult()); } @@ -50,13 +70,14 @@ public void doubleEvent(MyEvent myEvent) { } - @Value + @Data public static class Child { - ExternalCallback externalCallback; + private final ExternalCallback externalCallback; + private Object result; @OnTrigger public boolean triggered() { - System.out.println("parent:" + externalCallback.getName() + " updated:" + externalCallback.update); + result = externalCallback.update; return true; } } From 70dde30580becb573ef0104f675cd3627c4802e9 Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 6 Jun 2023 21:31:48 +0000 Subject: [PATCH 033/228] updating poms for 9.0.8-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 66a234ebf..320d53b07 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.7-SNAPSHOT + 9.0.8-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2fe4219b0..47dc80c48 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.7-SNAPSHOT + 9.0.8-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 0c86eb2d3..42029907c 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.7-SNAPSHOT + 9.0.8-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index a8d2be8ac..b63fc65b8 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.7-SNAPSHOT + 9.0.8-SNAPSHOT ../parent-root/pom.xml From bc498d24d729814629164d30ce576368997c1bc7 Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 6 Jun 2023 21:31:52 +0000 Subject: [PATCH 034/228] updating poms for branch'release/9.0.7' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 66a234ebf..b8cf982b3 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.7-SNAPSHOT + 9.0.7 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2fe4219b0..93c4b3f09 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.7-SNAPSHOT + 9.0.7 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 0c86eb2d3..db2f5dc74 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.7-SNAPSHOT + 9.0.7 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index a8d2be8ac..fd877cbc9 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.7-SNAPSHOT + 9.0.7 ../parent-root/pom.xml From 891411125f61c8e97ab9ff264ac5924062af846d Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 6 Jun 2023 21:35:56 +0000 Subject: [PATCH 035/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 320d53b07..b8cf982b3 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.8-SNAPSHOT + 9.0.7 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 47dc80c48..93c4b3f09 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.8-SNAPSHOT + 9.0.7 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 42029907c..db2f5dc74 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.8-SNAPSHOT + 9.0.7 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index b63fc65b8..fd877cbc9 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.8-SNAPSHOT + 9.0.7 ../parent-root/pom.xml From 2d0cb792b04f66b12627e399f9ca26c174a4ac14 Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 6 Jun 2023 21:35:56 +0000 Subject: [PATCH 036/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index b8cf982b3..320d53b07 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.7 + 9.0.8-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 93c4b3f09..47dc80c48 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.7 + 9.0.8-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index db2f5dc74..42029907c 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.7 + 9.0.8-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fd877cbc9..b63fc65b8 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.7 + 9.0.8-SNAPSHOT ../parent-root/pom.xml From ee297856ed2dc93f398f0c4bc65ffa4ba336a2c8 Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 7 Jun 2023 22:25:11 +0100 Subject: [PATCH 037/228] added callback node --- docs/_config.yml | 16 +- docs/cookbook/node_callbacks.md | 210 +++++++++++++++++++++++++++ docs/cookbook/parallel_processing.md | 2 +- 3 files changed, 219 insertions(+), 9 deletions(-) create mode 100644 docs/cookbook/node_callbacks.md diff --git a/docs/_config.yml b/docs/_config.yml index 8f95a38be..c806a82fa 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -23,8 +23,8 @@ title: Fluxtion streaming description: Documentation for Fluxtion event processor remote_theme: pmarsceill/just-the-docs aux_links: - "release 9.0.1": - - "//github.com/v12technology/fluxtion/tree/9.0.1" + "release 9.0.7": + - "//github.com/v12technology/fluxtion/tree/9.0.7" heading_anchors: true # Color scheme supports "light" (default) and "dark" @@ -39,12 +39,12 @@ kramdown: block: line_numbers: true -fluxtion_version: 9.0.1 -fluxtion_src: https://github.com/v12technology/fluxtion/blob/9.0.1 -fluxtion_src_runtime: https://github.com/v12technology/fluxtion/blob/9.0.1/runtime/src/main/java/com/fluxtion/runtime -fluxtion_src_compiler: https://github.com/v12technology/fluxtion/blob/9.0.1/compiler/src/main/java/com/fluxtion/compiler -EventProcessor_link: https://github.com/v12technology/fluxtion/blob/9.0.1/runtime/src/main/java/com/fluxtion/runtime/EventProcessor.java -Fluxtion_link: https://github.com/v12technology/fluxtion/blob/9.0.1/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java +fluxtion_version: 9.0.7 +fluxtion_src: https://github.com/v12technology/fluxtion/blob/9.0.7 +fluxtion_src_runtime: https://github.com/v12technology/fluxtion/blob/9.0.7/runtime/src/main/java/com/fluxtion/runtime +fluxtion_src_compiler: https://github.com/v12technology/fluxtion/blob/9.0.7/compiler/src/main/java/com/fluxtion/compiler +EventProcessor_link: https://github.com/v12technology/fluxtion/blob/9.0.7/runtime/src/main/java/com/fluxtion/runtime/EventProcessor.java +Fluxtion_link: https://github.com/v12technology/fluxtion/blob/9.0.7/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java cookbook_src: https://github.com/v12technology/fluxtion-examples/tree/cook_subscription_example/cookbook/src/main/java/com/fluxtion/example/cookbook/ ga_tracking: G-NGDV621P1P diff --git a/docs/cookbook/node_callbacks.md b/docs/cookbook/node_callbacks.md new file mode 100644 index 000000000..194b32bbd --- /dev/null +++ b/docs/cookbook/node_callbacks.md @@ -0,0 +1,210 @@ +--- +title: Node callback pattern +parent: Cookbook +has_children: false +nav_order: 3 +published: true +example_src: https://github.com/v12technology/fluxtion-examples/tree/main/cookbook/src/main/java/com/fluxtion/example/cookbook/nodecallback +--- + +## Introduction + +This example demonstrates invoking instances in a graph by direct function calls and the instance method triggering a graph processing +cycle. Dependencies of the callback node are triggered as if the method was annotated with an EventHandler annotation. +The callback pattern allows targeting of a single instance in a graph. + + +[See the example here]({{page.example_src}}/Main.java) + + +Sometimes a user will want to target a graph node function directly to trigger a graph cycle. Using EventHandler +annotation on a method is analogous to listening to a topic in a message system, while the node call back pattern is +like having a queue with a single listener. + +## Steps to register a call back +In order for a node to available as a uniquely addressable call back node the following steps are required + +1. The node must inherit from [CallBackNode]({{site.fluxtion_src_runtime}}/callback/CallBackNode.java) +2. The node must call the super constructor with a unique name, this allows the node to found via its name +3. To trigger a graph cycle from a method call [CallBackNode#triggerGraphCycle]({{site.fluxtion_src_runtime}}/callback/CallBackNode.java#52) +4. Add the node as normal to Fluxtion, build the graph and call init() on the event processor + +## Accessing the node +Once the graph is built and init() is called the callback node can be invoked to trigger graph cycles. But first the node must +be discovered and referenced from outside the graph. There are a number of strategies to do this: + +1. Call ```EventProcessor.getNodeById('node_name');``` using the name supplied in the node constructor +2. Pass a mutable event into the graph the node is listening for. The node adds its reference to the event +3. Inject an instance to the node and the node registers itself with the injected instance at startup +4. Create an interface with default methods implementations using (1) above, make the EventProcessor implement the interface + +The example uses the first of these approaches, ```EventProcessor.getNodeById('node_name');``` + +## Example + +[See the example here]({{page.example_src}}/Main.java) + +The example tracks voting candidates and gathers the results into a collector for printing. The classes in the example are: +- [Main]({{page.example_src}}/Main.java) method, builds the graph, finds the callback nodes by name and invokes functions on the nodes directly +- [CandidateVoteHandler]({{page.example_src}}/CandidateVoteHandler.java) is a call back node that can trigger graph cycles +- [ElectionTracker]({{page.example_src}}/ElectionTracker.java) Aggregates CandidateVoteHandlers, annotated methods receive callbacks during a graph cycle and prints results. +- [VoteData]({{page.example_src}}/VoteData.java) Generic data record that holds voting information updates. + +Although each CandidateVoteHandler has the same method signature only the targeted callback instance is invoked during +execution. + +### CandidateVoteHandler +Extends CallBackNode and uses base methods to trigger graph cycles. + +{% highlight java %} +public class CandidateVoteHandler extends CallBackNode { + + private int updateId; + private String lastNewsStory = ""; + private int totalVotes; + + public CandidateVoteHandler(String name) { + super(name); + } + + public void newStory(VoteData argument, int updateId) { + this.updateId = updateId; + this.lastNewsStory = argument.value(); + super.triggerGraphCycle(); + } + + public void voteCountUpdate(VoteData argument, int updateId) { + this.updateId = updateId; + this.totalVotes += argument.value(); + super.triggerGraphCycle(); + } + + @Override + public String toString() { + return getName() + + ", totalVotes=" + totalVotes + + ", updateId=" + updateId + + ", lastNewsStory='" + lastNewsStory + '\'' + ; + } +} +{% endhighlight %} + + +### Main +Builds the graph, finds CandidateVoteHandler nodes by name and invokes methods on the instances directly to trigger +graph process cycles. + +{% highlight java %} +public class Main { + + public static void main(String[] args) throws NoSuchFieldException { + var voteProcessor = Fluxtion.interpret(c -> c.addNode(new ElectionTracker(List.of( + new CandidateVoteHandler("Red_party"), + new CandidateVoteHandler("Blue_party"), + new CandidateVoteHandler("Green_party") + )))); + voteProcessor.init(); + + //get the nodes by name from the graph + CandidateVoteHandler redPartyNode = voteProcessor.getNodeById("Red_party"); + CandidateVoteHandler bluePartyNode = voteProcessor.getNodeById("Blue_party"); + CandidateVoteHandler greenPartyNode = voteProcessor.getNodeById("Green_party"); + + //invoke functions directly on nodes - creates a + redPartyNode.voteCountUpdate(new VoteData<>(25), 1); + bluePartyNode.voteCountUpdate(new VoteData<>(12), 2); + bluePartyNode.voteCountUpdate(new VoteData<>(19), 3); + bluePartyNode.voteCountUpdate(new VoteData<>(50), 4); + redPartyNode.newStory(new VoteData<>("red alert!!"), 5); + greenPartyNode.newStory(new VoteData<>("green and gone :("), 6); + greenPartyNode.voteCountUpdate(new VoteData<>(2), 1); + } +} +{% endhighlight %} + + +### ElectionTracker +Aggregated CandidateVoteHandlers and annotated methods receive callbacks during a graph cycle + +{% highlight java %} +public record ElectionTracker(List candidateVoteHandlers) { + + @OnParentUpdate + public void updatedCandidateStatus(CandidateVoteHandler candidateVoteHandler) { + System.out.println("update for:" + candidateVoteHandler.getName()); + } + + @OnTrigger + public boolean printLatestResults() { + String result = candidateVoteHandlers.stream() + .map(Objects::toString) + .collect(Collectors.joining("\n\t", "\t", "\n\n")); + System.out.println(result); + return true; + } +} +{% endhighlight %} + + +### VoteData +Generic data holder used as function arguments + +{% highlight java %} +public record VoteData(T value) { } +{% endhighlight %} + + +## Execution output + + +Running the sample produces this output: + +{% highlight console %} +update for:Red_party +Red_party, totalVotes=25, updateId=1, lastNewsStory='' +Blue_party, totalVotes=0, updateId=0, lastNewsStory='' +Green_party, totalVotes=0, updateId=0, lastNewsStory='' + + +update for:Blue_party +Red_party, totalVotes=25, updateId=1, lastNewsStory='' +Blue_party, totalVotes=12, updateId=2, lastNewsStory='' +Green_party, totalVotes=0, updateId=0, lastNewsStory='' + + +update for:Blue_party +Red_party, totalVotes=25, updateId=1, lastNewsStory='' +Blue_party, totalVotes=31, updateId=3, lastNewsStory='' +Green_party, totalVotes=0, updateId=0, lastNewsStory='' + + +update for:Blue_party +Red_party, totalVotes=25, updateId=1, lastNewsStory='' +Blue_party, totalVotes=81, updateId=4, lastNewsStory='' +Green_party, totalVotes=0, updateId=0, lastNewsStory='' + + +update for:Red_party +Red_party, totalVotes=25, updateId=5, lastNewsStory='red alert!!' +Blue_party, totalVotes=81, updateId=4, lastNewsStory='' +Green_party, totalVotes=0, updateId=0, lastNewsStory='' + + +update for:Green_party +Red_party, totalVotes=25, updateId=5, lastNewsStory='red alert!!' +Blue_party, totalVotes=81, updateId=4, lastNewsStory='' +Green_party, totalVotes=0, updateId=6, lastNewsStory='green and gone :(' + + +update for:Green_party +Red_party, totalVotes=25, updateId=5, lastNewsStory='red alert!!' +Blue_party, totalVotes=81, updateId=4, lastNewsStory='' +Green_party, totalVotes=2, updateId=1, lastNewsStory='green and gone :(' +{% endhighlight %} + + + + + + diff --git a/docs/cookbook/parallel_processing.md b/docs/cookbook/parallel_processing.md index aeb6e0dae..b492bdcdd 100644 --- a/docs/cookbook/parallel_processing.md +++ b/docs/cookbook/parallel_processing.md @@ -2,7 +2,7 @@ title: Parallel processing parent: Cookbook has_children: false -nav_order: 7 +nav_order: 8 published: true example_src: https://github.com/v12technology/fluxtion-examples/tree/main/cookbook/src/main/java/com/fluxtion/example/cookbook/parallel --- From 8d94fc1008f18ed98e449f0e72e8bc011818d09a Mon Sep 17 00:00:00 2001 From: command-line Date: Sun, 11 Jun 2023 22:36:12 +0100 Subject: [PATCH 038/228] added support for exporting functions --- .../compiler/EventProcessorConfig.java | 3 +- .../generation/GenerationContext.java | 6 +- .../ValidateExportFunctionAnnotations.java | 53 ++ .../generation/model/ExportFunctionData.java | 34 ++ .../model/SimpleEventProcessorModel.java | 39 +- .../TopologicallySortedDependencyGraph.java | 32 +- .../targets/JavaSourceGenerator.java | 34 ++ .../compiler/generation/util/ClassUtils.java | 111 ++++ .../gradle/incremental.annotation.processors | 3 +- .../resources/template/base/javaTemplate.vsl | 2 + .../exportfunction/ExportFunctionTest.java | 114 ++++ .../exportfunction/MyExportedInterface.java | 12 + .../generation/util/ClassUtilsTest.java | 85 ++- .../com/fluxtion/runtime/NodeDiscovery.java | 6 + .../runtime/StaticEventProcessor.java | 2 +- .../runtime/annotations/ExportFunction.java | 35 ++ .../runtime/callback/CallBackNode.java | 2 +- .../runtime/callback/ExportFunctionNode.java | 39 ++ .../callback/ExportFunctionTrigger.java | 79 +++ .../callback/ExportFunctionTriggerEvent.java | 535 +++++++++++++++++ .../runtime/callback/InstanceCallback.java | 536 ----------------- .../callback/InstanceCallbackEvent.java | 537 ++++++++++++++++++ .../runtime/partition/Partitioner.java | 37 +- .../runtime/partition/PartitionerTest.java | 5 +- 24 files changed, 1741 insertions(+), 600 deletions(-) create mode 100644 compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java create mode 100644 compiler/src/main/java/com/fluxtion/compiler/generation/model/ExportFunctionData.java create mode 100644 compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java create mode 100644 compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/MyExportedInterface.java create mode 100644 runtime/src/main/java/com/fluxtion/runtime/NodeDiscovery.java create mode 100644 runtime/src/main/java/com/fluxtion/runtime/annotations/ExportFunction.java create mode 100644 runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionNode.java create mode 100644 runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTrigger.java create mode 100644 runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTriggerEvent.java delete mode 100644 runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallback.java create mode 100644 runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallbackEvent.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java b/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java index 3180d004a..1b23244cf 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java +++ b/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java @@ -139,7 +139,8 @@ public T addNode(T node) { return (T) getNodeList().get(getNodeList().indexOf(node)); } - public void addNode(Object... nodeList) { + public void addNode(Object node, Object... nodeList) { + addNode(node); Arrays.asList(nodeList).forEach(this::addNode); } diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/GenerationContext.java b/compiler/src/main/java/com/fluxtion/compiler/generation/GenerationContext.java index cca2da8af..4617c4325 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/GenerationContext.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/GenerationContext.java @@ -16,7 +16,7 @@ */ package com.fluxtion.compiler.generation; -import com.fluxtion.runtime.callback.InstanceCallback; +import com.fluxtion.runtime.callback.InstanceCallbackEvent; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; @@ -186,7 +186,7 @@ private GenerationContext(String packageName, String sepClassName, File outputDi log.info("classloader:{}", this.classLoader); log.debug("built GenerationContext: {}", this); cacheMap = new HashMap<>(); - InstanceCallback.reset(); + InstanceCallbackEvent.reset(); } private GenerationContext(ClassLoader classLoasder, String packageName, String sepClassName, File outputDirectory, File resourcesRootDirectory, File buildOutputDirectory) { @@ -196,7 +196,7 @@ private GenerationContext(ClassLoader classLoasder, String packageName, String s this.resourcesRootDirectory = resourcesRootDirectory; this.classLoader = classLoasder; cacheMap = new HashMap<>(); - InstanceCallback.reset(); + InstanceCallbackEvent.reset(); log.debug("built GenerationContext: {}", this); } diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java b/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java new file mode 100644 index 000000000..c0565bc66 --- /dev/null +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java @@ -0,0 +1,53 @@ +package com.fluxtion.compiler.generation.annotationprocessor; + +import com.fluxtion.runtime.annotations.ExportFunction; +import com.google.auto.service.AutoService; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.Processor; +import javax.annotation.processing.RoundEnvironment; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.ExecutableType; +import javax.lang.model.type.TypeKind; +import javax.tools.Diagnostic; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +@AutoService(Processor.class) +public class ValidateExportFunctionAnnotations extends AbstractProcessor { + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + for (TypeElement annotation : annotations) { + Set annotatedElements = roundEnv.getElementsAnnotatedWith(annotation); + Set typeElements = annotatedElements.stream() + .filter(element -> + ((ExecutableType) element.asType()).getReturnType().getKind() != TypeKind.BOOLEAN + || !element.getModifiers().contains(Modifier.PUBLIC) + ) + .collect(Collectors.toSet()); + + typeElements.forEach(element -> + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, + "exported method should be public method and a boolean return type" + + element.getSimpleName(), element)); + + } + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latestSupported(); + } + + @Override + public Set getSupportedAnnotationTypes() { + Set supportedAnnotations = new HashSet<>(); + supportedAnnotations.add(ExportFunction.class.getCanonicalName()); + return supportedAnnotations; + } +} diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/model/ExportFunctionData.java b/compiler/src/main/java/com/fluxtion/compiler/generation/model/ExportFunctionData.java new file mode 100644 index 000000000..5bdf864c9 --- /dev/null +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/model/ExportFunctionData.java @@ -0,0 +1,34 @@ +package com.fluxtion.compiler.generation.model; + +import com.fluxtion.runtime.callback.ExportFunctionTrigger; + +import java.util.ArrayList; +import java.util.List; + +public class ExportFunctionData { + + private final String publicMethodName; + private final ExportFunctionTrigger exportFunctionTrigger = new ExportFunctionTrigger(); + private final List functionCallBackList = new ArrayList<>(); + + public ExportFunctionData(String publicMethodName) { + this.publicMethodName = publicMethodName; + } + + public String getPublicMethodName() { + return publicMethodName; + } + + public ExportFunctionTrigger getExportFunctionTrigger() { + return exportFunctionTrigger; + } + + public List getFunctionCallBackList() { + return functionCallBackList; + } + + public void addCbMethodHandle(CbMethodHandle cbMethodHandle) { + functionCallBackList.add(cbMethodHandle); + exportFunctionTrigger.getFunctionPointerList().add(cbMethodHandle.getInstance()); + } +} diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/model/SimpleEventProcessorModel.java b/compiler/src/main/java/com/fluxtion/compiler/generation/model/SimpleEventProcessorModel.java index beb9c675e..f3ef63398 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/model/SimpleEventProcessorModel.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/model/SimpleEventProcessorModel.java @@ -25,7 +25,21 @@ import com.fluxtion.compiler.generation.serialiser.FieldSerializer; import com.fluxtion.compiler.generation.util.ClassUtils; import com.fluxtion.compiler.generation.util.NaturalOrderComparator; -import com.fluxtion.runtime.annotations.*; +import com.fluxtion.runtime.annotations.AfterEvent; +import com.fluxtion.runtime.annotations.AfterTrigger; +import com.fluxtion.runtime.annotations.FilterId; +import com.fluxtion.runtime.annotations.FilterType; +import com.fluxtion.runtime.annotations.Initialise; +import com.fluxtion.runtime.annotations.NoTriggerReference; +import com.fluxtion.runtime.annotations.OnBatchEnd; +import com.fluxtion.runtime.annotations.OnBatchPause; +import com.fluxtion.runtime.annotations.OnEventHandler; +import com.fluxtion.runtime.annotations.OnParentUpdate; +import com.fluxtion.runtime.annotations.OnTrigger; +import com.fluxtion.runtime.annotations.PushReference; +import com.fluxtion.runtime.annotations.Start; +import com.fluxtion.runtime.annotations.Stop; +import com.fluxtion.runtime.annotations.TearDown; import com.fluxtion.runtime.annotations.builder.AssignToField; import com.fluxtion.runtime.annotations.builder.ConstructorArg; import com.fluxtion.runtime.event.Event; @@ -42,9 +56,24 @@ import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; -import java.lang.reflect.*; -import java.util.*; +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; +import java.util.OptionalInt; +import java.util.Set; import java.util.logging.Level; import java.util.stream.Collectors; @@ -1150,6 +1179,10 @@ public Map, Map>> getHandlerOnl return Collections.unmodifiableMap(handlerOnlyDispatchMap); } + public Map getExportedFunctionMap() { + return Collections.unmodifiableMap(dependencyGraph.getExportedFunctionMap()); + } + public Map> getParentUpdateListenerMethodMap() { return Collections.unmodifiableMap(parentUpdateListenerMethodMap); } diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java b/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java index dce8aea00..c7bced588 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java @@ -29,6 +29,7 @@ import com.fluxtion.compiler.generation.util.NaturalOrderComparator; import com.fluxtion.runtime.annotations.AfterEvent; import com.fluxtion.runtime.annotations.AfterTrigger; +import com.fluxtion.runtime.annotations.ExportFunction; import com.fluxtion.runtime.annotations.Initialise; import com.fluxtion.runtime.annotations.NoTriggerReference; import com.fluxtion.runtime.annotations.OnBatchEnd; @@ -106,6 +107,11 @@ public class TopologicallySortedDependencyGraph implements NodeRegistry { private final Set pushEdges = new HashSet<>(); private final List topologicalHandlers = new ArrayList<>(); private final List noPushTopologicalHandlers = new ArrayList<>(); + /** + * Map of all the public functions that are exported with {@link ExportFunction} + * annotation + */ + private final Map exportedFunctionMap; private final NodeFactoryRegistration nodeFactoryRegistration; private final HashMap, CbMethodHandle> class2FactoryMethod; private final HashMap name2FactoryMethod; @@ -160,6 +166,7 @@ public TopologicallySortedDependencyGraph(List nodes, Map pub this.inst2NameTemp = HashBiMap.create(); this.class2FactoryMethod = new HashMap<>(); this.name2FactoryMethod = new HashMap<>(); + this.exportedFunctionMap = new HashMap<>(); if (nodes == null) { nodes = Collections.EMPTY_LIST; } @@ -250,6 +257,10 @@ public List getObjectSortedDependents() throws Exception { return Collections.unmodifiableList(noPushTopologicalHandlers); } + public Map getExportedFunctionMap() { + return Collections.unmodifiableMap(exportedFunctionMap); + } + //TODO this should be a list that is sorted topologically and then // with natural order public Map getRegistrationListenerMap() { @@ -562,6 +573,7 @@ public synchronized void generateDependencyTree() throws Exception { inst2Name.putAll(inst2NameTemp); inst2Name.entrySet().removeIf(o -> Anchor.class.isAssignableFrom(o.getKey().getClass())); inst2Name.entrySet().removeIf(o -> o.getKey().getClass().isAnnotationPresent(ExcludeNode.class)); + inst2Name.keySet().forEach(this::addExportedMethods); //all instances are in inst2Name, can now generate final graph for (Map.Entry entry : inst2Name.entrySet()) { @@ -745,6 +757,24 @@ private void walkDependenciesForEventHandling(Object object) throws IllegalArgum } } + private void addExportedMethods(Object object) { + final Class clazz = object.getClass(); + + Set exportMethodSet = ReflectionUtils.getAllMethods(clazz, ReflectionUtils.withAnnotation(ExportFunction.class)); + exportMethodSet.forEach(method -> { + String exportMethodName = method.getAnnotation(ExportFunction.class).value(); + ExportFunctionData exportFunctionData = exportedFunctionMap.computeIfAbsent( + exportMethodName, n -> { + ExportFunctionData data = new ExportFunctionData(exportMethodName); + registerNode(data.getExportFunctionTrigger(), null); + return data; + }); + final String name = inst2Name.get(object); + exportFunctionData.getExportFunctionTrigger().getFunctionPointerList().add(object); + exportFunctionData.addCbMethodHandle(new CbMethodHandle(method, object, name)); + }); + } + @SuppressWarnings("unchecked") private String getInstanceName(Field field, Object node) throws IllegalArgumentException, IllegalAccessException { Object refField = field.get(node); @@ -800,6 +830,7 @@ private Predicate annotationPredicate() { .or(ReflectionUtils.withAnnotation(TearDown.class)) .or(ReflectionUtils.withAnnotation(Initialise.class)) .or(ReflectionUtils.withAnnotation(TriggerEventOverride.class)) + .or(ReflectionUtils.withAnnotation(ExportFunction.class)) ; } @@ -1083,5 +1114,4 @@ public void exportAsGraphMl(Writer writer, boolean addEvents) throws SAXExceptio private String nameNode(Object node) { return nameStrategy.mappedNodeName(node); } - } diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/JavaSourceGenerator.java b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/JavaSourceGenerator.java index 32d6434ce..0aeba5fc7 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/JavaSourceGenerator.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/JavaSourceGenerator.java @@ -23,6 +23,7 @@ import com.fluxtion.compiler.generation.GenerationContext; import com.fluxtion.compiler.generation.model.CbMethodHandle; import com.fluxtion.compiler.generation.model.DirtyFlag; +import com.fluxtion.compiler.generation.model.ExportFunctionData; import com.fluxtion.compiler.generation.model.Field; import com.fluxtion.compiler.generation.model.InvokerFilterTarget; import com.fluxtion.compiler.generation.model.SimpleEventProcessorModel; @@ -56,6 +57,7 @@ import java.util.Map.Entry; import java.util.Objects; import java.util.Set; +import java.util.StringJoiner; import java.util.stream.Collectors; import static com.fluxtion.compiler.generation.targets.JavaGenHelper.mapPrimitiveToWrapper; @@ -211,6 +213,10 @@ public class JavaSourceGenerator { * event type, will include branching based on filterId. */ private String eventHandlers; + /** + * String representing exported events + */ + private String exportedMethods; /** * determines whether separate delegate eventHandling methods are generated. */ @@ -264,6 +270,7 @@ public void buildSourceModel() throws Exception { buildForkAwareMethodSource(model.getEventEndMethods(), eventEndMethodList); buildMethodSource(model.getBatchEndMethods(), batchEndMethodList); buildMethodSource(model.getTearDownMethods(), tearDownMethodList); + buildExportedMethods(); addDefaultImports(); buildNodeDeclarations(); buildDirtyFlags(); @@ -351,6 +358,29 @@ private void buildMethodSource(List methodList, List met } } + private void buildExportedMethods() { + Map exportedFunctionDataMap = model.getExportedFunctionMap(); + List keys = new ArrayList<>(exportedFunctionDataMap.keySet()); + keys.sort(String::compareTo); + StringJoiner joiner = new StringJoiner("\n"); + joiner.setEmptyValue(""); +// //filtered +// for (String key : keys) { +// List cbMethodHandles = exportedFunctionMap.get(key); +// if (!cbMethodHandles.isEmpty()) { +// CbMethodHandle cbMethodHandle = cbMethodHandles.get(0); +// joiner.add(ClassUtils.wrapNodeCall(cbMethodHandle.getMethod(), key, cbMethodHandle.getVariableName())); +// } +// } + //multicast + for (String key : keys) { + if (!exportedFunctionDataMap.get(key).getFunctionCallBackList().isEmpty()) { + joiner.add(ClassUtils.wrapExportedFunctionCall(key, exportedFunctionDataMap.get(key), model)); + } + } + exportedMethods = joiner.toString(); + } + private void buildForkAwareMethodSource(List methodList, List methodSourceList) { Set forkedTriggers = model.getForkedTriggerInstances(); resetForkTasks = model.getTriggerOnlyCallBacks().stream() @@ -1269,6 +1299,10 @@ public String getEventHandlers() { return eventHandlers; } + public String getExportedMethods() { + return exportedMethods; + } + public String getNodeDeclarations() { return nodeDeclarations; } diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java index 2b1df6b47..4fd73ea11 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java @@ -18,19 +18,26 @@ package com.fluxtion.compiler.generation.util; import com.fluxtion.compiler.generation.model.CbMethodHandle; +import com.fluxtion.compiler.generation.model.ExportFunctionData; import com.fluxtion.compiler.generation.model.Field; +import com.fluxtion.compiler.generation.model.SimpleEventProcessorModel; +import lombok.SneakyThrows; import net.vidageek.mirror.dsl.Mirror; import org.reflections.ReflectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.beans.PropertyDescriptor; +import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.StringJoiner; +import java.util.concurrent.atomic.LongAdder; import java.util.stream.Collectors; /** @@ -131,4 +138,108 @@ static List> sortClassHierarchy(Set> classSet) { }); return clazzSorted; } + + @SneakyThrows + static String wrapExportedFunctionCall(Method delegateMethod, String exportedMethodName, String instanceName) { + LongAdder argNumber = new LongAdder(); + StringBuilder signature = new StringBuilder("public void " + exportedMethodName); + signature.append('('); + StringJoiner sj = new StringJoiner(", "); + Type[] params = delegateMethod.getGenericParameterTypes(); + for (int j = 0; j < params.length; j++) { + String param = params[j].getTypeName(); + if (delegateMethod.isVarArgs() && (j == params.length - 1)) // replace T[] with T... + param = param.replaceFirst("\\[\\]$", "..."); + param += " arg" + argNumber.intValue(); + sj.add(param); + argNumber.increment(); + } + signature.append(sj.toString()); + signature.append(", String identifer"); + signature.append("){"); + signature.append("try {\n" + + " ExportingNode instance = getNodeById(identifer);"); + signature.append("\n instance." + delegateMethod.getName() + "("); + StringJoiner sjInvoker = new StringJoiner(", "); + for (int i = 0; i < argNumber.intValue(); i++) { + sjInvoker.add("arg" + i); + } + signature.append(sjInvoker.toString()); + signature.append(");\n"); + signature.append("} catch (NoSuchFieldException e) {\n" + + " throw new RuntimeException(e);\n" + + " }" + + " }"); + return signature.toString(); + } + + @SneakyThrows + static String wrapExportedFunctionCall(String exportedMethodName, List callBackList, SimpleEventProcessorModel model) { + LongAdder argNumber = new LongAdder(); + Method delegateMethod = callBackList.get(0).getMethod(); + StringBuilder signature = new StringBuilder("public void " + exportedMethodName); + signature.append('('); + StringJoiner sj = new StringJoiner(", "); + Type[] params = delegateMethod.getGenericParameterTypes(); + for (int j = 0; j < params.length; j++) { + String param = params[j].getTypeName(); + if (delegateMethod.isVarArgs() && (j == params.length - 1)) // replace T[] with T... + param = param.replaceFirst("\\[\\]$", "..."); + param += " arg" + argNumber.intValue(); + sj.add(param); + argNumber.increment(); + } + signature.append(sj); + signature.append("){"); + //method calls + StringJoiner sjInvoker = new StringJoiner(", ", "(", "));"); + for (int i = 0; i < argNumber.intValue(); i++) { + sjInvoker.add("arg" + i); + } + callBackList.forEach(cb -> { + signature.append("setDirty(").append(cb.getVariableName()).append(", "). + append(cb.getVariableName()).append(".").append(cb.getMethod().getName()).append(sjInvoker); + }); + //close + signature.append(" triggerCalculation();\n }"); + return signature.toString(); + } + + @SneakyThrows + static String wrapExportedFunctionCall(String exportedMethodName, ExportFunctionData exportFunctionData, SimpleEventProcessorModel model) { + LongAdder argNumber = new LongAdder(); + List callBackList = exportFunctionData.getFunctionCallBackList(); + Method delegateMethod = callBackList.get(0).getMethod(); + StringBuilder signature = new StringBuilder("public void " + exportedMethodName); + signature.append('('); + StringJoiner sj = new StringJoiner(", "); + Type[] params = delegateMethod.getGenericParameterTypes(); + for (int j = 0; j < params.length; j++) { + String param = params[j].getTypeName(); + if (delegateMethod.isVarArgs() && (j == params.length - 1)) // replace T[] with T... + param = param.replaceFirst("\\[\\]$", "..."); + param += " arg" + argNumber.intValue(); + sj.add(param); + argNumber.increment(); + } + signature.append(sj); + signature.append("){"); + //method calls + StringJoiner sjInvoker = new StringJoiner(", ", "(", "));\n"); + for (int i = 0; i < argNumber.intValue(); i++) { + sjInvoker.add("arg" + i); + } + callBackList.forEach(cb -> { + String variableName = cb.getVariableName(); + signature.append(variableName).append(".setTriggered("). + append(variableName).append(".").append(cb.getMethod().getName()).append(sjInvoker); + }); + //close + //onEvent(handlerExportFunctionTriggerEvent_0.getEvent()); + signature.append("onEvent(") + .append(exportFunctionData.getExportFunctionTrigger().getName()).append(".getEvent());\n") + .append("}"); + return signature.toString(); + } + } diff --git a/compiler/src/main/resources/META-INF/gradle/incremental.annotation.processors b/compiler/src/main/resources/META-INF/gradle/incremental.annotation.processors index 357915a4b..52a0b16fc 100644 --- a/compiler/src/main/resources/META-INF/gradle/incremental.annotation.processors +++ b/compiler/src/main/resources/META-INF/gradle/incremental.annotation.processors @@ -1,4 +1,5 @@ com.fluxtion.compiler.generation.annotationprocessor.ValidateEventHandlerAnnotations,isolating com.fluxtion.compiler.generation.annotationprocessor.ValidateOnTriggerAnnotations,isolating com.fluxtion.compiler.generation.annotationprocessor.ValidateOnParentUpdateHandlerAnnotations,isolating -com.fluxtion.compiler.generation.annotationprocessor.ValidateLifecycleAnnotations,isolating \ No newline at end of file +com.fluxtion.compiler.generation.annotationprocessor.ValidateLifecycleAnnotations,isolating +com.fluxtion.compiler.generation.annotationprocessor.ValidateExportFunctionAnnotations,isolating \ No newline at end of file diff --git a/compiler/src/main/resources/template/base/javaTemplate.vsl b/compiler/src/main/resources/template/base/javaTemplate.vsl index e636f5ddd..f97a3d691 100644 --- a/compiler/src/main/resources/template/base/javaTemplate.vsl +++ b/compiler/src/main/resources/template/base/javaTemplate.vsl @@ -100,6 +100,8 @@ private final IdentityHashMap> dirtyFlagUpdateMap = ne ${MODEL.eventDispatch} } + ${MODEL.exportedMethods} + ${MODEL.eventHandlers} private void afterEvent() { diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java new file mode 100644 index 000000000..4546dc189 --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java @@ -0,0 +1,114 @@ +package com.fluxtion.compiler.generation.exportfunction; + +import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; +import com.fluxtion.compiler.generation.util.CompiledOnlySepTest; +import com.fluxtion.runtime.annotations.ExportFunction; +import com.fluxtion.runtime.annotations.OnParentUpdate; +import com.fluxtion.runtime.annotations.OnTrigger; +import com.fluxtion.runtime.annotations.builder.AssignToField; +import com.fluxtion.runtime.callback.ExportFunctionNode; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Arrays; +import java.util.List; + +public class ExportFunctionTest extends CompiledOnlySepTest { + public ExportFunctionTest(SepTestConfig compile) { + super(compile); + } + + @Test + public void exportTest() { + writeSourceFile = true; + MyExportedInterface myExportedInterface = (MyExportedInterface) sep(c -> { + c.addNode(new Aggregator( + new ExportingNode("export1"), + new ExportingNode("export2") + ), "aggregator"); + c.addInterfaceImplementation(MyExportedInterface.class); + }); + Aggregator aggregator = getField("aggregator"); + myExportedInterface.updatedDetails("hello", 300); + Assert.assertEquals(2, aggregator.updateCount); + Assert.assertEquals(1, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='updatedDetails s:hello y:300'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='updatedDetails s:hello y:300'}", aggregator.parent2.toString()); + + // + myExportedInterface.complexCallBack(Arrays.asList("", "", ""), 33); + Assert.assertEquals(4, aggregator.updateCount); + Assert.assertEquals(2, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='complexCallBack s:3 y:33'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='complexCallBack s:3 y:33'}", aggregator.parent2.toString()); + + myExportedInterface.complexCallBackDouble(Arrays.asList(24.5), 344); + Assert.assertEquals(4, aggregator.updateCount); + Assert.assertEquals(2, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='complexCallBack s:3 y:33'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='complexCallBack s:3 y:33'}", aggregator.parent2.toString()); + } + + + public static class ExportingNode extends ExportFunctionNode { + + private final String name; + private String result; + + public ExportingNode(String name) { + this.name = name; + } + + + @ExportFunction("updatedDetails") + public boolean myfunction(String s, int y) { + result = "updatedDetails s:" + s + " y:" + y; + return true; + } + + @ExportFunction("complexCallBack") + public boolean myfunction(List s, int y) { + result = "complexCallBack s:" + s.size() + " y:" + y; + return true; + } + + @ExportFunction("complexCallBackDouble") + public boolean myfunctionDouble(List s, int y) { + return false; + } + + @Override + public String toString() { + return "ExportingNode{" + + "name='" + name + '\'' + + ", result='" + result + '\'' + + '}'; + } + } + + + public static class Aggregator { + + public final ExportingNode parent; + public final ExportingNode parent2; + public int updateCount; + public int triggerCount; + + public Aggregator(@AssignToField("parent") ExportingNode parent, + @AssignToField("parent2") ExportingNode parent2) { + this.parent = parent; + this.parent2 = parent2; + } + + @OnParentUpdate + public void parentUpdated(ExportingNode updatedNode) { + updateCount++; + } + + @OnTrigger + public boolean triggered() { + triggerCount++; + return true; + } + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/MyExportedInterface.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/MyExportedInterface.java new file mode 100644 index 000000000..ff1b0922c --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/MyExportedInterface.java @@ -0,0 +1,12 @@ +package com.fluxtion.compiler.generation.exportfunction; + +import java.util.List; + +public interface MyExportedInterface { + + void updatedDetails(String s, int y); + + void complexCallBack(List s, int y); + + void complexCallBackDouble(List s, int y); +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/util/ClassUtilsTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/util/ClassUtilsTest.java index 7d0500663..1646c34b1 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/util/ClassUtilsTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/util/ClassUtilsTest.java @@ -18,6 +18,7 @@ package com.fluxtion.compiler.generation.util; import com.fluxtion.compiler.generation.model.CbMethodHandle; +import org.apache.commons.lang3.StringUtils; import org.junit.Assert; import org.junit.Test; @@ -26,6 +27,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.Map; import static org.junit.Assert.assertEquals; @@ -34,37 +36,6 @@ */ public class ClassUtilsTest { - - public static class A { - } - - public static class B { - } - - public static class B1 extends B { - } - - public static class B2 extends B1 { - } - - - public static class Handler1 { - public void handleA(A a) { - } - - public void handleB(B a) { - } - - public void handleB1(B1 a) { - } - - public void handleB2(B2 a) { - } - - public void handleObject(Object o) { - } - } - @Test public void testCbLocate() throws NoSuchMethodException { Handler1 h = new Handler1(); @@ -114,4 +85,56 @@ public void testClassHierarchySort() { Assert.assertTrue(sortClassHierarchy.indexOf(Object.class) > sortClassHierarchy.indexOf(A.class)); } + + public void crazyMethod(String a, List x, Map>, ?> map) { + + } + + @Test + public void printSignature() { + String generated = Arrays.stream(ClassUtilsTest.class.getDeclaredMethods()) + .filter(m -> m.getName().contains("crazyMethod")) + .findAny() + .map(m -> ClassUtils.wrapExportedFunctionCall(m, "wrappedCrazy", "instanceA")) + .get(); + String expected = "" + + "public void wrappedCrazy(java.lang.String arg0, java.util.List arg1, java.util.Map>, ?> arg2, String identifer){" + + " try {\n" + + " ExportingNode instance = getNodeById(identifer);\n" + + " instance.crazyMethod(arg0, arg1, arg2);\n" + + " } catch (NoSuchFieldException e) {\n" + + " throw new RuntimeException(e);\n" + + " }" + + "}"; + assertEquals(StringUtils.deleteWhitespace(expected), StringUtils.deleteWhitespace(generated)); + } + + public static class A { + } + + public static class B { + } + + public static class B1 extends B { + } + + public static class B2 extends B1 { + } + + public static class Handler1 { + public void handleA(A a) { + } + + public void handleB(B a) { + } + + public void handleB1(B1 a) { + } + + public void handleB2(B2 a) { + } + + public void handleObject(Object o) { + } + } } diff --git a/runtime/src/main/java/com/fluxtion/runtime/NodeDiscovery.java b/runtime/src/main/java/com/fluxtion/runtime/NodeDiscovery.java new file mode 100644 index 000000000..a931474db --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/NodeDiscovery.java @@ -0,0 +1,6 @@ +package com.fluxtion.runtime; + +public interface NodeDiscovery { + + T getNodeById(String id) throws NoSuchFieldException; +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java b/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java index 7b3306f4d..dfa018228 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java +++ b/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java @@ -64,7 +64,7 @@ * * @author Greg Higgins */ -public interface StaticEventProcessor { +public interface StaticEventProcessor extends NodeDiscovery { StaticEventProcessor NULL_EVENTHANDLER = e -> { }; diff --git a/runtime/src/main/java/com/fluxtion/runtime/annotations/ExportFunction.java b/runtime/src/main/java/com/fluxtion/runtime/annotations/ExportFunction.java new file mode 100644 index 000000000..a6112e29e --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/annotations/ExportFunction.java @@ -0,0 +1,35 @@ +package com.fluxtion.runtime.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface ExportFunction { + + /** + * The name of the exported function in the generated {@link com.fluxtion.runtime.StaticEventProcessor} + * + * @return method name exported + */ + String value() default ""; + + /** + * The filter value as a String, a zero length String indicates no filtering + * should be applied. + * + * @return the filter value of the handler to match against filterString of + * event + */ +// String filterString() default ""; + + /** + * A member of this class that provides a value to override static values in + * annotation. + * + * @return field providing filter override + */ +// String filterVariable() default ""; +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java b/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java index e0e9a2d2b..4a39577c0 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java @@ -34,7 +34,7 @@ public boolean onEvent(Object e) { @SneakyThrows public final Class eventClass() { if (cbClass == null) { - cbClass = InstanceCallback.cbClassList.remove(0); + cbClass = InstanceCallbackEvent.cbClassList.remove(0); eventClassName = cbClass.getName(); } return cbClass; diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionNode.java b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionNode.java new file mode 100644 index 000000000..70bacb650 --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionNode.java @@ -0,0 +1,39 @@ +package com.fluxtion.runtime.callback; + +import com.fluxtion.runtime.annotations.AfterEvent; +import com.fluxtion.runtime.annotations.Initialise; +import com.fluxtion.runtime.annotations.OnTrigger; +import com.fluxtion.runtime.annotations.Start; + +public class ExportFunctionNode { + + private boolean triggered; + + @OnTrigger + public boolean triggered() { + return triggered; + } + + @AfterEvent + public void afterEvent() { + triggered = false; + } + + @Initialise + public void init() { + triggered = false; + } + + @Start + public void start() { + triggered = false; + } + + public boolean isTriggered() { + return triggered; + } + + public void setTriggered(boolean triggered) { + this.triggered = triggered; + } +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTrigger.java b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTrigger.java new file mode 100644 index 000000000..8cf5b8600 --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTrigger.java @@ -0,0 +1,79 @@ +package com.fluxtion.runtime.callback; + +import com.fluxtion.runtime.annotations.PushReference; +import com.fluxtion.runtime.annotations.builder.AssignToField; +import com.fluxtion.runtime.node.EventHandlerNode; +import com.fluxtion.runtime.node.NamedNode; +import lombok.SneakyThrows; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class ExportFunctionTrigger implements EventHandlerNode, NamedNode { + @PushReference + private List functionPointerList = new ArrayList<>(); + private transient Class cbClass; + + private final transient Object event; + + private transient final String name; + + @SneakyThrows + public ExportFunctionTrigger(@AssignToField("cbClass") Class cbClass) { + this.cbClass = cbClass; + this.event = cbClass.getDeclaredConstructor().newInstance(); + this.name = "handler" + cbClass.getSimpleName(); + } + + @SneakyThrows + public ExportFunctionTrigger() { + this.cbClass = ExportFunctionTriggerEvent.exportFunctionCbList.remove(0); + this.event = cbClass.getDeclaredConstructor().newInstance(); + this.name = "handler" + cbClass.getSimpleName(); + } + + @Override + public boolean onEvent(Object e) { + return true; + } + + public Object getEvent() { + return event; + } + + public List getFunctionPointerList() { + return functionPointerList; + } + + public void setFunctionPointerList(List functionPointerList) { + this.functionPointerList = functionPointerList; + } + + @Override + @SneakyThrows + public final Class eventClass() { + if (cbClass == null) { + cbClass = InstanceCallbackEvent.cbClassList.remove(0); + } + return cbClass; + } + + @Override + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ExportFunctionTrigger that = (ExportFunctionTrigger) o; + return Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return name.hashCode(); + } +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTriggerEvent.java b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTriggerEvent.java new file mode 100644 index 000000000..8dcc7c75e --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTriggerEvent.java @@ -0,0 +1,535 @@ +package com.fluxtion.runtime.callback; + +import java.util.ArrayList; +import java.util.List; + +public interface ExportFunctionTriggerEvent { + + List> exportFunctionCbList = new ArrayList<>(); + + static void main(String[] args) { + for (int i = 0; i < 128; i++) { + System.out.printf("class ExportFunctionTriggerEvent_%d {}%n", i); + } + System.out.print("static void reset(){\n"); + for (int i = 0; i < 128; i++) { + System.out.printf("\tcbClassList.add(ExportFunctionTriggerEvent_%d.class);%n", i); + } + System.out.println("}\n"); + } + + static void reset() { + exportFunctionCbList.add(ExportFunctionTriggerEvent_0.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_1.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_2.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_3.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_4.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_5.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_6.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_7.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_8.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_9.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_10.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_11.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_12.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_13.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_14.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_15.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_16.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_17.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_18.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_19.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_20.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_21.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_22.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_23.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_24.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_25.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_26.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_27.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_28.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_29.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_30.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_31.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_32.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_33.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_34.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_35.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_36.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_37.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_38.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_39.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_40.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_41.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_42.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_43.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_44.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_45.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_46.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_47.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_48.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_49.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_50.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_51.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_52.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_53.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_54.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_55.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_56.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_57.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_58.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_59.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_60.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_61.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_62.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_63.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_64.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_65.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_66.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_67.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_68.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_69.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_70.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_71.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_72.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_73.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_74.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_75.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_76.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_77.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_78.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_79.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_80.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_81.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_82.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_83.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_84.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_85.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_86.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_87.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_88.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_89.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_90.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_91.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_92.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_93.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_94.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_95.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_96.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_97.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_98.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_99.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_100.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_101.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_102.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_103.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_104.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_105.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_106.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_107.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_108.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_109.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_110.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_111.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_112.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_113.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_114.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_115.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_116.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_117.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_118.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_119.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_120.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_121.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_122.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_123.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_124.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_125.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_126.class); + exportFunctionCbList.add(ExportFunctionTriggerEvent_127.class); + } + + class ExportFunctionTriggerEvent_0 { + } + + class ExportFunctionTriggerEvent_1 { + } + + class ExportFunctionTriggerEvent_2 { + } + + class ExportFunctionTriggerEvent_3 { + } + + class ExportFunctionTriggerEvent_4 { + } + + class ExportFunctionTriggerEvent_5 { + } + + class ExportFunctionTriggerEvent_6 { + } + + class ExportFunctionTriggerEvent_7 { + } + + class ExportFunctionTriggerEvent_8 { + } + + class ExportFunctionTriggerEvent_9 { + } + + class ExportFunctionTriggerEvent_10 { + } + + class ExportFunctionTriggerEvent_11 { + } + + class ExportFunctionTriggerEvent_12 { + } + + class ExportFunctionTriggerEvent_13 { + } + + class ExportFunctionTriggerEvent_14 { + } + + class ExportFunctionTriggerEvent_15 { + } + + class ExportFunctionTriggerEvent_16 { + } + + class ExportFunctionTriggerEvent_17 { + } + + class ExportFunctionTriggerEvent_18 { + } + + class ExportFunctionTriggerEvent_19 { + } + + class ExportFunctionTriggerEvent_20 { + } + + class ExportFunctionTriggerEvent_21 { + } + + class ExportFunctionTriggerEvent_22 { + } + + class ExportFunctionTriggerEvent_23 { + } + + class ExportFunctionTriggerEvent_24 { + } + + class ExportFunctionTriggerEvent_25 { + } + + class ExportFunctionTriggerEvent_26 { + } + + class ExportFunctionTriggerEvent_27 { + } + + class ExportFunctionTriggerEvent_28 { + } + + class ExportFunctionTriggerEvent_29 { + } + + class ExportFunctionTriggerEvent_30 { + } + + class ExportFunctionTriggerEvent_31 { + } + + class ExportFunctionTriggerEvent_32 { + } + + class ExportFunctionTriggerEvent_33 { + } + + class ExportFunctionTriggerEvent_34 { + } + + class ExportFunctionTriggerEvent_35 { + } + + class ExportFunctionTriggerEvent_36 { + } + + class ExportFunctionTriggerEvent_37 { + } + + class ExportFunctionTriggerEvent_38 { + } + + class ExportFunctionTriggerEvent_39 { + } + + class ExportFunctionTriggerEvent_40 { + } + + class ExportFunctionTriggerEvent_41 { + } + + class ExportFunctionTriggerEvent_42 { + } + + class ExportFunctionTriggerEvent_43 { + } + + class ExportFunctionTriggerEvent_44 { + } + + class ExportFunctionTriggerEvent_45 { + } + + class ExportFunctionTriggerEvent_46 { + } + + class ExportFunctionTriggerEvent_47 { + } + + class ExportFunctionTriggerEvent_48 { + } + + class ExportFunctionTriggerEvent_49 { + } + + class ExportFunctionTriggerEvent_50 { + } + + class ExportFunctionTriggerEvent_51 { + } + + class ExportFunctionTriggerEvent_52 { + } + + class ExportFunctionTriggerEvent_53 { + } + + class ExportFunctionTriggerEvent_54 { + } + + class ExportFunctionTriggerEvent_55 { + } + + class ExportFunctionTriggerEvent_56 { + } + + class ExportFunctionTriggerEvent_57 { + } + + class ExportFunctionTriggerEvent_58 { + } + + class ExportFunctionTriggerEvent_59 { + } + + class ExportFunctionTriggerEvent_60 { + } + + class ExportFunctionTriggerEvent_61 { + } + + class ExportFunctionTriggerEvent_62 { + } + + class ExportFunctionTriggerEvent_63 { + } + + class ExportFunctionTriggerEvent_64 { + } + + class ExportFunctionTriggerEvent_65 { + } + + class ExportFunctionTriggerEvent_66 { + } + + class ExportFunctionTriggerEvent_67 { + } + + class ExportFunctionTriggerEvent_68 { + } + + class ExportFunctionTriggerEvent_69 { + } + + class ExportFunctionTriggerEvent_70 { + } + + class ExportFunctionTriggerEvent_71 { + } + + class ExportFunctionTriggerEvent_72 { + } + + class ExportFunctionTriggerEvent_73 { + } + + class ExportFunctionTriggerEvent_74 { + } + + class ExportFunctionTriggerEvent_75 { + } + + class ExportFunctionTriggerEvent_76 { + } + + class ExportFunctionTriggerEvent_77 { + } + + class ExportFunctionTriggerEvent_78 { + } + + class ExportFunctionTriggerEvent_79 { + } + + class ExportFunctionTriggerEvent_80 { + } + + class ExportFunctionTriggerEvent_81 { + } + + class ExportFunctionTriggerEvent_82 { + } + + class ExportFunctionTriggerEvent_83 { + } + + class ExportFunctionTriggerEvent_84 { + } + + class ExportFunctionTriggerEvent_85 { + } + + class ExportFunctionTriggerEvent_86 { + } + + class ExportFunctionTriggerEvent_87 { + } + + class ExportFunctionTriggerEvent_88 { + } + + class ExportFunctionTriggerEvent_89 { + } + + class ExportFunctionTriggerEvent_90 { + } + + class ExportFunctionTriggerEvent_91 { + } + + class ExportFunctionTriggerEvent_92 { + } + + class ExportFunctionTriggerEvent_93 { + } + + class ExportFunctionTriggerEvent_94 { + } + + class ExportFunctionTriggerEvent_95 { + } + + class ExportFunctionTriggerEvent_96 { + } + + class ExportFunctionTriggerEvent_97 { + } + + class ExportFunctionTriggerEvent_98 { + } + + class ExportFunctionTriggerEvent_99 { + } + + class ExportFunctionTriggerEvent_100 { + } + + class ExportFunctionTriggerEvent_101 { + } + + class ExportFunctionTriggerEvent_102 { + } + + class ExportFunctionTriggerEvent_103 { + } + + class ExportFunctionTriggerEvent_104 { + } + + class ExportFunctionTriggerEvent_105 { + } + + class ExportFunctionTriggerEvent_106 { + } + + class ExportFunctionTriggerEvent_107 { + } + + class ExportFunctionTriggerEvent_108 { + } + + class ExportFunctionTriggerEvent_109 { + } + + class ExportFunctionTriggerEvent_110 { + } + + class ExportFunctionTriggerEvent_111 { + } + + class ExportFunctionTriggerEvent_112 { + } + + class ExportFunctionTriggerEvent_113 { + } + + class ExportFunctionTriggerEvent_114 { + } + + class ExportFunctionTriggerEvent_115 { + } + + class ExportFunctionTriggerEvent_116 { + } + + class ExportFunctionTriggerEvent_117 { + } + + class ExportFunctionTriggerEvent_118 { + } + + class ExportFunctionTriggerEvent_119 { + } + + class ExportFunctionTriggerEvent_120 { + } + + class ExportFunctionTriggerEvent_121 { + } + + class ExportFunctionTriggerEvent_122 { + } + + class ExportFunctionTriggerEvent_123 { + } + + class ExportFunctionTriggerEvent_124 { + } + + class ExportFunctionTriggerEvent_125 { + } + + class ExportFunctionTriggerEvent_126 { + } + + class ExportFunctionTriggerEvent_127 { + } +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallback.java b/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallback.java deleted file mode 100644 index 6171a8b3c..000000000 --- a/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallback.java +++ /dev/null @@ -1,536 +0,0 @@ -package com.fluxtion.runtime.callback; - -import java.util.ArrayList; -import java.util.List; - -public interface InstanceCallback { - - List> cbClassList = new ArrayList<>(); - - static void main(String[] args) { - for (int i = 0; i < 128; i++) { - System.out.printf("class InstanceCallback_%d {}%n", i); - } - for (int i = 0; i < 128; i++) { - System.out.printf("cbClassList.add(InstanceCallback_%d.class);%n", i); - } - } - - static void reset() { -// System.out.println("FunctionTriggerNode::reset"); - cbClassList.clear(); - cbClassList.add(InstanceCallback_0.class); - cbClassList.add(InstanceCallback_1.class); - cbClassList.add(InstanceCallback_2.class); - cbClassList.add(InstanceCallback_3.class); - cbClassList.add(InstanceCallback_4.class); - cbClassList.add(InstanceCallback_5.class); - cbClassList.add(InstanceCallback_6.class); - cbClassList.add(InstanceCallback_7.class); - cbClassList.add(InstanceCallback_8.class); - cbClassList.add(InstanceCallback_9.class); - cbClassList.add(InstanceCallback_10.class); - cbClassList.add(InstanceCallback_11.class); - cbClassList.add(InstanceCallback_12.class); - cbClassList.add(InstanceCallback_13.class); - cbClassList.add(InstanceCallback_14.class); - cbClassList.add(InstanceCallback_15.class); - cbClassList.add(InstanceCallback_16.class); - cbClassList.add(InstanceCallback_17.class); - cbClassList.add(InstanceCallback_18.class); - cbClassList.add(InstanceCallback_19.class); - cbClassList.add(InstanceCallback_20.class); - cbClassList.add(InstanceCallback_21.class); - cbClassList.add(InstanceCallback_22.class); - cbClassList.add(InstanceCallback_23.class); - cbClassList.add(InstanceCallback_24.class); - cbClassList.add(InstanceCallback_25.class); - cbClassList.add(InstanceCallback_26.class); - cbClassList.add(InstanceCallback_27.class); - cbClassList.add(InstanceCallback_28.class); - cbClassList.add(InstanceCallback_29.class); - cbClassList.add(InstanceCallback_30.class); - cbClassList.add(InstanceCallback_31.class); - cbClassList.add(InstanceCallback_32.class); - cbClassList.add(InstanceCallback_33.class); - cbClassList.add(InstanceCallback_34.class); - cbClassList.add(InstanceCallback_35.class); - cbClassList.add(InstanceCallback_36.class); - cbClassList.add(InstanceCallback_37.class); - cbClassList.add(InstanceCallback_38.class); - cbClassList.add(InstanceCallback_39.class); - cbClassList.add(InstanceCallback_40.class); - cbClassList.add(InstanceCallback_41.class); - cbClassList.add(InstanceCallback_42.class); - cbClassList.add(InstanceCallback_43.class); - cbClassList.add(InstanceCallback_44.class); - cbClassList.add(InstanceCallback_45.class); - cbClassList.add(InstanceCallback_46.class); - cbClassList.add(InstanceCallback_47.class); - cbClassList.add(InstanceCallback_48.class); - cbClassList.add(InstanceCallback_49.class); - cbClassList.add(InstanceCallback_50.class); - cbClassList.add(InstanceCallback_51.class); - cbClassList.add(InstanceCallback_52.class); - cbClassList.add(InstanceCallback_53.class); - cbClassList.add(InstanceCallback_54.class); - cbClassList.add(InstanceCallback_55.class); - cbClassList.add(InstanceCallback_56.class); - cbClassList.add(InstanceCallback_57.class); - cbClassList.add(InstanceCallback_58.class); - cbClassList.add(InstanceCallback_59.class); - cbClassList.add(InstanceCallback_60.class); - cbClassList.add(InstanceCallback_61.class); - cbClassList.add(InstanceCallback_62.class); - cbClassList.add(InstanceCallback_63.class); - cbClassList.add(InstanceCallback_64.class); - cbClassList.add(InstanceCallback_65.class); - cbClassList.add(InstanceCallback_66.class); - cbClassList.add(InstanceCallback_67.class); - cbClassList.add(InstanceCallback_68.class); - cbClassList.add(InstanceCallback_69.class); - cbClassList.add(InstanceCallback_70.class); - cbClassList.add(InstanceCallback_71.class); - cbClassList.add(InstanceCallback_72.class); - cbClassList.add(InstanceCallback_73.class); - cbClassList.add(InstanceCallback_74.class); - cbClassList.add(InstanceCallback_75.class); - cbClassList.add(InstanceCallback_76.class); - cbClassList.add(InstanceCallback_77.class); - cbClassList.add(InstanceCallback_78.class); - cbClassList.add(InstanceCallback_79.class); - cbClassList.add(InstanceCallback_80.class); - cbClassList.add(InstanceCallback_81.class); - cbClassList.add(InstanceCallback_82.class); - cbClassList.add(InstanceCallback_83.class); - cbClassList.add(InstanceCallback_84.class); - cbClassList.add(InstanceCallback_85.class); - cbClassList.add(InstanceCallback_86.class); - cbClassList.add(InstanceCallback_87.class); - cbClassList.add(InstanceCallback_88.class); - cbClassList.add(InstanceCallback_89.class); - cbClassList.add(InstanceCallback_90.class); - cbClassList.add(InstanceCallback_91.class); - cbClassList.add(InstanceCallback_92.class); - cbClassList.add(InstanceCallback_93.class); - cbClassList.add(InstanceCallback_94.class); - cbClassList.add(InstanceCallback_95.class); - cbClassList.add(InstanceCallback_96.class); - cbClassList.add(InstanceCallback_97.class); - cbClassList.add(InstanceCallback_98.class); - cbClassList.add(InstanceCallback_99.class); - cbClassList.add(InstanceCallback_100.class); - cbClassList.add(InstanceCallback_101.class); - cbClassList.add(InstanceCallback_102.class); - cbClassList.add(InstanceCallback_103.class); - cbClassList.add(InstanceCallback_104.class); - cbClassList.add(InstanceCallback_105.class); - cbClassList.add(InstanceCallback_106.class); - cbClassList.add(InstanceCallback_107.class); - cbClassList.add(InstanceCallback_108.class); - cbClassList.add(InstanceCallback_109.class); - cbClassList.add(InstanceCallback_110.class); - cbClassList.add(InstanceCallback_111.class); - cbClassList.add(InstanceCallback_112.class); - cbClassList.add(InstanceCallback_113.class); - cbClassList.add(InstanceCallback_114.class); - cbClassList.add(InstanceCallback_115.class); - cbClassList.add(InstanceCallback_116.class); - cbClassList.add(InstanceCallback_117.class); - cbClassList.add(InstanceCallback_118.class); - cbClassList.add(InstanceCallback_119.class); - cbClassList.add(InstanceCallback_120.class); - cbClassList.add(InstanceCallback_121.class); - cbClassList.add(InstanceCallback_122.class); - cbClassList.add(InstanceCallback_123.class); - cbClassList.add(InstanceCallback_124.class); - cbClassList.add(InstanceCallback_125.class); - cbClassList.add(InstanceCallback_126.class); - cbClassList.add(InstanceCallback_127.class); - } - - - class InstanceCallback_0 { - } - - class InstanceCallback_1 { - } - - class InstanceCallback_2 { - } - - class InstanceCallback_3 { - } - - class InstanceCallback_4 { - } - - class InstanceCallback_5 { - } - - class InstanceCallback_6 { - } - - class InstanceCallback_7 { - } - - class InstanceCallback_8 { - } - - class InstanceCallback_9 { - } - - class InstanceCallback_10 { - } - - class InstanceCallback_11 { - } - - class InstanceCallback_12 { - } - - class InstanceCallback_13 { - } - - class InstanceCallback_14 { - } - - class InstanceCallback_15 { - } - - class InstanceCallback_16 { - } - - class InstanceCallback_17 { - } - - class InstanceCallback_18 { - } - - class InstanceCallback_19 { - } - - class InstanceCallback_20 { - } - - class InstanceCallback_21 { - } - - class InstanceCallback_22 { - } - - class InstanceCallback_23 { - } - - class InstanceCallback_24 { - } - - class InstanceCallback_25 { - } - - class InstanceCallback_26 { - } - - class InstanceCallback_27 { - } - - class InstanceCallback_28 { - } - - class InstanceCallback_29 { - } - - class InstanceCallback_30 { - } - - class InstanceCallback_31 { - } - - class InstanceCallback_32 { - } - - class InstanceCallback_33 { - } - - class InstanceCallback_34 { - } - - class InstanceCallback_35 { - } - - class InstanceCallback_36 { - } - - class InstanceCallback_37 { - } - - class InstanceCallback_38 { - } - - class InstanceCallback_39 { - } - - class InstanceCallback_40 { - } - - class InstanceCallback_41 { - } - - class InstanceCallback_42 { - } - - class InstanceCallback_43 { - } - - class InstanceCallback_44 { - } - - class InstanceCallback_45 { - } - - class InstanceCallback_46 { - } - - class InstanceCallback_47 { - } - - class InstanceCallback_48 { - } - - class InstanceCallback_49 { - } - - class InstanceCallback_50 { - } - - class InstanceCallback_51 { - } - - class InstanceCallback_52 { - } - - class InstanceCallback_53 { - } - - class InstanceCallback_54 { - } - - class InstanceCallback_55 { - } - - class InstanceCallback_56 { - } - - class InstanceCallback_57 { - } - - class InstanceCallback_58 { - } - - class InstanceCallback_59 { - } - - class InstanceCallback_60 { - } - - class InstanceCallback_61 { - } - - class InstanceCallback_62 { - } - - class InstanceCallback_63 { - } - - class InstanceCallback_64 { - } - - class InstanceCallback_65 { - } - - class InstanceCallback_66 { - } - - class InstanceCallback_67 { - } - - class InstanceCallback_68 { - } - - class InstanceCallback_69 { - } - - class InstanceCallback_70 { - } - - class InstanceCallback_71 { - } - - class InstanceCallback_72 { - } - - class InstanceCallback_73 { - } - - class InstanceCallback_74 { - } - - class InstanceCallback_75 { - } - - class InstanceCallback_76 { - } - - class InstanceCallback_77 { - } - - class InstanceCallback_78 { - } - - class InstanceCallback_79 { - } - - class InstanceCallback_80 { - } - - class InstanceCallback_81 { - } - - class InstanceCallback_82 { - } - - class InstanceCallback_83 { - } - - class InstanceCallback_84 { - } - - class InstanceCallback_85 { - } - - class InstanceCallback_86 { - } - - class InstanceCallback_87 { - } - - class InstanceCallback_88 { - } - - class InstanceCallback_89 { - } - - class InstanceCallback_90 { - } - - class InstanceCallback_91 { - } - - class InstanceCallback_92 { - } - - class InstanceCallback_93 { - } - - class InstanceCallback_94 { - } - - class InstanceCallback_95 { - } - - class InstanceCallback_96 { - } - - class InstanceCallback_97 { - } - - class InstanceCallback_98 { - } - - class InstanceCallback_99 { - } - - class InstanceCallback_100 { - } - - class InstanceCallback_101 { - } - - class InstanceCallback_102 { - } - - class InstanceCallback_103 { - } - - class InstanceCallback_104 { - } - - class InstanceCallback_105 { - } - - class InstanceCallback_106 { - } - - class InstanceCallback_107 { - } - - class InstanceCallback_108 { - } - - class InstanceCallback_109 { - } - - class InstanceCallback_110 { - } - - class InstanceCallback_111 { - } - - class InstanceCallback_112 { - } - - class InstanceCallback_113 { - } - - class InstanceCallback_114 { - } - - class InstanceCallback_115 { - } - - class InstanceCallback_116 { - } - - class InstanceCallback_117 { - } - - class InstanceCallback_118 { - } - - class InstanceCallback_119 { - } - - class InstanceCallback_120 { - } - - class InstanceCallback_121 { - } - - class InstanceCallback_122 { - } - - class InstanceCallback_123 { - } - - class InstanceCallback_124 { - } - - class InstanceCallback_125 { - } - - class InstanceCallback_126 { - } - - class InstanceCallback_127 { - } -} diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallbackEvent.java b/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallbackEvent.java new file mode 100644 index 000000000..2fb6007ef --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallbackEvent.java @@ -0,0 +1,537 @@ +package com.fluxtion.runtime.callback; + +import java.util.ArrayList; +import java.util.List; + +public interface InstanceCallbackEvent { + + List> cbClassList = new ArrayList<>(); + + static void main(String[] args) { + for (int i = 0; i < 128; i++) { + System.out.printf("class InstanceCallbackEvent_%d {}%n", i); + } + for (int i = 0; i < 128; i++) { + System.out.printf("cbClassList.add(InstanceCallbackEvent_%d.class);%n", i); + } + } + + static void reset() { + ExportFunctionTriggerEvent.reset(); +// System.out.println("FunctionTriggerNode::reset"); + cbClassList.clear(); + cbClassList.add(InstanceCallbackEvent_0.class); + cbClassList.add(InstanceCallbackEvent_1.class); + cbClassList.add(InstanceCallbackEvent_2.class); + cbClassList.add(InstanceCallbackEvent_3.class); + cbClassList.add(InstanceCallbackEvent_4.class); + cbClassList.add(InstanceCallbackEvent_5.class); + cbClassList.add(InstanceCallbackEvent_6.class); + cbClassList.add(InstanceCallbackEvent_7.class); + cbClassList.add(InstanceCallbackEvent_8.class); + cbClassList.add(InstanceCallbackEvent_9.class); + cbClassList.add(InstanceCallbackEvent_10.class); + cbClassList.add(InstanceCallbackEvent_11.class); + cbClassList.add(InstanceCallbackEvent_12.class); + cbClassList.add(InstanceCallbackEvent_13.class); + cbClassList.add(InstanceCallbackEvent_14.class); + cbClassList.add(InstanceCallbackEvent_15.class); + cbClassList.add(InstanceCallbackEvent_16.class); + cbClassList.add(InstanceCallbackEvent_17.class); + cbClassList.add(InstanceCallbackEvent_18.class); + cbClassList.add(InstanceCallbackEvent_19.class); + cbClassList.add(InstanceCallbackEvent_20.class); + cbClassList.add(InstanceCallbackEvent_21.class); + cbClassList.add(InstanceCallbackEvent_22.class); + cbClassList.add(InstanceCallbackEvent_23.class); + cbClassList.add(InstanceCallbackEvent_24.class); + cbClassList.add(InstanceCallbackEvent_25.class); + cbClassList.add(InstanceCallbackEvent_26.class); + cbClassList.add(InstanceCallbackEvent_27.class); + cbClassList.add(InstanceCallbackEvent_28.class); + cbClassList.add(InstanceCallbackEvent_29.class); + cbClassList.add(InstanceCallbackEvent_30.class); + cbClassList.add(InstanceCallbackEvent_31.class); + cbClassList.add(InstanceCallbackEvent_32.class); + cbClassList.add(InstanceCallbackEvent_33.class); + cbClassList.add(InstanceCallbackEvent_34.class); + cbClassList.add(InstanceCallbackEvent_35.class); + cbClassList.add(InstanceCallbackEvent_36.class); + cbClassList.add(InstanceCallbackEvent_37.class); + cbClassList.add(InstanceCallbackEvent_38.class); + cbClassList.add(InstanceCallbackEvent_39.class); + cbClassList.add(InstanceCallbackEvent_40.class); + cbClassList.add(InstanceCallbackEvent_41.class); + cbClassList.add(InstanceCallbackEvent_42.class); + cbClassList.add(InstanceCallbackEvent_43.class); + cbClassList.add(InstanceCallbackEvent_44.class); + cbClassList.add(InstanceCallbackEvent_45.class); + cbClassList.add(InstanceCallbackEvent_46.class); + cbClassList.add(InstanceCallbackEvent_47.class); + cbClassList.add(InstanceCallbackEvent_48.class); + cbClassList.add(InstanceCallbackEvent_49.class); + cbClassList.add(InstanceCallbackEvent_50.class); + cbClassList.add(InstanceCallbackEvent_51.class); + cbClassList.add(InstanceCallbackEvent_52.class); + cbClassList.add(InstanceCallbackEvent_53.class); + cbClassList.add(InstanceCallbackEvent_54.class); + cbClassList.add(InstanceCallbackEvent_55.class); + cbClassList.add(InstanceCallbackEvent_56.class); + cbClassList.add(InstanceCallbackEvent_57.class); + cbClassList.add(InstanceCallbackEvent_58.class); + cbClassList.add(InstanceCallbackEvent_59.class); + cbClassList.add(InstanceCallbackEvent_60.class); + cbClassList.add(InstanceCallbackEvent_61.class); + cbClassList.add(InstanceCallbackEvent_62.class); + cbClassList.add(InstanceCallbackEvent_63.class); + cbClassList.add(InstanceCallbackEvent_64.class); + cbClassList.add(InstanceCallbackEvent_65.class); + cbClassList.add(InstanceCallbackEvent_66.class); + cbClassList.add(InstanceCallbackEvent_67.class); + cbClassList.add(InstanceCallbackEvent_68.class); + cbClassList.add(InstanceCallbackEvent_69.class); + cbClassList.add(InstanceCallbackEvent_70.class); + cbClassList.add(InstanceCallbackEvent_71.class); + cbClassList.add(InstanceCallbackEvent_72.class); + cbClassList.add(InstanceCallbackEvent_73.class); + cbClassList.add(InstanceCallbackEvent_74.class); + cbClassList.add(InstanceCallbackEvent_75.class); + cbClassList.add(InstanceCallbackEvent_76.class); + cbClassList.add(InstanceCallbackEvent_77.class); + cbClassList.add(InstanceCallbackEvent_78.class); + cbClassList.add(InstanceCallbackEvent_79.class); + cbClassList.add(InstanceCallbackEvent_80.class); + cbClassList.add(InstanceCallbackEvent_81.class); + cbClassList.add(InstanceCallbackEvent_82.class); + cbClassList.add(InstanceCallbackEvent_83.class); + cbClassList.add(InstanceCallbackEvent_84.class); + cbClassList.add(InstanceCallbackEvent_85.class); + cbClassList.add(InstanceCallbackEvent_86.class); + cbClassList.add(InstanceCallbackEvent_87.class); + cbClassList.add(InstanceCallbackEvent_88.class); + cbClassList.add(InstanceCallbackEvent_89.class); + cbClassList.add(InstanceCallbackEvent_90.class); + cbClassList.add(InstanceCallbackEvent_91.class); + cbClassList.add(InstanceCallbackEvent_92.class); + cbClassList.add(InstanceCallbackEvent_93.class); + cbClassList.add(InstanceCallbackEvent_94.class); + cbClassList.add(InstanceCallbackEvent_95.class); + cbClassList.add(InstanceCallbackEvent_96.class); + cbClassList.add(InstanceCallbackEvent_97.class); + cbClassList.add(InstanceCallbackEvent_98.class); + cbClassList.add(InstanceCallbackEvent_99.class); + cbClassList.add(InstanceCallbackEvent_100.class); + cbClassList.add(InstanceCallbackEvent_101.class); + cbClassList.add(InstanceCallbackEvent_102.class); + cbClassList.add(InstanceCallbackEvent_103.class); + cbClassList.add(InstanceCallbackEvent_104.class); + cbClassList.add(InstanceCallbackEvent_105.class); + cbClassList.add(InstanceCallbackEvent_106.class); + cbClassList.add(InstanceCallbackEvent_107.class); + cbClassList.add(InstanceCallbackEvent_108.class); + cbClassList.add(InstanceCallbackEvent_109.class); + cbClassList.add(InstanceCallbackEvent_110.class); + cbClassList.add(InstanceCallbackEvent_111.class); + cbClassList.add(InstanceCallbackEvent_112.class); + cbClassList.add(InstanceCallbackEvent_113.class); + cbClassList.add(InstanceCallbackEvent_114.class); + cbClassList.add(InstanceCallbackEvent_115.class); + cbClassList.add(InstanceCallbackEvent_116.class); + cbClassList.add(InstanceCallbackEvent_117.class); + cbClassList.add(InstanceCallbackEvent_118.class); + cbClassList.add(InstanceCallbackEvent_119.class); + cbClassList.add(InstanceCallbackEvent_120.class); + cbClassList.add(InstanceCallbackEvent_121.class); + cbClassList.add(InstanceCallbackEvent_122.class); + cbClassList.add(InstanceCallbackEvent_123.class); + cbClassList.add(InstanceCallbackEvent_124.class); + cbClassList.add(InstanceCallbackEvent_125.class); + cbClassList.add(InstanceCallbackEvent_126.class); + cbClassList.add(InstanceCallbackEvent_127.class); + } + + + class InstanceCallbackEvent_0 { + } + + class InstanceCallbackEvent_1 { + } + + class InstanceCallbackEvent_2 { + } + + class InstanceCallbackEvent_3 { + } + + class InstanceCallbackEvent_4 { + } + + class InstanceCallbackEvent_5 { + } + + class InstanceCallbackEvent_6 { + } + + class InstanceCallbackEvent_7 { + } + + class InstanceCallbackEvent_8 { + } + + class InstanceCallbackEvent_9 { + } + + class InstanceCallbackEvent_10 { + } + + class InstanceCallbackEvent_11 { + } + + class InstanceCallbackEvent_12 { + } + + class InstanceCallbackEvent_13 { + } + + class InstanceCallbackEvent_14 { + } + + class InstanceCallbackEvent_15 { + } + + class InstanceCallbackEvent_16 { + } + + class InstanceCallbackEvent_17 { + } + + class InstanceCallbackEvent_18 { + } + + class InstanceCallbackEvent_19 { + } + + class InstanceCallbackEvent_20 { + } + + class InstanceCallbackEvent_21 { + } + + class InstanceCallbackEvent_22 { + } + + class InstanceCallbackEvent_23 { + } + + class InstanceCallbackEvent_24 { + } + + class InstanceCallbackEvent_25 { + } + + class InstanceCallbackEvent_26 { + } + + class InstanceCallbackEvent_27 { + } + + class InstanceCallbackEvent_28 { + } + + class InstanceCallbackEvent_29 { + } + + class InstanceCallbackEvent_30 { + } + + class InstanceCallbackEvent_31 { + } + + class InstanceCallbackEvent_32 { + } + + class InstanceCallbackEvent_33 { + } + + class InstanceCallbackEvent_34 { + } + + class InstanceCallbackEvent_35 { + } + + class InstanceCallbackEvent_36 { + } + + class InstanceCallbackEvent_37 { + } + + class InstanceCallbackEvent_38 { + } + + class InstanceCallbackEvent_39 { + } + + class InstanceCallbackEvent_40 { + } + + class InstanceCallbackEvent_41 { + } + + class InstanceCallbackEvent_42 { + } + + class InstanceCallbackEvent_43 { + } + + class InstanceCallbackEvent_44 { + } + + class InstanceCallbackEvent_45 { + } + + class InstanceCallbackEvent_46 { + } + + class InstanceCallbackEvent_47 { + } + + class InstanceCallbackEvent_48 { + } + + class InstanceCallbackEvent_49 { + } + + class InstanceCallbackEvent_50 { + } + + class InstanceCallbackEvent_51 { + } + + class InstanceCallbackEvent_52 { + } + + class InstanceCallbackEvent_53 { + } + + class InstanceCallbackEvent_54 { + } + + class InstanceCallbackEvent_55 { + } + + class InstanceCallbackEvent_56 { + } + + class InstanceCallbackEvent_57 { + } + + class InstanceCallbackEvent_58 { + } + + class InstanceCallbackEvent_59 { + } + + class InstanceCallbackEvent_60 { + } + + class InstanceCallbackEvent_61 { + } + + class InstanceCallbackEvent_62 { + } + + class InstanceCallbackEvent_63 { + } + + class InstanceCallbackEvent_64 { + } + + class InstanceCallbackEvent_65 { + } + + class InstanceCallbackEvent_66 { + } + + class InstanceCallbackEvent_67 { + } + + class InstanceCallbackEvent_68 { + } + + class InstanceCallbackEvent_69 { + } + + class InstanceCallbackEvent_70 { + } + + class InstanceCallbackEvent_71 { + } + + class InstanceCallbackEvent_72 { + } + + class InstanceCallbackEvent_73 { + } + + class InstanceCallbackEvent_74 { + } + + class InstanceCallbackEvent_75 { + } + + class InstanceCallbackEvent_76 { + } + + class InstanceCallbackEvent_77 { + } + + class InstanceCallbackEvent_78 { + } + + class InstanceCallbackEvent_79 { + } + + class InstanceCallbackEvent_80 { + } + + class InstanceCallbackEvent_81 { + } + + class InstanceCallbackEvent_82 { + } + + class InstanceCallbackEvent_83 { + } + + class InstanceCallbackEvent_84 { + } + + class InstanceCallbackEvent_85 { + } + + class InstanceCallbackEvent_86 { + } + + class InstanceCallbackEvent_87 { + } + + class InstanceCallbackEvent_88 { + } + + class InstanceCallbackEvent_89 { + } + + class InstanceCallbackEvent_90 { + } + + class InstanceCallbackEvent_91 { + } + + class InstanceCallbackEvent_92 { + } + + class InstanceCallbackEvent_93 { + } + + class InstanceCallbackEvent_94 { + } + + class InstanceCallbackEvent_95 { + } + + class InstanceCallbackEvent_96 { + } + + class InstanceCallbackEvent_97 { + } + + class InstanceCallbackEvent_98 { + } + + class InstanceCallbackEvent_99 { + } + + class InstanceCallbackEvent_100 { + } + + class InstanceCallbackEvent_101 { + } + + class InstanceCallbackEvent_102 { + } + + class InstanceCallbackEvent_103 { + } + + class InstanceCallbackEvent_104 { + } + + class InstanceCallbackEvent_105 { + } + + class InstanceCallbackEvent_106 { + } + + class InstanceCallbackEvent_107 { + } + + class InstanceCallbackEvent_108 { + } + + class InstanceCallbackEvent_109 { + } + + class InstanceCallbackEvent_110 { + } + + class InstanceCallbackEvent_111 { + } + + class InstanceCallbackEvent_112 { + } + + class InstanceCallbackEvent_113 { + } + + class InstanceCallbackEvent_114 { + } + + class InstanceCallbackEvent_115 { + } + + class InstanceCallbackEvent_116 { + } + + class InstanceCallbackEvent_117 { + } + + class InstanceCallbackEvent_118 { + } + + class InstanceCallbackEvent_119 { + } + + class InstanceCallbackEvent_120 { + } + + class InstanceCallbackEvent_121 { + } + + class InstanceCallbackEvent_122 { + } + + class InstanceCallbackEvent_123 { + } + + class InstanceCallbackEvent_124 { + } + + class InstanceCallbackEvent_125 { + } + + class InstanceCallbackEvent_126 { + } + + class InstanceCallbackEvent_127 { + } +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/partition/Partitioner.java b/runtime/src/main/java/com/fluxtion/runtime/partition/Partitioner.java index f2bfdf090..321b03e6c 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/partition/Partitioner.java +++ b/runtime/src/main/java/com/fluxtion/runtime/partition/Partitioner.java @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2018 V12 Technology Ltd. * * This program is free software: you can redistribute it and/or modify @@ -11,16 +11,16 @@ * Server Side Public License for more details. * * You should have received a copy of the Server Side Public License - * along with this program. If not, see + * along with this program. If not, see * . */ package com.fluxtion.runtime.partition; import com.fluxtion.runtime.StaticEventProcessor; -//import com.fluxtion.api.event.Event; import com.fluxtion.runtime.lifecycle.BatchHandler; import com.fluxtion.runtime.lifecycle.Lifecycle; import com.fluxtion.runtime.partition.LambdaReflection.SerializableFunction; + import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; @@ -36,31 +36,31 @@ * to that instance. Partitioning allows a separate memory context for an * EventHandler, this can be useful when the structure of processing is repeated * but the state is different for each instance.

- * - For example monitoring the fuel level on a fleet of cars is the same + *

+ * For example monitoring the fuel level on a fleet of cars is the same * processing for each car, but an individual car will have a unique fuel level. * In this case the StaticEventProcessor can be partitioned on vehicle * identification number. *

- * - The StaticEventProcessor instance will be re-used or a new one created when + *

+ * The StaticEventProcessor instance will be re-used or a new one created when * new events are received. The {@link #partition(SerializableFunction)} methods provide * functions that map keys from an incoming event. the key is used * manage StaticEventProcessor instances in an underlying map. If no key/value * mapping is found then a new StaticEventProcessor is created and handles the * incoming message. *

- * + *

* New instances are created with s {@link Supplier} factory. Optionally an * initialiser can be provided that can access the newly created * StaticEventProcessor before any messages are processed. Using the car/fuel * analogy the initialiser function may set a reference to a global fuel monitor * from each newly created car processor. * - * @author gregp * @param + * @author gregp */ -public class Partitioner< E extends StaticEventProcessor> implements StaticEventProcessor, Lifecycle, BatchHandler { +public class Partitioner implements StaticEventProcessor, Lifecycle, BatchHandler { private HashMap class2Function; private HashMap class2MultiFunction; @@ -77,7 +77,7 @@ public class Partitioner< E extends StaticEventProcessor> implements StaticEvent /** * Create a partitioner with a factory and initialiser function. * - * @param factory factory creating instances of EventHandlers + * @param factory factory creating instances of EventHandlers * @param initialiser Initialisation function applied to new EventHandlers */ public Partitioner(Supplier factory, Consumer initialiser) { @@ -94,7 +94,6 @@ public Partitioner(Supplier factory, Consumer initialiser) { } /** - * * Create a partitioner with a factory. * * @param factory factory creating instances of EventHandlers @@ -115,7 +114,7 @@ public Partitioner(Supplier factory) { * * * @param - * @param Generated key + * @param Generated key * @param partitionKeyGen key mapping function */ public void keyPartitioner(Function partitionKeyGen) { @@ -126,8 +125,8 @@ public void keyPartitioner(Function partitionK * Register a partition key generator function that creates keys from a * property on an incoming event. an incoming Event * - * @param The incoming event - * @param The key type + * @param The incoming event + * @param The key type * @param supplier Key value supplier */ public void partition(SerializableFunction supplier) { @@ -139,8 +138,8 @@ public void partition(SerializableFunction supplier) { * Register a partition key generator function that creates keys from a set * of properties on an incoming event. an incoming Event * - * @param The incoming event - * @param The key type + * @param The incoming event + * @param The key type * @param supplier Key value suppliers */ public void partition(SerializableFunction... supplier) { @@ -174,8 +173,8 @@ public void onEvent(Object e) { } } } - - public E getProcessor(Object key){ + + public E getProcessor(Object key) { return handlerMap.get(key); } diff --git a/runtime/src/test/java/com/fluxtion/runtime/partition/PartitionerTest.java b/runtime/src/test/java/com/fluxtion/runtime/partition/PartitionerTest.java index 0c7f45674..b256cb352 100644 --- a/runtime/src/test/java/com/fluxtion/runtime/partition/PartitionerTest.java +++ b/runtime/src/test/java/com/fluxtion/runtime/partition/PartitionerTest.java @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2018 V12 Technology Ltd. * * This program is free software: you can redistribute it and/or modify @@ -11,7 +11,7 @@ * Server Side Public License for more details. * * You should have received a copy of the Server Side Public License - * along with this program. If not, see + * along with this program. If not, see * . */ package com.fluxtion.runtime.partition; @@ -30,7 +30,6 @@ import static org.hamcrest.MatcherAssert.assertThat; /** - * * @author gregp */ public class PartitionerTest { From 469715c46a7a674b84b62092cefb6914d0ad85c4 Mon Sep 17 00:00:00 2001 From: command-line Date: Sun, 11 Jun 2023 22:52:39 +0100 Subject: [PATCH 039/228] added test for no override of method names --- .../TopologicallySortedDependencyGraph.java | 4 +- .../exportfunction/ExportFunctionTest.java | 98 ++++++++++++++++++- .../MyExportedInterfaceNoOverride.java | 12 +++ 3 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/MyExportedInterfaceNoOverride.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java b/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java index c7bced588..c8015dbd9 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java @@ -759,10 +759,10 @@ private void walkDependenciesForEventHandling(Object object) throws IllegalArgum private void addExportedMethods(Object object) { final Class clazz = object.getClass(); - Set exportMethodSet = ReflectionUtils.getAllMethods(clazz, ReflectionUtils.withAnnotation(ExportFunction.class)); exportMethodSet.forEach(method -> { - String exportMethodName = method.getAnnotation(ExportFunction.class).value(); + String overrideExportMethodName = method.getAnnotation(ExportFunction.class).value(); + String exportMethodName = overrideExportMethodName.trim().isEmpty() ? method.getName() : overrideExportMethodName; ExportFunctionData exportFunctionData = exportedFunctionMap.computeIfAbsent( exportMethodName, n -> { ExportFunctionData data = new ExportFunctionData(exportMethodName); diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java index 4546dc189..6cbbb02f6 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java @@ -20,7 +20,7 @@ public ExportFunctionTest(SepTestConfig compile) { @Test public void exportTest() { - writeSourceFile = true; +// writeSourceFile = true; MyExportedInterface myExportedInterface = (MyExportedInterface) sep(c -> { c.addNode(new Aggregator( new ExportingNode("export1"), @@ -49,6 +49,37 @@ public void exportTest() { Assert.assertEquals("ExportingNode{name='export2', result='complexCallBack s:3 y:33'}", aggregator.parent2.toString()); } + @Test + public void exportTestNoOverride() { +// writeSourceFile = true; + MyExportedInterfaceNoOverride myExportedInterface = (MyExportedInterfaceNoOverride) sep(c -> { + c.addNode(new Aggregator2( + new ExportingNodeNoOverride("export1"), + new ExportingNodeNoOverride("export2") + ), "aggregator"); + c.addInterfaceImplementation(MyExportedInterfaceNoOverride.class); + }); + Aggregator2 aggregator = getField("aggregator"); + myExportedInterface.myfunctionString("hello", 300); + Assert.assertEquals(2, aggregator.updateCount); + Assert.assertEquals(1, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='myfunction s:hello y:300'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='myfunction s:hello y:300'}", aggregator.parent2.toString()); + + // + myExportedInterface.myfunctionList(Arrays.asList("", "", ""), 33); + Assert.assertEquals(4, aggregator.updateCount); + Assert.assertEquals(2, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='myfunction s:3 y:33'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='myfunction s:3 y:33'}", aggregator.parent2.toString()); + + myExportedInterface.myfunctionDouble(Arrays.asList(24.5), 344); + Assert.assertEquals(4, aggregator.updateCount); + Assert.assertEquals(2, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='myfunction s:3 y:33'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='myfunction s:3 y:33'}", aggregator.parent2.toString()); + } + public static class ExportingNode extends ExportFunctionNode { @@ -61,13 +92,13 @@ public ExportingNode(String name) { @ExportFunction("updatedDetails") - public boolean myfunction(String s, int y) { + public boolean myfunctionString(String s, int y) { result = "updatedDetails s:" + s + " y:" + y; return true; } @ExportFunction("complexCallBack") - public boolean myfunction(List s, int y) { + public boolean myfunctionList(List s, int y) { result = "complexCallBack s:" + s.size() + " y:" + y; return true; } @@ -86,6 +117,42 @@ public String toString() { } } + public static class ExportingNodeNoOverride extends ExportFunctionNode { + + private final String name; + private String result; + + public ExportingNodeNoOverride(String name) { + this.name = name; + } + + + @ExportFunction() + public boolean myfunctionString(String s, int y) { + result = "myfunction s:" + s + " y:" + y; + return true; + } + + @ExportFunction() + public boolean myfunctionList(List s, int y) { + result = "myfunction s:" + s.size() + " y:" + y; + return true; + } + + @ExportFunction() + public boolean myfunctionDouble(List s, int y) { + return false; + } + + @Override + public String toString() { + return "ExportingNode{" + + "name='" + name + '\'' + + ", result='" + result + '\'' + + '}'; + } + } + public static class Aggregator { @@ -111,4 +178,29 @@ public boolean triggered() { return true; } } + + public static class Aggregator2 { + + public final ExportingNodeNoOverride parent; + public final ExportingNodeNoOverride parent2; + public int updateCount; + public int triggerCount; + + public Aggregator2(@AssignToField("parent") ExportingNodeNoOverride parent, + @AssignToField("parent2") ExportingNodeNoOverride parent2) { + this.parent = parent; + this.parent2 = parent2; + } + + @OnParentUpdate + public void parentUpdated(ExportingNodeNoOverride updatedNode) { + updateCount++; + } + + @OnTrigger + public boolean triggered() { + triggerCount++; + return true; + } + } } diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/MyExportedInterfaceNoOverride.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/MyExportedInterfaceNoOverride.java new file mode 100644 index 000000000..9bdafa2ce --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/MyExportedInterfaceNoOverride.java @@ -0,0 +1,12 @@ +package com.fluxtion.compiler.generation.exportfunction; + +import java.util.List; + +public interface MyExportedInterfaceNoOverride { + + void myfunctionString(String s, int y); + + void myfunctionList(List s, int y); + + void myfunctionDouble(List s, int y); +} From 17db3130ed154a90f757fd6b9d388a2d67684065 Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 11 Jun 2023 21:57:00 +0000 Subject: [PATCH 040/228] updating poms for 9.0.9-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 320d53b07..1a92939b9 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.8-SNAPSHOT + 9.0.9-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 47dc80c48..5d3cfec0b 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.8-SNAPSHOT + 9.0.9-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 42029907c..219dbf986 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.8-SNAPSHOT + 9.0.9-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index b63fc65b8..548baa3a6 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.8-SNAPSHOT + 9.0.9-SNAPSHOT ../parent-root/pom.xml From 22190bad072b59219ac05c73a2248c993bbb6d09 Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 11 Jun 2023 21:57:04 +0000 Subject: [PATCH 041/228] updating poms for branch'release/9.0.8' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 320d53b07..96b1ca50f 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.8-SNAPSHOT + 9.0.8 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 47dc80c48..fbcde5549 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.8-SNAPSHOT + 9.0.8 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 42029907c..4dff11bda 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.8-SNAPSHOT + 9.0.8 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index b63fc65b8..d7abd7a15 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.8-SNAPSHOT + 9.0.8 ../parent-root/pom.xml From e79871fe50c2f7eacf4f5d42d33824e96e4505c3 Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 11 Jun 2023 22:00:48 +0000 Subject: [PATCH 042/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 1a92939b9..96b1ca50f 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.9-SNAPSHOT + 9.0.8 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 5d3cfec0b..fbcde5549 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.9-SNAPSHOT + 9.0.8 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 219dbf986..4dff11bda 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.9-SNAPSHOT + 9.0.8 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 548baa3a6..d7abd7a15 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.9-SNAPSHOT + 9.0.8 ../parent-root/pom.xml From 07efcc28de717e443f787a1c92cfd0d819436de6 Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 11 Jun 2023 22:00:48 +0000 Subject: [PATCH 043/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 96b1ca50f..1a92939b9 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.8 + 9.0.9-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index fbcde5549..5d3cfec0b 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.8 + 9.0.9-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 4dff11bda..219dbf986 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.8 + 9.0.9-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index d7abd7a15..548baa3a6 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.8 + 9.0.9-SNAPSHOT ../parent-root/pom.xml From dd5a5d613665bed416951be2626d795198dbe2fa Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 14 Jun 2023 11:52:34 +0100 Subject: [PATCH 044/228] support interpreted export functions --- .../compiler/EventProcessorGenerator.java | 2 +- .../targets/InMemoryEventProcessor.java | 97 ++++++++++++++++++- .../compiler/generation/util/ClassUtils.java | 4 +- .../exportfunction/ExportFunctionTest.java | 11 ++- .../exportfunction/ExportInterpretedTest.java | 80 +++++++++++++++ .../runtime/StaticEventProcessor.java | 13 +++ 6 files changed, 199 insertions(+), 8 deletions(-) create mode 100644 compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportInterpretedTest.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java index e46a4ceda..6bc1ed0c9 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java @@ -92,7 +92,7 @@ public InMemoryEventProcessor inMemoryProcessor(EventProcessorConfig config, boo if (generateDescription && !GenerationContext.SINGLETON.getPackageName().isEmpty()) { exportGraphMl(graph); } - return new InMemoryEventProcessor(simpleEventProcessorModel); + return new InMemoryEventProcessor(simpleEventProcessorModel, config); } public void templateSep(EventProcessorConfig config, boolean generateDescription, Writer writer) throws Exception { diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java index b76da2183..0c838cb6f 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java @@ -1,7 +1,10 @@ package com.fluxtion.compiler.generation.targets; +import com.fluxtion.compiler.EventProcessorConfig; import com.fluxtion.compiler.builder.filter.FilterDescription; +import com.fluxtion.compiler.generation.compiler.classcompiler.StringCompilation; import com.fluxtion.compiler.generation.model.CbMethodHandle; +import com.fluxtion.compiler.generation.model.ExportFunctionData; import com.fluxtion.compiler.generation.model.Field; import com.fluxtion.compiler.generation.model.SimpleEventProcessorModel; import com.fluxtion.compiler.generation.util.ClassUtils; @@ -12,6 +15,7 @@ import com.fluxtion.runtime.audit.Auditor; import com.fluxtion.runtime.callback.CallbackDispatcher; import com.fluxtion.runtime.callback.EventProcessorCallbackInternal; +import com.fluxtion.runtime.callback.ExportFunctionTrigger; import com.fluxtion.runtime.callback.InternalEventProcessor; import com.fluxtion.runtime.event.Event; import com.fluxtion.runtime.input.EventFeed; @@ -23,6 +27,7 @@ import com.fluxtion.runtime.node.MutableEventProcessorContext; import lombok.Data; import lombok.SneakyThrows; +import lombok.Value; import lombok.extern.slf4j.Slf4j; import org.reflections.ReflectionUtils; @@ -37,6 +42,8 @@ import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.StringJoiner; +import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BooleanSupplier; import java.util.stream.Collectors; @@ -45,6 +52,7 @@ public class InMemoryEventProcessor implements EventProcessor, StaticEventProcessor, InternalEventProcessor, Lifecycle, BatchHandler { private final SimpleEventProcessorModel simpleEventProcessorModel; + private final EventProcessorConfig config; private final MutableEventProcessorContext context; private final EventProcessorCallbackInternal callbackDispatcher; private final SubscriptionManagerNode subscriptionManager; @@ -62,9 +70,11 @@ public class InMemoryEventProcessor implements EventProcessor, StaticEventProces private boolean processing = false; private boolean isDefaultHandling; private boolean initCalled = false; + private Object exportingWrapper; - public InMemoryEventProcessor(SimpleEventProcessorModel simpleEventProcessorModel) { + public InMemoryEventProcessor(SimpleEventProcessorModel simpleEventProcessorModel, EventProcessorConfig config) { this.simpleEventProcessorModel = simpleEventProcessorModel; + this.config = config; try { context = getNodeById(EventProcessorContext.DEFAULT_NODE_NAME); callbackDispatcher = getNodeById(CallbackDispatcher.DEFAULT_NODE_NAME); @@ -505,6 +515,91 @@ private void buildDispatch() { registerAuditors(); } + @Value + private static class CallbackInstance { + Object instance; + String variableName; + + private CallbackInstance(CbMethodHandle cbMethodHandle) { + instance = cbMethodHandle.getInstance(); + variableName = cbMethodHandle.getVariableName(); + } + } + + @SneakyThrows + @SuppressWarnings("unchecked") + public T asInterface() { + if (exportingWrapper != null) { + return (T) exportingWrapper; + } + String packageName = "com.fluxtion.compiler.generation.targets.temp"; + String className = "InMemoryExportWrapper_" + UUID.randomUUID().toString().replace("-", "_"); + String fqn = packageName + "." + className; + + String additionalInterfaces = ""; + if (!config.interfacesToImplement().isEmpty()) { + additionalInterfaces = config.interfacesToImplement().stream() + .map(Class::getCanonicalName) + .collect(Collectors.joining(", ", " implements ", "")); + } + + Map exportedFunctionMap = simpleEventProcessorModel.getExportedFunctionMap(); + Set exportCbSet = exportedFunctionMap.values().stream() + .map(ExportFunctionData::getFunctionCallBackList).flatMap(List::stream) + .map(CallbackInstance::new) + .collect(Collectors.toSet()); + + String triggerDeclarations = exportedFunctionMap.values().stream() + .map(ExportFunctionData::getExportFunctionTrigger) + .map(e -> "ExportFunctionTrigger " + e.getName()) + .collect(Collectors.joining(";\n\t", "\n\t", ";\n")); + + String declarations = exportCbSet.stream() + .map(c -> c.getInstance().getClass().getCanonicalName() + " " + c.getVariableName()) + .collect(Collectors.joining(";\n\t", "\tInMemoryEventProcessor processor;\n\t", ";" + triggerDeclarations)); + + + String triggerAssignments = exportedFunctionMap.values().stream() + .map(ExportFunctionData::getExportFunctionTrigger) + .map(e -> e.getName() + " = processor.getNodeById(\"" + e.getName() + "\")") + .collect(Collectors.joining(";\n\t", "\n\t", ";\n")); + + String constructor = exportCbSet.stream() + .map(c -> c.getVariableName() + " = processor.getNodeById(\"" + c.getVariableName() + "\")") + .collect(Collectors.joining( + ";\n\t", + "public " + className + "(InMemoryEventProcessor processor) throws java.lang.NoSuchFieldException {\n" + + "\tthis.processor = processor;\n\t", + ";" + triggerAssignments + "}\n")); + + String delegateOnEvent = "void onEvent(Object o){\n\tprocessor.onEvent(o);\n}"; + + List keys = new ArrayList<>(exportedFunctionMap.keySet()); + keys.sort(String::compareTo); + StringJoiner joiner = new StringJoiner("\n\n", "\n", ""); + joiner.setEmptyValue(""); + for (String key : keys) { + if (!exportedFunctionMap.get(key).getFunctionCallBackList().isEmpty()) { + joiner.add(ClassUtils.wrapExportedFunctionCall(key, exportedFunctionMap.get(key), simpleEventProcessorModel)); + } + } + String exportedMethods = joiner.toString(); + + StringBuilder sb = new StringBuilder("package " + packageName + ";\n\n" + + "import " + this.getClass().getCanonicalName() + ";\n" + + "import " + ExportFunctionTrigger.class.getCanonicalName() + ";\n\n" + + "public class " + className + additionalInterfaces + " {\n" + + declarations + "\n" + + constructor + "\n" + + delegateOnEvent + "\n" + + exportedMethods + "\n" + + "}"); + + Class clazz = StringCompilation.compile(fqn, sb.toString()); + exportingWrapper = clazz.getConstructor(InMemoryEventProcessor.class).newInstance(this); + return (T) exportingWrapper; + } + private void registerAuditors() { //register auditors List auditorFields = simpleEventProcessorModel.getNodeRegistrationListenerFields().stream() diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java index 4fd73ea11..699fafb59 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java @@ -223,9 +223,9 @@ static String wrapExportedFunctionCall(String exportedMethodName, ExportFunction argNumber.increment(); } signature.append(sj); - signature.append("){"); + signature.append("){\n\t"); //method calls - StringJoiner sjInvoker = new StringJoiner(", ", "(", "));\n"); + StringJoiner sjInvoker = new StringJoiner(", ", "(", "));\n\t"); for (int i = 0; i < argNumber.intValue(); i++) { sjInvoker.add("arg" + i); } diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java index 6cbbb02f6..22e32d6a9 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java @@ -1,7 +1,7 @@ package com.fluxtion.compiler.generation.exportfunction; import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; -import com.fluxtion.compiler.generation.util.CompiledOnlySepTest; +import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; import com.fluxtion.runtime.annotations.ExportFunction; import com.fluxtion.runtime.annotations.OnParentUpdate; import com.fluxtion.runtime.annotations.OnTrigger; @@ -13,7 +13,8 @@ import java.util.Arrays; import java.util.List; -public class ExportFunctionTest extends CompiledOnlySepTest { +public class ExportFunctionTest extends MultipleSepTargetInProcessTest { + public ExportFunctionTest(SepTestConfig compile) { super(compile); } @@ -21,13 +22,14 @@ public ExportFunctionTest(SepTestConfig compile) { @Test public void exportTest() { // writeSourceFile = true; - MyExportedInterface myExportedInterface = (MyExportedInterface) sep(c -> { + sep(c -> { c.addNode(new Aggregator( new ExportingNode("export1"), new ExportingNode("export2") ), "aggregator"); c.addInterfaceImplementation(MyExportedInterface.class); }); + MyExportedInterface myExportedInterface = sep.asInterface(); Aggregator aggregator = getField("aggregator"); myExportedInterface.updatedDetails("hello", 300); Assert.assertEquals(2, aggregator.updateCount); @@ -52,13 +54,14 @@ public void exportTest() { @Test public void exportTestNoOverride() { // writeSourceFile = true; - MyExportedInterfaceNoOverride myExportedInterface = (MyExportedInterfaceNoOverride) sep(c -> { + sep(c -> { c.addNode(new Aggregator2( new ExportingNodeNoOverride("export1"), new ExportingNodeNoOverride("export2") ), "aggregator"); c.addInterfaceImplementation(MyExportedInterfaceNoOverride.class); }); + MyExportedInterfaceNoOverride myExportedInterface = sep.asInterface(); Aggregator2 aggregator = getField("aggregator"); myExportedInterface.myfunctionString("hello", 300); Assert.assertEquals(2, aggregator.updateCount); diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportInterpretedTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportInterpretedTest.java new file mode 100644 index 000000000..763ffca2f --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportInterpretedTest.java @@ -0,0 +1,80 @@ +package com.fluxtion.compiler.generation.exportfunction; + +import com.fluxtion.compiler.generation.exportfunction.ExportFunctionTest.Aggregator; +import com.fluxtion.compiler.generation.exportfunction.ExportFunctionTest.Aggregator2; +import com.fluxtion.compiler.generation.exportfunction.ExportFunctionTest.ExportingNode; +import com.fluxtion.compiler.generation.exportfunction.ExportFunctionTest.ExportingNodeNoOverride; +import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; +import com.fluxtion.compiler.generation.util.InMemoryOnlySepTest; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Arrays; + +public class ExportInterpretedTest extends InMemoryOnlySepTest { + public ExportInterpretedTest(SepTestConfig compiledSep) { + super(compiledSep); + } + + @Test + public void exportTest() { + sep(c -> { + c.addNode(new Aggregator( + new ExportingNode("export1"), + new ExportingNode("export2") + ), "aggregator"); + c.addInterfaceImplementation(MyExportedInterface.class); + }); + MyExportedInterface myExportedInterface = sep.asInterface(); + Aggregator aggregator = getField("aggregator"); + myExportedInterface.updatedDetails("hello", 300); + Assert.assertEquals(2, aggregator.updateCount); + Assert.assertEquals(1, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='updatedDetails s:hello y:300'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='updatedDetails s:hello y:300'}", aggregator.parent2.toString()); + + // + myExportedInterface.complexCallBack(Arrays.asList("", "", ""), 33); + Assert.assertEquals(4, aggregator.updateCount); + Assert.assertEquals(2, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='complexCallBack s:3 y:33'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='complexCallBack s:3 y:33'}", aggregator.parent2.toString()); + + myExportedInterface.complexCallBackDouble(Arrays.asList(24.5), 344); + Assert.assertEquals(4, aggregator.updateCount); + Assert.assertEquals(2, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='complexCallBack s:3 y:33'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='complexCallBack s:3 y:33'}", aggregator.parent2.toString()); + } + + @Test + public void exportTestNoOverride() { + sep(c -> { + c.addNode(new Aggregator2( + new ExportingNodeNoOverride("export1"), + new ExportingNodeNoOverride("export2") + ), "aggregator"); + c.addInterfaceImplementation(MyExportedInterfaceNoOverride.class); + }); + MyExportedInterfaceNoOverride myExportedInterface = sep.asInterface(); + Aggregator2 aggregator = getField("aggregator"); + myExportedInterface.myfunctionString("hello", 300); + Assert.assertEquals(2, aggregator.updateCount); + Assert.assertEquals(1, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='myfunction s:hello y:300'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='myfunction s:hello y:300'}", aggregator.parent2.toString()); + + // + myExportedInterface.myfunctionList(Arrays.asList("", "", ""), 33); + Assert.assertEquals(4, aggregator.updateCount); + Assert.assertEquals(2, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='myfunction s:3 y:33'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='myfunction s:3 y:33'}", aggregator.parent2.toString()); + + myExportedInterface.myfunctionDouble(Arrays.asList(24.5), 344); + Assert.assertEquals(4, aggregator.updateCount); + Assert.assertEquals(2, aggregator.triggerCount); + Assert.assertEquals("ExportingNode{name='export1', result='myfunction s:3 y:33'}", aggregator.parent.toString()); + Assert.assertEquals("ExportingNode{name='export2', result='myfunction s:3 y:33'}", aggregator.parent2.toString()); + } +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java b/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java index dfa018228..44b688101 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java +++ b/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java @@ -366,4 +366,17 @@ default String getLastAuditLogRecord() { default void setClockStrategy(ClockStrategy clockStrategy) { onEvent(ClockStrategy.registerClockEvent(clockStrategy)); } + + /** + * Returns an instance of the event processor cast to an interface type. The implemented interfaces of an event processor + * are specified using the com.fluxtion.compiler.EventProcessorConfig#addInterfaceImplementation during the + * building phase of the processor. + * + * @param the interface type to cast to + * @return The {@link StaticEventProcessor} cast to an interface + */ + @SuppressWarnings("unchecked") + default T asInterface() { + return (T) this; + } } From a3db2e6df9e6b82668c80dd451abd1ef3b5e1830 Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 14 Jun 2023 12:27:39 +0100 Subject: [PATCH 045/228] bump version and update nexus-staging-maven-plugin to version 1.6.13 --- compiler/pom.xml | 2 +- parent-root/pom.xml | 5 +++-- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 1a92939b9..6bc3e34dc 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.9-SNAPSHOT + 9.0.10-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 5d3cfec0b..e7d1ecf17 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.9-SNAPSHOT + 9.0.10-SNAPSHOT pom fluxtion :: poms :: parent root @@ -92,7 +92,8 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.7 + 1.6.13 + true ossrh diff --git a/pom.xml b/pom.xml index 219dbf986..7ededbd9f 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.9-SNAPSHOT + 9.0.10-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 548baa3a6..e90e40d4c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.9-SNAPSHOT + 9.0.10-SNAPSHOT ../parent-root/pom.xml From 3fe04a776389d4cc732a4307dd8a560ce60e36e8 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 11:31:15 +0000 Subject: [PATCH 046/228] updating poms for 9.0.11-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 6bc3e34dc..c2744b25a 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.10-SNAPSHOT + 9.0.11-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index e7d1ecf17..59f6ef752 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.10-SNAPSHOT + 9.0.11-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 7ededbd9f..2ab7d145d 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.10-SNAPSHOT + 9.0.11-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index e90e40d4c..40a245f40 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.10-SNAPSHOT + 9.0.11-SNAPSHOT ../parent-root/pom.xml From 8f9cf23e45b342487e7d6004fb21f3c789d78f38 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 11:31:24 +0000 Subject: [PATCH 047/228] updating poms for branch'release/9.0.10' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 6bc3e34dc..8e053991c 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.10-SNAPSHOT + 9.0.10 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index e7d1ecf17..07c2f0d6b 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.10-SNAPSHOT + 9.0.10 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 7ededbd9f..3f220777e 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.10-SNAPSHOT + 9.0.10 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index e90e40d4c..297ab929d 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.10-SNAPSHOT + 9.0.10 ../parent-root/pom.xml From e5a30727f5e33a8ad833c112a66235b826728a47 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 11:34:52 +0000 Subject: [PATCH 048/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c2744b25a..8e053991c 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.11-SNAPSHOT + 9.0.10 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 59f6ef752..07c2f0d6b 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.11-SNAPSHOT + 9.0.10 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 2ab7d145d..3f220777e 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.11-SNAPSHOT + 9.0.10 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 40a245f40..297ab929d 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.11-SNAPSHOT + 9.0.10 ../parent-root/pom.xml From cccc4b5a97a21010d496c81b43c075075a41078b Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 11:34:53 +0000 Subject: [PATCH 049/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 8e053991c..c2744b25a 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.10 + 9.0.11-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 07c2f0d6b..59f6ef752 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.10 + 9.0.11-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 3f220777e..2ab7d145d 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.10 + 9.0.11-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 297ab929d..40a245f40 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.10 + 9.0.11-SNAPSHOT ../parent-root/pom.xml From 1f28a957724f5145c751c439a18c8dd3095147b4 Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 14 Jun 2023 13:35:32 +0100 Subject: [PATCH 050/228] support onEvent and lifecycle methods in InMemoryEventProcessor export wrapper --- .../generation/targets/InMemoryEventProcessor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java index 0c838cb6f..e9f3fd009 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java @@ -572,7 +572,12 @@ public T asInterface() { "\tthis.processor = processor;\n\t", ";" + triggerAssignments + "}\n")); - String delegateOnEvent = "void onEvent(Object o){\n\tprocessor.onEvent(o);\n}"; + String delegateOnEvent = "public void onEvent(Object o){\n\tprocessor.onEvent(o);\n}" + + "public void init(){\n\tprocessor.init();\n}" + + "public void start(){\n\tprocessor.start();\n}" + + "public void stop(){\n\tprocessor.stop();\n}" + + "public InMemoryEventProcessor processor(){\n\treturn processor;\n}" + + "public void tearDown(){\n\tprocessor.tearDown();\n}"; List keys = new ArrayList<>(exportedFunctionMap.keySet()); keys.sort(String::compareTo); From 95164fb6209fd552911374f906b5320952e3b392 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 12:44:06 +0000 Subject: [PATCH 051/228] updating poms for 9.0.12-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c2744b25a..19d387790 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.11-SNAPSHOT + 9.0.12-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 59f6ef752..7045ea7b0 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.11-SNAPSHOT + 9.0.12-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 2ab7d145d..5bc9dc6c6 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.11-SNAPSHOT + 9.0.12-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 40a245f40..69f0ded84 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.11-SNAPSHOT + 9.0.12-SNAPSHOT ../parent-root/pom.xml From a30710b342c8d080cdec52bb1a0c061a674a0b61 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 12:44:12 +0000 Subject: [PATCH 052/228] updating poms for branch'release/9.0.11' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c2744b25a..587248e63 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.11-SNAPSHOT + 9.0.11 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 59f6ef752..c0dac6e84 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.11-SNAPSHOT + 9.0.11 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 2ab7d145d..4238d7b79 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.11-SNAPSHOT + 9.0.11 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 40a245f40..b5f26b38f 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.11-SNAPSHOT + 9.0.11 ../parent-root/pom.xml From dc0d9f51a23040b4f0e67d98942ecb63492a2b05 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 12:48:37 +0000 Subject: [PATCH 053/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 19d387790..587248e63 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.12-SNAPSHOT + 9.0.11 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 7045ea7b0..c0dac6e84 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.12-SNAPSHOT + 9.0.11 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 5bc9dc6c6..4238d7b79 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.12-SNAPSHOT + 9.0.11 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 69f0ded84..b5f26b38f 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.12-SNAPSHOT + 9.0.11 ../parent-root/pom.xml From 5121610968148d2d956c64a8c55f9e88e0ed1622 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 12:48:38 +0000 Subject: [PATCH 054/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 587248e63..19d387790 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.11 + 9.0.12-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index c0dac6e84..7045ea7b0 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.11 + 9.0.12-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 4238d7b79..5bc9dc6c6 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.11 + 9.0.12-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index b5f26b38f..69f0ded84 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.11 + 9.0.12-SNAPSHOT ../parent-root/pom.xml From 515a04e491fcad170e3ff3da6ec2d7f8a7587a66 Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 14 Jun 2023 19:28:28 +0100 Subject: [PATCH 055/228] optimise function based dispatch and support buffering --- .../targets/InMemoryEventProcessor.java | 16 ++++----- .../targets/JavaSourceGenerator.java | 2 +- .../compiler/generation/util/ClassUtils.java | 35 ++++++++++++++++--- .../callback/ExportFunctionTrigger.java | 4 +-- 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java index e9f3fd009..d80a44020 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java @@ -65,9 +65,9 @@ public class InMemoryEventProcessor implements EventProcessor, StaticEventProces private final Map, List> noFilterEventHandlerToBitsetMap = new HashMap<>(); private final Map> filteredEventHandlerToBitsetMap = new HashMap<>(); private final List auditors = new ArrayList<>(); - private boolean buffering = false; + public boolean buffering = false; private Object currentEvent; - private boolean processing = false; + public boolean processing = false; private boolean isDefaultHandling; private boolean initCalled = false; private Object exportingWrapper; @@ -572,11 +572,11 @@ public T asInterface() { "\tthis.processor = processor;\n\t", ";" + triggerAssignments + "}\n")); - String delegateOnEvent = "public void onEvent(Object o){\n\tprocessor.onEvent(o);\n}" + - "public void init(){\n\tprocessor.init();\n}" + - "public void start(){\n\tprocessor.start();\n}" + - "public void stop(){\n\tprocessor.stop();\n}" + - "public InMemoryEventProcessor processor(){\n\treturn processor;\n}" + + String delegateOnEvent = "public void onEvent(Object o){\n\tprocessor.onEvent(o);\n}\n\n" + + "public void init(){\n\tprocessor.init();\n}\n\n" + + "public void start(){\n\tprocessor.start();\n}\n\n" + + "public void stop(){\n\tprocessor.stop();\n}\n\n" + + "public InMemoryEventProcessor processor(){\n\treturn processor;\n}\n\n" + "public void tearDown(){\n\tprocessor.tearDown();\n}"; List keys = new ArrayList<>(exportedFunctionMap.keySet()); @@ -585,7 +585,7 @@ public T asInterface() { joiner.setEmptyValue(""); for (String key : keys) { if (!exportedFunctionMap.get(key).getFunctionCallBackList().isEmpty()) { - joiner.add(ClassUtils.wrapExportedFunctionCall(key, exportedFunctionMap.get(key), simpleEventProcessorModel)); + joiner.add(ClassUtils.wrapExportedFunctionCall(key, exportedFunctionMap.get(key), true)); } } String exportedMethods = joiner.toString(); diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/JavaSourceGenerator.java b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/JavaSourceGenerator.java index 0aeba5fc7..6e29c4d4e 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/JavaSourceGenerator.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/JavaSourceGenerator.java @@ -375,7 +375,7 @@ private void buildExportedMethods() { //multicast for (String key : keys) { if (!exportedFunctionDataMap.get(key).getFunctionCallBackList().isEmpty()) { - joiner.add(ClassUtils.wrapExportedFunctionCall(key, exportedFunctionDataMap.get(key), model)); + joiner.add(ClassUtils.wrapExportedFunctionCall(key, exportedFunctionDataMap.get(key), false)); } } exportedMethods = joiner.toString(); diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java index 699fafb59..8fb493403 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java @@ -21,6 +21,7 @@ import com.fluxtion.compiler.generation.model.ExportFunctionData; import com.fluxtion.compiler.generation.model.Field; import com.fluxtion.compiler.generation.model.SimpleEventProcessorModel; +import com.fluxtion.runtime.callback.ExportFunctionTrigger; import lombok.SneakyThrows; import net.vidageek.mirror.dsl.Mirror; import org.reflections.ReflectionUtils; @@ -206,7 +207,7 @@ static String wrapExportedFunctionCall(String exportedMethodName, List callBackList = exportFunctionData.getFunctionCallBackList(); Method delegateMethod = callBackList.get(0).getMethod(); @@ -215,7 +216,9 @@ static String wrapExportedFunctionCall(String exportedMethodName, ExportFunction StringJoiner sj = new StringJoiner(", "); Type[] params = delegateMethod.getGenericParameterTypes(); for (int j = 0; j < params.length; j++) { - String param = params[j].getTypeName(); + String param = params[j].getTypeName() + .replace("$", ".") + .replace("java.lang.", ""); if (delegateMethod.isVarArgs() && (j == params.length - 1)) // replace T[] with T... param = param.replaceFirst("\\[\\]$", "..."); param += " arg" + argNumber.intValue(); @@ -224,6 +227,17 @@ static String wrapExportedFunctionCall(String exportedMethodName, ExportFunction } signature.append(sj); signature.append("){\n\t"); + // + if (onEventDispatch) { + signature.append("if(processor().buffering){\n" + + " processor().triggerCalculation();\n" + + " }\n\t"); + } else { + signature.append("if(buffering){\n" + + " triggerCalculation();\n" + + " }\n" + + " processing = true;\n\t"); + } //method calls StringJoiner sjInvoker = new StringJoiner(", ", "(", "));\n\t"); for (int i = 0; i < argNumber.intValue(); i++) { @@ -236,9 +250,20 @@ static String wrapExportedFunctionCall(String exportedMethodName, ExportFunction }); //close //onEvent(handlerExportFunctionTriggerEvent_0.getEvent()); - signature.append("onEvent(") - .append(exportFunctionData.getExportFunctionTrigger().getName()).append(".getEvent());\n") - .append("}"); + ExportFunctionTrigger exportFunctionTrigger = exportFunctionData.getExportFunctionTrigger(); + if (onEventDispatch) { + signature.append("onEvent(") + .append(exportFunctionTrigger.getName()).append(".getEvent());\n"); + } else { + signature.append("handleEvent(") + .append("(").append(exportFunctionTrigger.eventClass().getSimpleName()).append(")") + .append(exportFunctionTrigger.getName()).append(".getEvent());\n") + ; + } + if (!onEventDispatch) { + signature.append(" processing = false;"); + } + signature.append("}"); return signature.toString(); } diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTrigger.java b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTrigger.java index 8cf5b8600..b293483bf 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTrigger.java +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTrigger.java @@ -34,11 +34,11 @@ public ExportFunctionTrigger() { } @Override - public boolean onEvent(Object e) { + public final boolean onEvent(Object e) { return true; } - public Object getEvent() { + public final Object getEvent() { return event; } From 92076ceadbee39a457f5caa27c5554253f8d6860 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 18:37:31 +0000 Subject: [PATCH 056/228] updating poms for 9.0.13-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 19d387790..7347cb2a3 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.12-SNAPSHOT + 9.0.13-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 7045ea7b0..2726616ba 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.12-SNAPSHOT + 9.0.13-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 5bc9dc6c6..ceef2d1ff 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.12-SNAPSHOT + 9.0.13-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 69f0ded84..cfd3449f6 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.12-SNAPSHOT + 9.0.13-SNAPSHOT ../parent-root/pom.xml From 1c0be06fdafc8623c24802eda258380fd87dc77f Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 18:37:41 +0000 Subject: [PATCH 057/228] updating poms for branch'release/9.0.12' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 19d387790..c6f8902bc 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.12-SNAPSHOT + 9.0.12 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 7045ea7b0..92d25956f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.12-SNAPSHOT + 9.0.12 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 5bc9dc6c6..731ef8419 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.12-SNAPSHOT + 9.0.12 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 69f0ded84..0dd4a906c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.12-SNAPSHOT + 9.0.12 ../parent-root/pom.xml From 8fbec11fb0e39cf6b02ad085e00a7bc3d8f5c380 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 18:41:10 +0000 Subject: [PATCH 058/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 7347cb2a3..c6f8902bc 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.13-SNAPSHOT + 9.0.12 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2726616ba..92d25956f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.13-SNAPSHOT + 9.0.12 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index ceef2d1ff..731ef8419 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.13-SNAPSHOT + 9.0.12 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index cfd3449f6..0dd4a906c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.13-SNAPSHOT + 9.0.12 ../parent-root/pom.xml From 109c87565ecee079730d17345bf1c448cf0c3ac8 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 14 Jun 2023 18:41:10 +0000 Subject: [PATCH 059/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c6f8902bc..7347cb2a3 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.12 + 9.0.13-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 92d25956f..2726616ba 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.12 + 9.0.13-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 731ef8419..ceef2d1ff 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.12 + 9.0.13-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 0dd4a906c..cfd3449f6 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.12 + 9.0.13-SNAPSHOT ../parent-root/pom.xml From 48f72567ed24dfce5f76741a9adfe8327c2cfcce Mon Sep 17 00:00:00 2001 From: greg higgins Date: Thu, 15 Jun 2023 08:53:14 +0100 Subject: [PATCH 060/228] Create codeql.yml --- .github/workflows/codeql.yml | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..f2a50edc1 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,77 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '28 14 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" From f2de043d7bea504e906338863ef32675d17585c2 Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 21 Jun 2023 14:58:05 +0100 Subject: [PATCH 061/228] ignore transient fields when walking the event handling tree --- .../generation/model/TopologicallySortedDependencyGraph.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java b/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java index c8015dbd9..8f070999b 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java @@ -693,7 +693,7 @@ private void walkDependenciesForEventHandling(Object object) throws IllegalArgum }); fields = s.toArray(fields); for (Field field : fields) { - if (!trySetAccessible(field)) { + if (!trySetAccessible(field) || Modifier.isTransient(field.getModifiers())) { continue; } Object refField = field.get(object); From 355167c7c567c8d826fd3f2c9c119961dbd124ea Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 21 Jun 2023 14:06:28 +0000 Subject: [PATCH 062/228] updating poms for 9.0.14-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 7347cb2a3..e3cd1dc70 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.13-SNAPSHOT + 9.0.14-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2726616ba..160e3bfae 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.13-SNAPSHOT + 9.0.14-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index ceef2d1ff..22120e33b 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.13-SNAPSHOT + 9.0.14-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index cfd3449f6..fd643da2c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.13-SNAPSHOT + 9.0.14-SNAPSHOT ../parent-root/pom.xml From d6c030209f85d5911295ea9ee4f3ea9160de49c1 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 21 Jun 2023 14:06:35 +0000 Subject: [PATCH 063/228] updating poms for branch'release/9.0.13' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 7347cb2a3..918b72022 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.13-SNAPSHOT + 9.0.13 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2726616ba..89277eea2 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.13-SNAPSHOT + 9.0.13 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index ceef2d1ff..658a9b231 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.13-SNAPSHOT + 9.0.13 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index cfd3449f6..564ac1ce6 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.13-SNAPSHOT + 9.0.13 ../parent-root/pom.xml From a929a153feaff56a5571903b99859794c5ba58da Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 21 Jun 2023 14:10:02 +0000 Subject: [PATCH 064/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index e3cd1dc70..918b72022 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.14-SNAPSHOT + 9.0.13 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 160e3bfae..89277eea2 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.14-SNAPSHOT + 9.0.13 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 22120e33b..658a9b231 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.14-SNAPSHOT + 9.0.13 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fd643da2c..564ac1ce6 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.14-SNAPSHOT + 9.0.13 ../parent-root/pom.xml From ef51697a19ef6181eeefa935ced9fd5e6da7b643 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 21 Jun 2023 14:10:02 +0000 Subject: [PATCH 065/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 918b72022..e3cd1dc70 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.13 + 9.0.14-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 89277eea2..160e3bfae 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.13 + 9.0.14-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 658a9b231..22120e33b 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.13 + 9.0.14-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 564ac1ce6..fd643da2c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.13 + 9.0.14-SNAPSHOT ../parent-root/pom.xml From e4c5ab74ae951ccd2ab1df2de01225b3cd76c2b0 Mon Sep 17 00:00:00 2001 From: command-line Date: Thu, 22 Jun 2023 12:46:52 +0100 Subject: [PATCH 066/228] InMemoryEventProcessor fix subclass filtered events. Add shortcut methods of Fluxtion for building with a varag list of nodes --- .../java/com/fluxtion/compiler/Fluxtion.java | 33 ++++++++++++++ .../targets/InMemoryEventProcessor.java | 2 +- .../subclass/EventSubclassTest.java | 45 ++++++++++++++----- .../util/MultipleSepTargetInProcessTest.java | 8 ++++ 4 files changed, 77 insertions(+), 11 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java b/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java index eaf3f3827..6c5568286 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java +++ b/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java @@ -43,6 +43,14 @@ static EventProcessor compile(SerializableConsumer sepConf return EventProcessorFactory.compile(sepConfig); } + static EventProcessor compile(Object... nodes) { + return compile(c -> { + for (int i = 0; i < nodes.length; i++) { + c.addNode(nodes[i]); + } + }); + } + /** * Compiles the SEP in memory and captures the output to a user supplied {@link Writer} * @@ -72,6 +80,23 @@ static EventProcessor compileAot(SerializableConsumer cfgB return compile(cfgBuilder, compilerCfg -> compilerCfg.setPackageName(packageName)); } + static EventProcessor compileAot(String packageName, + String className, + Object... nodes) { + return compileAot(c -> { + for (int i = 0; i < nodes.length; i++) { + c.addNode(nodes[i]); + } + }, packageName, className); + } + + static EventProcessor compileAot(Object... nodes) { + return compileAot(c -> { + for (int i = 0; i < nodes.length; i++) { + c.addNode(nodes[i]); + } + }); + } @SneakyThrows static EventProcessor compileAot(SerializableConsumer cfgBuilder, @@ -102,6 +127,14 @@ static EventProcessor interpret(SerializableConsumer sepCo return EventProcessorFactory.interpreted(sepConfig, generateDescription); } + static EventProcessor interpret(Object... nodes) { + return interpret(c -> { + for (int i = 0; i < nodes.length; i++) { + c.addNode(nodes[i]); + } + }); + } + /** * Generates and compiles Java source code for a {@link StaticEventProcessor}. The compiled version only requires * the Fluxtion runtime dependencies to operate and process events. diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java index d80a44020..1beb484ba 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java @@ -169,7 +169,7 @@ private void subclassDispatchSearch(BitSet updateBitset) { .filter(c -> c.isInstance(currentEvent)) .findFirst() .ifPresent(c -> { - if (c.isAssignableFrom(Event.class)) { + if (Event.class.isAssignableFrom(c)) { FilterDescription filterDescription = FilterDescription.build(currentEvent); filterDescription.setEventClass((Class) c); filteredEventHandlerToBitsetMap.getOrDefault(filterDescription, Collections.emptyList()).forEach(updateBitset::set); diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/subclass/EventSubclassTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/subclass/EventSubclassTest.java index c7fee0731..13d278030 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/subclass/EventSubclassTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/subclass/EventSubclassTest.java @@ -21,11 +21,9 @@ import com.fluxtion.runtime.annotations.OnEventHandler; import com.fluxtion.runtime.annotations.OnTrigger; import com.fluxtion.runtime.event.Event; +import com.fluxtion.runtime.node.SingleNamedNode; +import lombok.Value; import org.junit.Test; -import org.junit.runners.Parameterized; - -import java.util.Arrays; -import java.util.Collection; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -39,13 +37,29 @@ public EventSubclassTest(SepTestConfig compiledSep) { super(compiledSep); } + @Test + public void singleFilteredHandler() { + sep(new AnyTimeHandler("node")); + AnyTimeHandler handler = getField("node"); + onEvent(new ImplEvent()); + assertThat(handler.timeEvent, is(0)); + onEvent(new FilteredImplEvent("test")); + assertThat(handler.timeEvent, is(1)); + } - @Parameterized.Parameters - public static Collection compiledSepStrategy() { - return Arrays.asList( - SepTestConfig.COMPILED_METHOD_PER_EVENT, - SepTestConfig.INTERPRETED - ); + public static class AnyTimeHandler extends SingleNamedNode { + private int timeEvent; + + public AnyTimeHandler(String name) { + super(name); + } + + @OnEventHandler(filterString = "test") + public boolean anyTimeEvent(TimeEvent e) { + timeEvent++; + System.out.println("time event " + timeEvent); + return true; + } } @Test @@ -118,6 +132,17 @@ public static class ImplEvent extends TimeEvent { } + @Value + public static class FilteredImplEvent extends TimeEvent { + + String filterString; + + @Override + public String filterString() { + return filterString; + } + } + public static class ExtendTimeEvent extends TimeEvent { } diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/util/MultipleSepTargetInProcessTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/util/MultipleSepTargetInProcessTest.java index c3d5080eb..feafec235 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/util/MultipleSepTargetInProcessTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/util/MultipleSepTargetInProcessTest.java @@ -136,6 +136,14 @@ protected StaticEventProcessor sep(Consumer cfgBuilder) { return sep(cfgBuilder, new HashMap<>()); } + protected StaticEventProcessor sep(Object... nodes) { + return sep(c -> { + for (int i = 0; i < nodes.length; i++) { + c.addNode(nodes[i]); + } + }); + } + protected StaticEventProcessor sep(Consumer cfgBuilder, Map contextMap) { Consumer wrappedBuilder = cfgBuilder; if (addAuditor || inlineCompiled || !instanceOfDispatch) { From 29e98e7b4cdf291ac7f2b3be52c6c2c8c4167479 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 22 Jun 2023 11:51:37 +0000 Subject: [PATCH 067/228] updating poms for 9.0.15-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index e3cd1dc70..29dbdb4df 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.14-SNAPSHOT + 9.0.15-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 160e3bfae..c1ce3a930 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.14-SNAPSHOT + 9.0.15-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 22120e33b..f00dc120e 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.14-SNAPSHOT + 9.0.15-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fd643da2c..8ea9b1a8c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.14-SNAPSHOT + 9.0.15-SNAPSHOT ../parent-root/pom.xml From eff7c7ee1bba7290553efbdcd857a7c89968fd49 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 22 Jun 2023 11:51:49 +0000 Subject: [PATCH 068/228] updating poms for branch'release/9.0.14' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index e3cd1dc70..5c5e81fc5 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.14-SNAPSHOT + 9.0.14 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 160e3bfae..77b61e7f5 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.14-SNAPSHOT + 9.0.14 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 22120e33b..6cd36c2cf 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.14-SNAPSHOT + 9.0.14 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fd643da2c..43b2c718c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.14-SNAPSHOT + 9.0.14 ../parent-root/pom.xml From 8d9a4f1f55687a0d58dabb902fb8352039243db3 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 22 Jun 2023 11:56:11 +0000 Subject: [PATCH 069/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 29dbdb4df..5c5e81fc5 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.15-SNAPSHOT + 9.0.14 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index c1ce3a930..77b61e7f5 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.15-SNAPSHOT + 9.0.14 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index f00dc120e..6cd36c2cf 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.15-SNAPSHOT + 9.0.14 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 8ea9b1a8c..43b2c718c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.15-SNAPSHOT + 9.0.14 ../parent-root/pom.xml From c5b2bc4f6d3bccd510570d7400fe294ded52f56c Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 22 Jun 2023 11:56:11 +0000 Subject: [PATCH 070/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 5c5e81fc5..29dbdb4df 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.14 + 9.0.15-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 77b61e7f5..c1ce3a930 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.14 + 9.0.15-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 6cd36c2cf..f00dc120e 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.14 + 9.0.15-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 43b2c718c..8ea9b1a8c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.14 + 9.0.15-SNAPSHOT ../parent-root/pom.xml From 013934392bcabe27cf22e20adbfa616a8abb3259 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 26 Jun 2023 12:05:09 +0100 Subject: [PATCH 071/228] add error message if ExportFunction class does not extend ExportFunctionNode --- .../ValidateExportFunctionAnnotations.java | 16 +++++++- .../classcompiler/StringCompilation.java | 17 ++------ .../ValidatingAnnotationProcessorTest.java | 40 +++++++++++++++++++ 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java b/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java index c0565bc66..34527856d 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java @@ -1,6 +1,7 @@ package com.fluxtion.compiler.generation.annotationprocessor; import com.fluxtion.runtime.annotations.ExportFunction; +import com.fluxtion.runtime.callback.ExportFunctionNode; import com.google.auto.service.AutoService; import javax.annotation.processing.AbstractProcessor; @@ -30,10 +31,21 @@ public boolean process(Set annotations, RoundEnvironment ) .collect(Collectors.toSet()); + TypeElement exportNodeType = processingEnv.getElementUtils().getTypeElement(ExportFunctionNode.class.getCanonicalName()); + Set failingSubClass = annotatedElements.stream() + .map(Element::getEnclosingElement) + .filter(element -> { + return !processingEnv.getTypeUtils().isSubtype(element.asType(), exportNodeType.asType()); + }) + .collect(Collectors.toSet()); + typeElements.forEach(element -> processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, - "exported method should be public method and a boolean return type" - + element.getSimpleName(), element)); + "exported method should be public method and a boolean return type ", element)); + + failingSubClass.forEach(element -> + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, + "class with exported method must extend " + ExportFunctionNode.class.getCanonicalName(), element)); } return false; diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/classcompiler/StringCompilation.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/classcompiler/StringCompilation.java index 22cbbb1c7..05053424f 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/classcompiler/StringCompilation.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/classcompiler/StringCompilation.java @@ -1,19 +1,9 @@ package com.fluxtion.compiler.generation.compiler.classcompiler; import com.fluxtion.compiler.generation.RuntimeConstants; -import com.fluxtion.compiler.generation.annotationprocessor.ValidateEventHandlerAnnotations; -import com.fluxtion.compiler.generation.annotationprocessor.ValidateLifecycleAnnotations; -import com.fluxtion.compiler.generation.annotationprocessor.ValidateOnParentUpdateHandlerAnnotations; -import com.fluxtion.compiler.generation.annotationprocessor.ValidateOnTriggerAnnotations; +import com.fluxtion.compiler.generation.annotationprocessor.*; -import javax.tools.DiagnosticCollector; -import javax.tools.FileObject; -import javax.tools.ForwardingJavaFileManager; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.ToolProvider; +import javax.tools.*; import java.io.IOException; import java.net.URISyntaxException; import java.util.ArrayList; @@ -57,7 +47,8 @@ static Class compile(String className, String source, List option new ValidateEventHandlerAnnotations(), new ValidateLifecycleAnnotations(), new ValidateOnTriggerAnnotations(), - new ValidateOnParentUpdateHandlerAnnotations())); + new ValidateOnParentUpdateHandlerAnnotations(), + new ValidateExportFunctionAnnotations())); if (!task.call()) { diagnostics.getDiagnostics().forEach(System.out::println); throw new RuntimeException("unable to compile source file to class:'" + className + "'"); diff --git a/compiler/src/test/java/com/fluxtion/compiler/annotationprocessor/ValidatingAnnotationProcessorTest.java b/compiler/src/test/java/com/fluxtion/compiler/annotationprocessor/ValidatingAnnotationProcessorTest.java index 85612318a..999b9540a 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/annotationprocessor/ValidatingAnnotationProcessorTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/annotationprocessor/ValidatingAnnotationProcessorTest.java @@ -148,4 +148,44 @@ public void noFailCompileString_OverrideGuardBooleanReturn() { "}"; StringCompilation.compile("MyStringHandler", source); } + + + @SneakyThrows + @Test(expected = RuntimeException.class) + public void failCompileString_ExportFunction() { + String source = " " + + "import com.fluxtion.runtime.annotations.OnEventHandler;\n" + + "import com.fluxtion.runtime.annotations.ExportFunction;\n" + + "import com.fluxtion.runtime.callback.ExportFunctionNode;\n" + + "\n" + + "public class MyStringHandler {\n" + + " String in;\n" + + "\n" + + " @ExportFunction\n" + + " public boolean stringUpdated(String in) {\n" + + " this.in = in;\n" + + " return true;\n" + + " }\n" + + "}"; + StringCompilation.compile("MyStringHandler", source); + } + + @SneakyThrows + @Test(expected = RuntimeException.class) + public void failCompileString_ExportFunction_NoBooleanReturn() { + String source = " " + + "import com.fluxtion.runtime.annotations.OnEventHandler;\n" + + "import com.fluxtion.runtime.annotations.ExportFunction;\n" + + "import com.fluxtion.runtime.callback.ExportFunctionNode;\n" + + "\n" + + "public class MyStringHandler extends ExportFunctionNode{\n" + + " String in;\n" + + "\n" + + " @ExportFunction\n" + + " public void stringUpdated(String in) {\n" + + " this.in = in;\n" + + " }\n" + + "}"; + StringCompilation.compile("MyStringHandler", source); + } } From 781f5678572796ee047807056d65531b0c8a75e0 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 26 Jun 2023 11:09:46 +0000 Subject: [PATCH 072/228] updating poms for 9.0.16-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 29dbdb4df..17855a6c2 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.15-SNAPSHOT + 9.0.16-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index c1ce3a930..32153bad8 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.15-SNAPSHOT + 9.0.16-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index f00dc120e..b0212d7ea 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.15-SNAPSHOT + 9.0.16-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 8ea9b1a8c..08dbe2ff9 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.15-SNAPSHOT + 9.0.16-SNAPSHOT ../parent-root/pom.xml From c5d519a29a2b3cf941a298adea07fbe4cb805ceb Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 26 Jun 2023 11:09:57 +0000 Subject: [PATCH 073/228] updating poms for branch'release/9.0.15' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 29dbdb4df..1dc5d1da0 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.15-SNAPSHOT + 9.0.15 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index c1ce3a930..7d42e5f9f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.15-SNAPSHOT + 9.0.15 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index f00dc120e..826c1b86b 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.15-SNAPSHOT + 9.0.15 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 8ea9b1a8c..90d05933c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.15-SNAPSHOT + 9.0.15 ../parent-root/pom.xml From 50dd4aa782adfb528a45b9b2433b6bb6b6f8fc00 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 26 Jun 2023 11:14:27 +0000 Subject: [PATCH 074/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 17855a6c2..1dc5d1da0 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.16-SNAPSHOT + 9.0.15 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 32153bad8..7d42e5f9f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.16-SNAPSHOT + 9.0.15 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index b0212d7ea..826c1b86b 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.16-SNAPSHOT + 9.0.15 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 08dbe2ff9..90d05933c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.16-SNAPSHOT + 9.0.15 ../parent-root/pom.xml From 0c2e55291706bca986b04bf587fad40d4bb34878 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 26 Jun 2023 11:14:27 +0000 Subject: [PATCH 075/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 1dc5d1da0..17855a6c2 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.15 + 9.0.16-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 7d42e5f9f..32153bad8 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.15 + 9.0.16-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 826c1b86b..b0212d7ea 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.15 + 9.0.16-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 90d05933c..08dbe2ff9 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.15 + 9.0.16-SNAPSHOT ../parent-root/pom.xml From cff42ac1f9e6585b9f2fec95fc76683084c73e95 Mon Sep 17 00:00:00 2001 From: command-line Date: Thu, 13 Jul 2023 10:10:19 +0100 Subject: [PATCH 076/228] Support user supplied LogRecord encoder at runtime --- .../generation/audit/LifecycleAuditTest.java | 44 ++++++++++++++++--- .../runtime/StaticEventProcessor.java | 15 +++---- .../runtime/audit/EventLogControlEvent.java | 16 +++++++ .../runtime/audit/EventLogManager.java | 4 ++ .../com/fluxtion/runtime/audit/LogRecord.java | 4 ++ 5 files changed, 69 insertions(+), 14 deletions(-) diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java index f52801807..7e2ab9820 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java @@ -2,11 +2,7 @@ import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; -import com.fluxtion.runtime.annotations.Initialise; -import com.fluxtion.runtime.annotations.OnEventHandler; -import com.fluxtion.runtime.annotations.Start; -import com.fluxtion.runtime.annotations.Stop; -import com.fluxtion.runtime.annotations.TearDown; +import com.fluxtion.runtime.annotations.*; import com.fluxtion.runtime.audit.EventLogNode; import com.fluxtion.runtime.audit.LogRecord; import org.junit.Assert; @@ -39,6 +35,26 @@ public void lifecycleLog() { Assert.assertEquals(5, logSink.size()); } + @Test + public void replaceLogRecord() { + List logSink = new ArrayList<>(); + MyLogRecord myLogRecord = new MyLogRecord(); + addAuditor(); + sep(c -> c.addNode(new MyNode(new Parent()))); + sep.setAuditLogProcessor(logSink::add); + sep.setAuditLogRecordEncoder(myLogRecord); + start(); + Assert.assertEquals(2, myLogRecord.getTerminateCount()); + onEvent("test"); + Assert.assertEquals(3, myLogRecord.getTerminateCount()); + onEvent("test2"); + Assert.assertEquals(4, myLogRecord.getTerminateCount()); + stop(); + Assert.assertEquals(5, myLogRecord.getTerminateCount()); + tearDown(); + Assert.assertEquals(6, myLogRecord.getTerminateCount()); + } + public static class Parent extends EventLogNode { @Initialise public void init() { @@ -102,4 +118,22 @@ public boolean eventHandler(String in) { } } + + public static class MyLogRecord extends LogRecord { + public int terminateCount; + + public MyLogRecord() { + super(null); + } + + @Override + public boolean terminateRecord() { + terminateCount++; + return super.terminateRecord(); + } + + public int getTerminateCount() { + return terminateCount; + } + } } diff --git a/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java b/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java index 44b688101..cee073121 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java +++ b/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java @@ -17,11 +17,8 @@ import com.fluxtion.runtime.annotations.OnEventHandler; import com.fluxtion.runtime.annotations.builder.Inject; -import com.fluxtion.runtime.audit.Auditor; -import com.fluxtion.runtime.audit.EventLogControlEvent; +import com.fluxtion.runtime.audit.*; import com.fluxtion.runtime.audit.EventLogControlEvent.LogLevel; -import com.fluxtion.runtime.audit.EventLogManager; -import com.fluxtion.runtime.audit.LogRecordListener; import com.fluxtion.runtime.dataflow.FlowFunction; import com.fluxtion.runtime.event.Signal; import com.fluxtion.runtime.input.EventFeed; @@ -33,11 +30,7 @@ import com.fluxtion.runtime.time.ClockStrategy; import java.util.Map; -import java.util.function.BooleanSupplier; -import java.util.function.Consumer; -import java.util.function.DoubleConsumer; -import java.util.function.IntConsumer; -import java.util.function.LongConsumer; +import java.util.function.*; /** * Processes events of any type and dispatches to registered {@link EventHandlerNode} @@ -349,6 +342,10 @@ default void setAuditLogProcessor(LogRecordListener logProcessor) { onEvent(new EventLogControlEvent(logProcessor)); } + default void setAuditLogRecordEncoder(LogRecord logRecord) { + onEvent(new EventLogControlEvent(logRecord)); + } + /** * Attempts to get the last {@link com.fluxtion.runtime.audit.LogRecord} as a String if one is available. Useful * for error handling if there is a filure in the graph; diff --git a/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogControlEvent.java b/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogControlEvent.java index 5e55e0140..e2919ff58 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogControlEvent.java +++ b/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogControlEvent.java @@ -43,7 +43,14 @@ public class EventLogControlEvent implements Event { * default, is no filtering and configuration will be applied to all SEP's. */ private String groupId; + /** + * user configured {@link LogRecordListener} + */ private LogRecordListener logRecordProcessor; + /** + * User configured {@link LogRecord} + */ + private LogRecord logRecord; public EventLogControlEvent() { this(LogLevel.INFO); @@ -58,6 +65,11 @@ public EventLogControlEvent(LogRecordListener logRecordProcessor) { this.logRecordProcessor = logRecordProcessor; } + public EventLogControlEvent(LogRecord logRecord) { + this(null, null, null); + this.logRecord = logRecord; + } + public EventLogControlEvent(String sourceId, String groupId, LogLevel level) { this.sourceId = sourceId; this.groupId = groupId; @@ -87,6 +99,10 @@ public LogRecordListener getLogRecordProcessor() { return logRecordProcessor; } + public LogRecord getLogRecord() { + return logRecord; + } + public enum LogLevel { NONE(0), ERROR(1), WARN(2), INFO(3), DEBUG(4), TRACE(5); diff --git a/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java b/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java index 5b293b521..3b137a0f4 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java +++ b/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java @@ -135,6 +135,10 @@ public void calculationLogConfig(EventLogControlEvent newConfig) { if (newConfig.getLogRecordProcessor() != null) { this.sink = newConfig.getLogRecordProcessor(); } + if (newConfig.getLogRecord() != null) { + this.logRecord = newConfig.getLogRecord(); + this.logRecord.setClock(clock); + } final EventLogControlEvent.LogLevel level = newConfig.getLevel(); if (level != null && (logRecord.groupingId == null || logRecord.groupingId.equals(newConfig.getGroupId()))) { diff --git a/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java b/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java index 4e0a0e36e..1d528a252 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java +++ b/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java @@ -112,6 +112,10 @@ public void addTrace(String sourceId) { addSourceId(sourceId, null); } + public void setClock(Clock clock) { + this.clock = clock; + } + public void printEventToString(boolean printEventToString) { this.printEventToString = printEventToString; } From f4809dd1da0dd775340f29c50b673c9139f36c15 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 13 Jul 2023 09:17:35 +0000 Subject: [PATCH 077/228] updating poms for 9.0.17-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 17855a6c2..4d2184325 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.16-SNAPSHOT + 9.0.17-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 32153bad8..f22893034 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.16-SNAPSHOT + 9.0.17-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index b0212d7ea..4a7fd7db4 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.16-SNAPSHOT + 9.0.17-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 08dbe2ff9..57d6cf956 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.16-SNAPSHOT + 9.0.17-SNAPSHOT ../parent-root/pom.xml From 6f4c7502274a30e2fbd263b9faa780b803018c72 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 13 Jul 2023 09:17:41 +0000 Subject: [PATCH 078/228] updating poms for branch'release/9.0.16' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 17855a6c2..c7eddfdd2 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.16-SNAPSHOT + 9.0.16 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 32153bad8..6f4712349 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.16-SNAPSHOT + 9.0.16 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index b0212d7ea..500a69623 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.16-SNAPSHOT + 9.0.16 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 08dbe2ff9..83b5e0778 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.16-SNAPSHOT + 9.0.16 ../parent-root/pom.xml From d7ef92a03878014caf9dc5a5cce95852a9cf96d6 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 13 Jul 2023 09:21:15 +0000 Subject: [PATCH 079/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 4d2184325..c7eddfdd2 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.17-SNAPSHOT + 9.0.16 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index f22893034..6f4712349 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.17-SNAPSHOT + 9.0.16 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 4a7fd7db4..500a69623 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.17-SNAPSHOT + 9.0.16 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 57d6cf956..83b5e0778 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.17-SNAPSHOT + 9.0.16 ../parent-root/pom.xml From 5c551c1551174a4d465b87450c0aa32726a0c8a8 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 13 Jul 2023 09:21:15 +0000 Subject: [PATCH 080/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index c7eddfdd2..4d2184325 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.16 + 9.0.17-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 6f4712349..f22893034 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.16 + 9.0.17-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 500a69623..4a7fd7db4 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.16 + 9.0.17-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 83b5e0778..57d6cf956 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.16 + 9.0.17-SNAPSHOT ../parent-root/pom.xml From fe9672f7527890b69b7bb62ade205db09dbe9daf Mon Sep 17 00:00:00 2001 From: command-line Date: Thu, 13 Jul 2023 10:32:13 +0100 Subject: [PATCH 081/228] pass object type to LogRecord for logging. LogRecord handles null and converting to string --- .../main/java/com/fluxtion/runtime/audit/EventLogger.java | 2 +- .../src/main/java/com/fluxtion/runtime/audit/LogRecord.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogger.java b/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogger.java index ed99f2255..67f52e253 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogger.java +++ b/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogger.java @@ -255,7 +255,7 @@ public EventLogger logNodeInvocation(LogLevel logLevel) { public EventLogger log(String key, Object value, LogLevel logLevel) { if (this.logLevel.level >= logLevel.level) { - log(key, value == null ? "NULL" : value.toString(), logLevel); + logrecord.addRecord(logSourceId, key, value); } return this; } diff --git a/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java b/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java index 1d528a252..2007658d8 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java +++ b/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java @@ -98,6 +98,11 @@ public void addRecord(String sourceId, String propertyKey, CharSequence value) { sb.append(value); } + public void addRecord(String sourceId, String propertyKey, Object value) { + addSourceId(sourceId, propertyKey); + sb.append(value == null ? "NULL" : value); + } + public void addRecord(String sourceId, String propertyKey, boolean value) { addSourceId(sourceId, propertyKey); sb.append(value); From 12d5c6172697eef093a429fc1c03f46d118719a2 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 13 Jul 2023 09:36:49 +0000 Subject: [PATCH 082/228] updating poms for 9.0.18-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 4d2184325..2bfd77660 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.17-SNAPSHOT + 9.0.18-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index f22893034..b5e3d35d9 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.17-SNAPSHOT + 9.0.18-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 4a7fd7db4..64c1fbb15 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.17-SNAPSHOT + 9.0.18-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 57d6cf956..08955ca9b 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.17-SNAPSHOT + 9.0.18-SNAPSHOT ../parent-root/pom.xml From a6fd527e82cf7ff5d6b7e0083eee701a76a2fa35 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 13 Jul 2023 09:36:56 +0000 Subject: [PATCH 083/228] updating poms for branch'release/9.0.17' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 4d2184325..5e700308a 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.17-SNAPSHOT + 9.0.17 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index f22893034..a59df7740 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.17-SNAPSHOT + 9.0.17 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 4a7fd7db4..70a632eb8 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.17-SNAPSHOT + 9.0.17 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 57d6cf956..5dacb220e 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.17-SNAPSHOT + 9.0.17 ../parent-root/pom.xml From 733674a45c6f5d3b79d2165b41517ffbc621b2d2 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 13 Jul 2023 09:40:26 +0000 Subject: [PATCH 084/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 2bfd77660..5e700308a 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.18-SNAPSHOT + 9.0.17 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index b5e3d35d9..a59df7740 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.18-SNAPSHOT + 9.0.17 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 64c1fbb15..70a632eb8 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.18-SNAPSHOT + 9.0.17 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 08955ca9b..5dacb220e 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.18-SNAPSHOT + 9.0.17 ../parent-root/pom.xml From 8ef115b1e51120004d4b770d2d4744c2f835d063 Mon Sep 17 00:00:00 2001 From: runner Date: Thu, 13 Jul 2023 09:40:26 +0000 Subject: [PATCH 085/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 5e700308a..2bfd77660 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.17 + 9.0.18-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index a59df7740..b5e3d35d9 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.17 + 9.0.18-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 70a632eb8..64c1fbb15 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.17 + 9.0.18-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 5dacb220e..08955ca9b 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.17 + 9.0.18-SNAPSHOT ../parent-root/pom.xml From 50e43d2a1c02ee59ab9e577d6b5c48525dfe5a5e Mon Sep 17 00:00:00 2001 From: command-line Date: Fri, 14 Jul 2023 09:51:00 +0100 Subject: [PATCH 086/228] support class serialisation. CallBackNode uses event class type in constructor --- .../compiler/EventProcessorConfig.java | 37 +- .../generation/serialiser/MetaSerializer.java | 12 + .../generation/callback/CallbackNodeTest.java | 1 + .../IoSerializerTest.java | 36 +- .../MetaSerializerTest.java | 76 ++ .../exportfunction/ExportFunctionTest.java | 17 +- .../util/MultipleSepTargetInProcessTest.java | 2 + .../runtime/callback/CallBackNode.java | 31 +- .../callback/ExportFunctionTriggerEvent.java | 791 +++++++++++++++--- .../callback/InstanceCallbackEvent.java | 777 ++++++++++++++--- .../runtime/callback/NamedNodeSimple.java | 33 + 11 files changed, 1494 insertions(+), 319 deletions(-) create mode 100644 compiler/src/main/java/com/fluxtion/compiler/generation/serialiser/MetaSerializer.java create mode 100644 compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/MetaSerializerTest.java create mode 100644 runtime/src/main/java/com/fluxtion/runtime/callback/NamedNodeSimple.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java b/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java index 1b23244cf..1bd35004c 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java +++ b/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java @@ -16,25 +16,14 @@ */ package com.fluxtion.compiler; -import com.fluxtion.compiler.builder.callback.CallBackDispatcherFactory; -import com.fluxtion.compiler.builder.callback.CallbackNodeFactory; -import com.fluxtion.compiler.builder.callback.DirtyStateMonitorFactory; -import com.fluxtion.compiler.builder.callback.EventDispatcherFactory; -import com.fluxtion.compiler.builder.callback.EventProcessorCallbackInternalFactory; +import com.fluxtion.compiler.builder.callback.*; import com.fluxtion.compiler.builder.context.EventProcessorContextFactory; import com.fluxtion.compiler.builder.context.InstanceSupplierFactory; -import com.fluxtion.compiler.builder.factory.NodeFactory; -import com.fluxtion.compiler.builder.factory.NodeFactoryRegistration; -import com.fluxtion.compiler.builder.factory.NodeNameLookupFactory; -import com.fluxtion.compiler.builder.factory.NodeNameProducer; -import com.fluxtion.compiler.builder.factory.SingletonNodeFactory; +import com.fluxtion.compiler.builder.factory.*; import com.fluxtion.compiler.builder.filter.EventHandlerFilterOverride; import com.fluxtion.compiler.builder.input.SubscriptionManagerFactory; import com.fluxtion.compiler.builder.time.ClockFactory; -import com.fluxtion.compiler.generation.serialiser.FieldContext; -import com.fluxtion.compiler.generation.serialiser.FormatSerializer; -import com.fluxtion.compiler.generation.serialiser.IoSerializer; -import com.fluxtion.compiler.generation.serialiser.TimeSerializer; +import com.fluxtion.compiler.generation.serialiser.*; import com.fluxtion.runtime.audit.Auditor; import com.fluxtion.runtime.audit.EventLogControlEvent.LogLevel; import com.fluxtion.runtime.audit.EventLogManager; @@ -49,23 +38,8 @@ import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; -import java.time.Duration; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.Period; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import java.time.*; +import java.util.*; import java.util.function.Function; /** @@ -114,6 +88,7 @@ public EventProcessorConfig() { classSerializerMap.put(DateFormat.class, FormatSerializer::simpleDataFormatToSource); classSerializerMap.put(DecimalFormat.class, FormatSerializer::decimalFormatToSource); classSerializerMap.put(NumberFormat.class, FormatSerializer::decimalFormatToSource); + classSerializerMap.put(Class.class, MetaSerializer::classToSource); } /** diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/serialiser/MetaSerializer.java b/compiler/src/main/java/com/fluxtion/compiler/generation/serialiser/MetaSerializer.java new file mode 100644 index 000000000..bcf536bdf --- /dev/null +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/serialiser/MetaSerializer.java @@ -0,0 +1,12 @@ +package com.fluxtion.compiler.generation.serialiser; + +import java.io.File; + +public interface MetaSerializer { + + static String classToSource(FieldContext> fieldContext) { + fieldContext.getImportList().add(File.class); + Class clazz = fieldContext.getInstanceToMap(); + return clazz.getCanonicalName() + ".class"; + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java index 3fe95142b..072350cca 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/callback/CallbackNodeTest.java @@ -16,6 +16,7 @@ public CallbackNodeTest(SepTestConfig testConfig) { @Test public void directInvokeTest() { + //writeOutputsToFile(true); sep(c -> { c.addNode(new Child(new ExternalCallback("callback1")), "child1"); c.addNode(new Child(new ExternalCallback("callback2")), "child2"); diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/IoSerializerTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/IoSerializerTest.java index 581a2dd98..5fa8537c0 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/IoSerializerTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/IoSerializerTest.java @@ -2,19 +2,11 @@ import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.Value; +import lombok.*; import org.junit.Test; import java.io.File; -import java.net.InetSocketAddress; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; +import java.net.*; public class IoSerializerTest extends MultipleSepTargetInProcessTest { public IoSerializerTest(SepTestConfig testConfig) { @@ -23,6 +15,7 @@ public IoSerializerTest(SepTestConfig testConfig) { @Test public void testIoSerializersConstructor() { +// writeSourceFile = true; sep(c -> { try { c.addNode(IoHolder.builder() @@ -56,6 +49,20 @@ public void testIoSerializersProperty() { }); } + @Test + public void serializeFieldTest() { + sep(c -> { + try { + IoHolderFieldProperty ioHolderFieldProperty = new IoHolderFieldProperty(); + ioHolderFieldProperty.setFile(new File("c:\\my_made_up\\path")); + ioHolderFieldProperty.setUrl(new URL("http://www.example.com/docs/resource1.html")); + c.addNode(ioHolderFieldProperty); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + }); + } + @Builder @AllArgsConstructor @@ -79,4 +86,13 @@ public static class IoHolderProperty { } + @Data + public static class IoHolderFieldProperty { + File file; + URL url; + URI uri; + InetSocketAddress inetSocketAddress; + } + + } diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/MetaSerializerTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/MetaSerializerTest.java new file mode 100644 index 000000000..108a3d98f --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/MetaSerializerTest.java @@ -0,0 +1,76 @@ +package com.fluxtion.compiler.generation.customfieldserializer; + +import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest; +import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; +import com.fluxtion.runtime.callback.InstanceCallbackEvent; +import com.fluxtion.runtime.node.SingleNamedNode; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.Value; +import org.junit.Test; + +public class MetaSerializerTest extends MultipleSepTargetInProcessTest { + public MetaSerializerTest(CompiledAndInterpretedSepTest.SepTestConfig testConfig) { + super(testConfig); + } + + @Test + public void serializeFieldTest() { + writeSourceFile = true; + sep(new ClassFieldHolder(String.class)); + } + + @Test + public void serializeConstructorTest() { + writeSourceFile = true; + sep(new ClassFieldHolder(String.class)); + } + + @Test + public void serializeInnerClassConstructorTest() { + writeSourceFile = true; + sep(new ClassFieldHolder(MyInnerClass.class)); + } + + @Test + public void serializeField_WithSingleNamedNodeTest() { + writeSourceFile = true; + InstanceCallbackEvent.reset(); + sep(new CbSample("test")); + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + public static class ClassFieldHolder { + private Class myClass; + } + + @Value + public static class ClassConstructorHolder { + private Class myClass; + } + + public static class MyInnerClass { + } + + public static class CbSample extends SingleNamedNode { + + private Class cbClass; + + public CbSample(String name) { + super(name); + cbClass = InstanceCallbackEvent.cbClassList.remove(0); + } + + + public Class getCbClass() { + return cbClass; + } + + public void setCbClass(Class cbClass) { + this.cbClass = cbClass; + } + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java index 22e32d6a9..59ff980f4 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java @@ -7,6 +7,7 @@ import com.fluxtion.runtime.annotations.OnTrigger; import com.fluxtion.runtime.annotations.builder.AssignToField; import com.fluxtion.runtime.callback.ExportFunctionNode; +import com.fluxtion.runtime.callback.ExportFunctionTrigger; import org.junit.Assert; import org.junit.Test; @@ -19,9 +20,23 @@ public ExportFunctionTest(SepTestConfig compile) { super(compile); } + + @Test + public void addTriggerNode() { + sep(c -> { + c.addNode(new ExportFunctionTrigger()); + }); + } + + @Test + public void addExportingNodeX() { + sep(c -> { + c.addNode(new ExportingNode("iodauhf")); + }); + } + @Test public void exportTest() { -// writeSourceFile = true; sep(c -> { c.addNode(new Aggregator( new ExportingNode("export1"), diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/util/MultipleSepTargetInProcessTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/util/MultipleSepTargetInProcessTest.java index feafec235..150db0f65 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/util/MultipleSepTargetInProcessTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/util/MultipleSepTargetInProcessTest.java @@ -29,6 +29,7 @@ import com.fluxtion.runtime.StaticEventProcessor; import com.fluxtion.runtime.audit.EventLogControlEvent; import com.fluxtion.runtime.audit.JULLogRecordListener; +import com.fluxtion.runtime.callback.InstanceCallbackEvent; import com.fluxtion.runtime.dataflow.FlowFunction; import com.fluxtion.runtime.lifecycle.BatchHandler; import com.fluxtion.runtime.lifecycle.Lifecycle; @@ -103,6 +104,7 @@ public void beforeTest() { addAuditor = false; reuseSep = false; callInit = true; + InstanceCallbackEvent.reset(); } @After diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java b/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java index 4a39577c0..f7d6eee6b 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/CallBackNode.java @@ -1,28 +1,34 @@ package com.fluxtion.runtime.callback; -import com.fluxtion.runtime.annotations.Initialise; +import com.fluxtion.runtime.EventProcessorBuilderService; import com.fluxtion.runtime.annotations.builder.Inject; import com.fluxtion.runtime.node.EventHandlerNode; import com.fluxtion.runtime.node.SingleNamedNode; +import lombok.Getter; +import lombok.Setter; import lombok.SneakyThrows; /** * Extend this node to expose instance callback outside the {@link com.fluxtion.runtime.EventProcessor}. * Use the protected methods */ +@Getter +@Setter public abstract class CallBackNode extends SingleNamedNode implements EventHandlerNode { - private transient Class cbClass; - private transient Object event; - public String eventClassName; + private Object event; @Inject - public EventDispatcher dispatcher; + private EventDispatcher dispatcher; @Inject - public DirtyStateMonitor dirtyStateMonitor; + private DirtyStateMonitor dirtyStateMonitor; @SneakyThrows public CallBackNode(String name) { super(name); + if (EventProcessorBuilderService.service().buildTime()) { + Class cbClass = InstanceCallbackEvent.cbClassList.remove(0); + event = cbClass.getDeclaredConstructor().newInstance(); + } } @Override @@ -30,20 +36,11 @@ public boolean onEvent(Object e) { return true; } + @Override @SneakyThrows public final Class eventClass() { - if (cbClass == null) { - cbClass = InstanceCallbackEvent.cbClassList.remove(0); - eventClassName = cbClass.getName(); - } - return cbClass; - } - - @Initialise - @SneakyThrows - public void init() { - event = Class.forName(eventClassName).getDeclaredConstructor().newInstance(); + return event.getClass(); } /** diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTriggerEvent.java b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTriggerEvent.java index 8dcc7c75e..65f716268 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTriggerEvent.java +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionTriggerEvent.java @@ -1,5 +1,7 @@ package com.fluxtion.runtime.callback; +import com.fluxtion.runtime.annotations.builder.SepNode; + import java.util.ArrayList; import java.util.List; @@ -8,17 +10,30 @@ public interface ExportFunctionTriggerEvent { List> exportFunctionCbList = new ArrayList<>(); static void main(String[] args) { - for (int i = 0; i < 128; i++) { - System.out.printf("class ExportFunctionTriggerEvent_%d {}%n", i); - } System.out.print("static void reset(){\n"); for (int i = 0; i < 128; i++) { System.out.printf("\tcbClassList.add(ExportFunctionTriggerEvent_%d.class);%n", i); } System.out.println("}\n"); + + for (int i = 0; i < 11; i++) { + System.out.printf("@SepNode%n" + + "class ExportFunctionTriggerEvent_%1$d extends NamedNodeSimple {%n" + + " public ExportFunctionTriggerEvent_%1$d(){%n" + + " super(\"exportFunctionTriggerEvent_%1$d\");%n" + + " }%n" + + "}%n%n", i); + } +// +// for (int i = 0; i < 128; i++) { +// System.out.printf("@SepNode%n" + +// "class ExportFunctionTriggerEvent_%1$d {%n" + +// "}%n%n", i); +// } } static void reset() { + exportFunctionCbList.clear(); exportFunctionCbList.add(ExportFunctionTriggerEvent_0.class); exportFunctionCbList.add(ExportFunctionTriggerEvent_1.class); exportFunctionCbList.add(ExportFunctionTriggerEvent_2.class); @@ -149,387 +164,901 @@ static void reset() { exportFunctionCbList.add(ExportFunctionTriggerEvent_127.class); } - class ExportFunctionTriggerEvent_0 { + + @SepNode + class ExportFunctionTriggerEvent_0 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_0() { + super("exportFunctionTriggerEvent_0"); + } } - class ExportFunctionTriggerEvent_1 { + @SepNode + class ExportFunctionTriggerEvent_1 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_1() { + super("exportFunctionTriggerEvent_1"); + } } - class ExportFunctionTriggerEvent_2 { + @SepNode + class ExportFunctionTriggerEvent_2 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_2() { + super("exportFunctionTriggerEvent_2"); + } } - class ExportFunctionTriggerEvent_3 { + @SepNode + class ExportFunctionTriggerEvent_3 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_3() { + super("exportFunctionTriggerEvent_3"); + } } - class ExportFunctionTriggerEvent_4 { + @SepNode + class ExportFunctionTriggerEvent_4 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_4() { + super("exportFunctionTriggerEvent_4"); + } } - class ExportFunctionTriggerEvent_5 { + @SepNode + class ExportFunctionTriggerEvent_5 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_5() { + super("exportFunctionTriggerEvent_5"); + } } - class ExportFunctionTriggerEvent_6 { + @SepNode + class ExportFunctionTriggerEvent_6 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_6() { + super("exportFunctionTriggerEvent_6"); + } } - class ExportFunctionTriggerEvent_7 { + @SepNode + class ExportFunctionTriggerEvent_7 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_7() { + super("exportFunctionTriggerEvent_7"); + } } - class ExportFunctionTriggerEvent_8 { + @SepNode + class ExportFunctionTriggerEvent_8 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_8() { + super("exportFunctionTriggerEvent_8"); + } } - class ExportFunctionTriggerEvent_9 { + @SepNode + class ExportFunctionTriggerEvent_9 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_9() { + super("exportFunctionTriggerEvent_9"); + } } - class ExportFunctionTriggerEvent_10 { + @SepNode + class ExportFunctionTriggerEvent_10 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_10() { + super("exportFunctionTriggerEvent_10"); + } } - class ExportFunctionTriggerEvent_11 { + @SepNode + class ExportFunctionTriggerEvent_11 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_11() { + super("exportFunctionTriggerEvent_11"); + } } - class ExportFunctionTriggerEvent_12 { + @SepNode + class ExportFunctionTriggerEvent_12 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_12() { + super("exportFunctionTriggerEvent_12"); + } } - class ExportFunctionTriggerEvent_13 { + @SepNode + class ExportFunctionTriggerEvent_13 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_13() { + super("exportFunctionTriggerEvent_13"); + } } - class ExportFunctionTriggerEvent_14 { + @SepNode + class ExportFunctionTriggerEvent_14 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_14() { + super("exportFunctionTriggerEvent_14"); + } } - class ExportFunctionTriggerEvent_15 { + @SepNode + class ExportFunctionTriggerEvent_15 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_15() { + super("exportFunctionTriggerEvent_15"); + } } - class ExportFunctionTriggerEvent_16 { + @SepNode + class ExportFunctionTriggerEvent_16 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_16() { + super("exportFunctionTriggerEvent_16"); + } } - class ExportFunctionTriggerEvent_17 { + @SepNode + class ExportFunctionTriggerEvent_17 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_17() { + super("exportFunctionTriggerEvent_17"); + } } - class ExportFunctionTriggerEvent_18 { + @SepNode + class ExportFunctionTriggerEvent_18 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_18() { + super("exportFunctionTriggerEvent_18"); + } } - class ExportFunctionTriggerEvent_19 { + @SepNode + class ExportFunctionTriggerEvent_19 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_19() { + super("exportFunctionTriggerEvent_19"); + } } - class ExportFunctionTriggerEvent_20 { + @SepNode + class ExportFunctionTriggerEvent_20 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_20() { + super("exportFunctionTriggerEvent_20"); + } } - class ExportFunctionTriggerEvent_21 { + @SepNode + class ExportFunctionTriggerEvent_21 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_21() { + super("exportFunctionTriggerEvent_21"); + } } - class ExportFunctionTriggerEvent_22 { + @SepNode + class ExportFunctionTriggerEvent_22 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_22() { + super("exportFunctionTriggerEvent_22"); + } } - class ExportFunctionTriggerEvent_23 { + @SepNode + class ExportFunctionTriggerEvent_23 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_23() { + super("exportFunctionTriggerEvent_23"); + } } - class ExportFunctionTriggerEvent_24 { + @SepNode + class ExportFunctionTriggerEvent_24 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_24() { + super("exportFunctionTriggerEvent_24"); + } } - class ExportFunctionTriggerEvent_25 { + @SepNode + class ExportFunctionTriggerEvent_25 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_25() { + super("exportFunctionTriggerEvent_25"); + } } - class ExportFunctionTriggerEvent_26 { + @SepNode + class ExportFunctionTriggerEvent_26 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_26() { + super("exportFunctionTriggerEvent_26"); + } } - class ExportFunctionTriggerEvent_27 { + @SepNode + class ExportFunctionTriggerEvent_27 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_27() { + super("exportFunctionTriggerEvent_27"); + } } - class ExportFunctionTriggerEvent_28 { + @SepNode + class ExportFunctionTriggerEvent_28 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_28() { + super("exportFunctionTriggerEvent_28"); + } } - class ExportFunctionTriggerEvent_29 { + @SepNode + class ExportFunctionTriggerEvent_29 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_29() { + super("exportFunctionTriggerEvent_29"); + } } - class ExportFunctionTriggerEvent_30 { + @SepNode + class ExportFunctionTriggerEvent_30 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_30() { + super("exportFunctionTriggerEvent_30"); + } } - class ExportFunctionTriggerEvent_31 { + @SepNode + class ExportFunctionTriggerEvent_31 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_31() { + super("exportFunctionTriggerEvent_31"); + } } - class ExportFunctionTriggerEvent_32 { + @SepNode + class ExportFunctionTriggerEvent_32 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_32() { + super("exportFunctionTriggerEvent_32"); + } } - class ExportFunctionTriggerEvent_33 { + @SepNode + class ExportFunctionTriggerEvent_33 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_33() { + super("exportFunctionTriggerEvent_33"); + } } - class ExportFunctionTriggerEvent_34 { + @SepNode + class ExportFunctionTriggerEvent_34 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_34() { + super("exportFunctionTriggerEvent_34"); + } } - class ExportFunctionTriggerEvent_35 { + @SepNode + class ExportFunctionTriggerEvent_35 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_35() { + super("exportFunctionTriggerEvent_35"); + } } - class ExportFunctionTriggerEvent_36 { + @SepNode + class ExportFunctionTriggerEvent_36 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_36() { + super("exportFunctionTriggerEvent_36"); + } } - class ExportFunctionTriggerEvent_37 { + @SepNode + class ExportFunctionTriggerEvent_37 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_37() { + super("exportFunctionTriggerEvent_37"); + } } - class ExportFunctionTriggerEvent_38 { + @SepNode + class ExportFunctionTriggerEvent_38 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_38() { + super("exportFunctionTriggerEvent_38"); + } } - class ExportFunctionTriggerEvent_39 { + @SepNode + class ExportFunctionTriggerEvent_39 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_39() { + super("exportFunctionTriggerEvent_39"); + } } - class ExportFunctionTriggerEvent_40 { + @SepNode + class ExportFunctionTriggerEvent_40 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_40() { + super("exportFunctionTriggerEvent_40"); + } } - class ExportFunctionTriggerEvent_41 { + @SepNode + class ExportFunctionTriggerEvent_41 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_41() { + super("exportFunctionTriggerEvent_41"); + } } - class ExportFunctionTriggerEvent_42 { + @SepNode + class ExportFunctionTriggerEvent_42 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_42() { + super("exportFunctionTriggerEvent_42"); + } } - class ExportFunctionTriggerEvent_43 { + @SepNode + class ExportFunctionTriggerEvent_43 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_43() { + super("exportFunctionTriggerEvent_43"); + } } - class ExportFunctionTriggerEvent_44 { + @SepNode + class ExportFunctionTriggerEvent_44 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_44() { + super("exportFunctionTriggerEvent_44"); + } } - class ExportFunctionTriggerEvent_45 { + @SepNode + class ExportFunctionTriggerEvent_45 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_45() { + super("exportFunctionTriggerEvent_45"); + } } - class ExportFunctionTriggerEvent_46 { + @SepNode + class ExportFunctionTriggerEvent_46 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_46() { + super("exportFunctionTriggerEvent_46"); + } } - class ExportFunctionTriggerEvent_47 { + @SepNode + class ExportFunctionTriggerEvent_47 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_47() { + super("exportFunctionTriggerEvent_47"); + } } - class ExportFunctionTriggerEvent_48 { + @SepNode + class ExportFunctionTriggerEvent_48 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_48() { + super("exportFunctionTriggerEvent_48"); + } } - class ExportFunctionTriggerEvent_49 { + @SepNode + class ExportFunctionTriggerEvent_49 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_49() { + super("exportFunctionTriggerEvent_49"); + } } - class ExportFunctionTriggerEvent_50 { + @SepNode + class ExportFunctionTriggerEvent_50 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_50() { + super("exportFunctionTriggerEvent_50"); + } } - class ExportFunctionTriggerEvent_51 { + @SepNode + class ExportFunctionTriggerEvent_51 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_51() { + super("exportFunctionTriggerEvent_51"); + } } - class ExportFunctionTriggerEvent_52 { + @SepNode + class ExportFunctionTriggerEvent_52 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_52() { + super("exportFunctionTriggerEvent_52"); + } } - class ExportFunctionTriggerEvent_53 { + @SepNode + class ExportFunctionTriggerEvent_53 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_53() { + super("exportFunctionTriggerEvent_53"); + } } - class ExportFunctionTriggerEvent_54 { + @SepNode + class ExportFunctionTriggerEvent_54 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_54() { + super("exportFunctionTriggerEvent_54"); + } } - class ExportFunctionTriggerEvent_55 { + @SepNode + class ExportFunctionTriggerEvent_55 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_55() { + super("exportFunctionTriggerEvent_55"); + } } - class ExportFunctionTriggerEvent_56 { + @SepNode + class ExportFunctionTriggerEvent_56 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_56() { + super("exportFunctionTriggerEvent_56"); + } } - class ExportFunctionTriggerEvent_57 { + @SepNode + class ExportFunctionTriggerEvent_57 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_57() { + super("exportFunctionTriggerEvent_57"); + } } - class ExportFunctionTriggerEvent_58 { + @SepNode + class ExportFunctionTriggerEvent_58 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_58() { + super("exportFunctionTriggerEvent_58"); + } } - class ExportFunctionTriggerEvent_59 { + @SepNode + class ExportFunctionTriggerEvent_59 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_59() { + super("exportFunctionTriggerEvent_59"); + } } - class ExportFunctionTriggerEvent_60 { + @SepNode + class ExportFunctionTriggerEvent_60 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_60() { + super("exportFunctionTriggerEvent_60"); + } } - class ExportFunctionTriggerEvent_61 { + @SepNode + class ExportFunctionTriggerEvent_61 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_61() { + super("exportFunctionTriggerEvent_61"); + } } - class ExportFunctionTriggerEvent_62 { + @SepNode + class ExportFunctionTriggerEvent_62 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_62() { + super("exportFunctionTriggerEvent_62"); + } } - class ExportFunctionTriggerEvent_63 { + @SepNode + class ExportFunctionTriggerEvent_63 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_63() { + super("exportFunctionTriggerEvent_63"); + } } - class ExportFunctionTriggerEvent_64 { + @SepNode + class ExportFunctionTriggerEvent_64 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_64() { + super("exportFunctionTriggerEvent_64"); + } } - class ExportFunctionTriggerEvent_65 { + @SepNode + class ExportFunctionTriggerEvent_65 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_65() { + super("exportFunctionTriggerEvent_65"); + } } - class ExportFunctionTriggerEvent_66 { + @SepNode + class ExportFunctionTriggerEvent_66 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_66() { + super("exportFunctionTriggerEvent_66"); + } } - class ExportFunctionTriggerEvent_67 { + @SepNode + class ExportFunctionTriggerEvent_67 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_67() { + super("exportFunctionTriggerEvent_67"); + } } - class ExportFunctionTriggerEvent_68 { + @SepNode + class ExportFunctionTriggerEvent_68 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_68() { + super("exportFunctionTriggerEvent_68"); + } } - class ExportFunctionTriggerEvent_69 { + @SepNode + class ExportFunctionTriggerEvent_69 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_69() { + super("exportFunctionTriggerEvent_69"); + } } - class ExportFunctionTriggerEvent_70 { + @SepNode + class ExportFunctionTriggerEvent_70 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_70() { + super("exportFunctionTriggerEvent_70"); + } } - class ExportFunctionTriggerEvent_71 { + @SepNode + class ExportFunctionTriggerEvent_71 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_71() { + super("exportFunctionTriggerEvent_71"); + } } - class ExportFunctionTriggerEvent_72 { + @SepNode + class ExportFunctionTriggerEvent_72 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_72() { + super("exportFunctionTriggerEvent_72"); + } } - class ExportFunctionTriggerEvent_73 { + @SepNode + class ExportFunctionTriggerEvent_73 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_73() { + super("exportFunctionTriggerEvent_73"); + } } - class ExportFunctionTriggerEvent_74 { + @SepNode + class ExportFunctionTriggerEvent_74 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_74() { + super("exportFunctionTriggerEvent_74"); + } } - class ExportFunctionTriggerEvent_75 { + @SepNode + class ExportFunctionTriggerEvent_75 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_75() { + super("exportFunctionTriggerEvent_75"); + } } - class ExportFunctionTriggerEvent_76 { + @SepNode + class ExportFunctionTriggerEvent_76 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_76() { + super("exportFunctionTriggerEvent_76"); + } } - class ExportFunctionTriggerEvent_77 { + @SepNode + class ExportFunctionTriggerEvent_77 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_77() { + super("exportFunctionTriggerEvent_77"); + } } - class ExportFunctionTriggerEvent_78 { + @SepNode + class ExportFunctionTriggerEvent_78 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_78() { + super("exportFunctionTriggerEvent_78"); + } } - class ExportFunctionTriggerEvent_79 { + @SepNode + class ExportFunctionTriggerEvent_79 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_79() { + super("exportFunctionTriggerEvent_79"); + } } - class ExportFunctionTriggerEvent_80 { + @SepNode + class ExportFunctionTriggerEvent_80 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_80() { + super("exportFunctionTriggerEvent_80"); + } } - class ExportFunctionTriggerEvent_81 { + @SepNode + class ExportFunctionTriggerEvent_81 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_81() { + super("exportFunctionTriggerEvent_81"); + } } - class ExportFunctionTriggerEvent_82 { + @SepNode + class ExportFunctionTriggerEvent_82 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_82() { + super("exportFunctionTriggerEvent_82"); + } } - class ExportFunctionTriggerEvent_83 { + @SepNode + class ExportFunctionTriggerEvent_83 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_83() { + super("exportFunctionTriggerEvent_83"); + } } - class ExportFunctionTriggerEvent_84 { + @SepNode + class ExportFunctionTriggerEvent_84 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_84() { + super("exportFunctionTriggerEvent_84"); + } } - class ExportFunctionTriggerEvent_85 { + @SepNode + class ExportFunctionTriggerEvent_85 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_85() { + super("exportFunctionTriggerEvent_85"); + } } - class ExportFunctionTriggerEvent_86 { + @SepNode + class ExportFunctionTriggerEvent_86 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_86() { + super("exportFunctionTriggerEvent_86"); + } } - class ExportFunctionTriggerEvent_87 { + @SepNode + class ExportFunctionTriggerEvent_87 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_87() { + super("exportFunctionTriggerEvent_87"); + } } - class ExportFunctionTriggerEvent_88 { + @SepNode + class ExportFunctionTriggerEvent_88 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_88() { + super("exportFunctionTriggerEvent_88"); + } } - class ExportFunctionTriggerEvent_89 { + @SepNode + class ExportFunctionTriggerEvent_89 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_89() { + super("exportFunctionTriggerEvent_89"); + } } - class ExportFunctionTriggerEvent_90 { + @SepNode + class ExportFunctionTriggerEvent_90 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_90() { + super("exportFunctionTriggerEvent_90"); + } } - class ExportFunctionTriggerEvent_91 { + @SepNode + class ExportFunctionTriggerEvent_91 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_91() { + super("exportFunctionTriggerEvent_91"); + } } - class ExportFunctionTriggerEvent_92 { + @SepNode + class ExportFunctionTriggerEvent_92 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_92() { + super("exportFunctionTriggerEvent_92"); + } } - class ExportFunctionTriggerEvent_93 { + @SepNode + class ExportFunctionTriggerEvent_93 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_93() { + super("exportFunctionTriggerEvent_93"); + } } - class ExportFunctionTriggerEvent_94 { + @SepNode + class ExportFunctionTriggerEvent_94 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_94() { + super("exportFunctionTriggerEvent_94"); + } } - class ExportFunctionTriggerEvent_95 { + @SepNode + class ExportFunctionTriggerEvent_95 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_95() { + super("exportFunctionTriggerEvent_95"); + } } - class ExportFunctionTriggerEvent_96 { + @SepNode + class ExportFunctionTriggerEvent_96 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_96() { + super("exportFunctionTriggerEvent_96"); + } } - class ExportFunctionTriggerEvent_97 { + @SepNode + class ExportFunctionTriggerEvent_97 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_97() { + super("exportFunctionTriggerEvent_97"); + } } - class ExportFunctionTriggerEvent_98 { + @SepNode + class ExportFunctionTriggerEvent_98 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_98() { + super("exportFunctionTriggerEvent_98"); + } } - class ExportFunctionTriggerEvent_99 { + @SepNode + class ExportFunctionTriggerEvent_99 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_99() { + super("exportFunctionTriggerEvent_99"); + } } - class ExportFunctionTriggerEvent_100 { + @SepNode + class ExportFunctionTriggerEvent_100 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_100() { + super("exportFunctionTriggerEvent_100"); + } } - class ExportFunctionTriggerEvent_101 { + @SepNode + class ExportFunctionTriggerEvent_101 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_101() { + super("exportFunctionTriggerEvent_101"); + } } - class ExportFunctionTriggerEvent_102 { + @SepNode + class ExportFunctionTriggerEvent_102 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_102() { + super("exportFunctionTriggerEvent_102"); + } } - class ExportFunctionTriggerEvent_103 { + @SepNode + class ExportFunctionTriggerEvent_103 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_103() { + super("exportFunctionTriggerEvent_103"); + } } - class ExportFunctionTriggerEvent_104 { + @SepNode + class ExportFunctionTriggerEvent_104 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_104() { + super("exportFunctionTriggerEvent_104"); + } } - class ExportFunctionTriggerEvent_105 { + @SepNode + class ExportFunctionTriggerEvent_105 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_105() { + super("exportFunctionTriggerEvent_105"); + } } - class ExportFunctionTriggerEvent_106 { + @SepNode + class ExportFunctionTriggerEvent_106 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_106() { + super("exportFunctionTriggerEvent_106"); + } } - class ExportFunctionTriggerEvent_107 { + @SepNode + class ExportFunctionTriggerEvent_107 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_107() { + super("exportFunctionTriggerEvent_107"); + } } - class ExportFunctionTriggerEvent_108 { + @SepNode + class ExportFunctionTriggerEvent_108 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_108() { + super("exportFunctionTriggerEvent_108"); + } } - class ExportFunctionTriggerEvent_109 { + @SepNode + class ExportFunctionTriggerEvent_109 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_109() { + super("exportFunctionTriggerEvent_109"); + } } - class ExportFunctionTriggerEvent_110 { + @SepNode + class ExportFunctionTriggerEvent_110 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_110() { + super("exportFunctionTriggerEvent_110"); + } } - class ExportFunctionTriggerEvent_111 { + @SepNode + class ExportFunctionTriggerEvent_111 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_111() { + super("exportFunctionTriggerEvent_111"); + } } - class ExportFunctionTriggerEvent_112 { + @SepNode + class ExportFunctionTriggerEvent_112 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_112() { + super("exportFunctionTriggerEvent_112"); + } } - class ExportFunctionTriggerEvent_113 { + @SepNode + class ExportFunctionTriggerEvent_113 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_113() { + super("exportFunctionTriggerEvent_113"); + } } - class ExportFunctionTriggerEvent_114 { + @SepNode + class ExportFunctionTriggerEvent_114 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_114() { + super("exportFunctionTriggerEvent_114"); + } } - class ExportFunctionTriggerEvent_115 { + @SepNode + class ExportFunctionTriggerEvent_115 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_115() { + super("exportFunctionTriggerEvent_115"); + } } - class ExportFunctionTriggerEvent_116 { + @SepNode + class ExportFunctionTriggerEvent_116 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_116() { + super("exportFunctionTriggerEvent_116"); + } } - class ExportFunctionTriggerEvent_117 { + @SepNode + class ExportFunctionTriggerEvent_117 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_117() { + super("exportFunctionTriggerEvent_117"); + } } - class ExportFunctionTriggerEvent_118 { + @SepNode + class ExportFunctionTriggerEvent_118 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_118() { + super("exportFunctionTriggerEvent_118"); + } } - class ExportFunctionTriggerEvent_119 { + @SepNode + class ExportFunctionTriggerEvent_119 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_119() { + super("exportFunctionTriggerEvent_119"); + } } - class ExportFunctionTriggerEvent_120 { + @SepNode + class ExportFunctionTriggerEvent_120 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_120() { + super("exportFunctionTriggerEvent_120"); + } } - class ExportFunctionTriggerEvent_121 { + @SepNode + class ExportFunctionTriggerEvent_121 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_121() { + super("exportFunctionTriggerEvent_121"); + } } - class ExportFunctionTriggerEvent_122 { + @SepNode + class ExportFunctionTriggerEvent_122 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_122() { + super("exportFunctionTriggerEvent_122"); + } } - class ExportFunctionTriggerEvent_123 { + @SepNode + class ExportFunctionTriggerEvent_123 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_123() { + super("exportFunctionTriggerEvent_123"); + } } - class ExportFunctionTriggerEvent_124 { + @SepNode + class ExportFunctionTriggerEvent_124 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_124() { + super("exportFunctionTriggerEvent_124"); + } } - class ExportFunctionTriggerEvent_125 { + @SepNode + class ExportFunctionTriggerEvent_125 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_125() { + super("exportFunctionTriggerEvent_125"); + } } - class ExportFunctionTriggerEvent_126 { + @SepNode + class ExportFunctionTriggerEvent_126 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_126() { + super("exportFunctionTriggerEvent_126"); + } } - class ExportFunctionTriggerEvent_127 { + @SepNode + class ExportFunctionTriggerEvent_127 extends NamedNodeSimple { + public ExportFunctionTriggerEvent_127() { + super("exportFunctionTriggerEvent_127"); + } } + } diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallbackEvent.java b/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallbackEvent.java index 2fb6007ef..dd339710f 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallbackEvent.java +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/InstanceCallbackEvent.java @@ -1,5 +1,7 @@ package com.fluxtion.runtime.callback; +import com.fluxtion.runtime.annotations.builder.SepNode; + import java.util.ArrayList; import java.util.List; @@ -9,7 +11,12 @@ public interface InstanceCallbackEvent { static void main(String[] args) { for (int i = 0; i < 128; i++) { - System.out.printf("class InstanceCallbackEvent_%d {}%n", i); + System.out.printf("@SepNode%n" + + "class InstanceCallbackEvent_%1$d extends NamedNodeSimple {%n" + + " public InstanceCallbackEvent_%1$d(){%n" + + " super(\"callBackTriggerEvent_%1$d\");%n" + + " }%n" + + "}%n%n", i); } for (int i = 0; i < 128; i++) { System.out.printf("cbClassList.add(InstanceCallbackEvent_%d.class);%n", i); @@ -151,387 +158,899 @@ static void reset() { } - class InstanceCallbackEvent_0 { + @SepNode + class InstanceCallbackEvent_0 extends NamedNodeSimple { + public InstanceCallbackEvent_0() { + super("callBackTriggerEvent_0"); + } } - class InstanceCallbackEvent_1 { + @SepNode + class InstanceCallbackEvent_1 extends NamedNodeSimple { + public InstanceCallbackEvent_1() { + super("callBackTriggerEvent_1"); + } } - class InstanceCallbackEvent_2 { + @SepNode + class InstanceCallbackEvent_2 extends NamedNodeSimple { + public InstanceCallbackEvent_2() { + super("callBackTriggerEvent_2"); + } } - class InstanceCallbackEvent_3 { + @SepNode + class InstanceCallbackEvent_3 extends NamedNodeSimple { + public InstanceCallbackEvent_3() { + super("callBackTriggerEvent_3"); + } } - class InstanceCallbackEvent_4 { + @SepNode + class InstanceCallbackEvent_4 extends NamedNodeSimple { + public InstanceCallbackEvent_4() { + super("callBackTriggerEvent_4"); + } } - class InstanceCallbackEvent_5 { + @SepNode + class InstanceCallbackEvent_5 extends NamedNodeSimple { + public InstanceCallbackEvent_5() { + super("callBackTriggerEvent_5"); + } } - class InstanceCallbackEvent_6 { + @SepNode + class InstanceCallbackEvent_6 extends NamedNodeSimple { + public InstanceCallbackEvent_6() { + super("callBackTriggerEvent_6"); + } } - class InstanceCallbackEvent_7 { + @SepNode + class InstanceCallbackEvent_7 extends NamedNodeSimple { + public InstanceCallbackEvent_7() { + super("callBackTriggerEvent_7"); + } } - class InstanceCallbackEvent_8 { + @SepNode + class InstanceCallbackEvent_8 extends NamedNodeSimple { + public InstanceCallbackEvent_8() { + super("callBackTriggerEvent_8"); + } } - class InstanceCallbackEvent_9 { + @SepNode + class InstanceCallbackEvent_9 extends NamedNodeSimple { + public InstanceCallbackEvent_9() { + super("callBackTriggerEvent_9"); + } } - class InstanceCallbackEvent_10 { + @SepNode + class InstanceCallbackEvent_10 extends NamedNodeSimple { + public InstanceCallbackEvent_10() { + super("callBackTriggerEvent_10"); + } } - class InstanceCallbackEvent_11 { + @SepNode + class InstanceCallbackEvent_11 extends NamedNodeSimple { + public InstanceCallbackEvent_11() { + super("callBackTriggerEvent_11"); + } } - class InstanceCallbackEvent_12 { + @SepNode + class InstanceCallbackEvent_12 extends NamedNodeSimple { + public InstanceCallbackEvent_12() { + super("callBackTriggerEvent_12"); + } } - class InstanceCallbackEvent_13 { + @SepNode + class InstanceCallbackEvent_13 extends NamedNodeSimple { + public InstanceCallbackEvent_13() { + super("callBackTriggerEvent_13"); + } } - class InstanceCallbackEvent_14 { + @SepNode + class InstanceCallbackEvent_14 extends NamedNodeSimple { + public InstanceCallbackEvent_14() { + super("callBackTriggerEvent_14"); + } } - class InstanceCallbackEvent_15 { + @SepNode + class InstanceCallbackEvent_15 extends NamedNodeSimple { + public InstanceCallbackEvent_15() { + super("callBackTriggerEvent_15"); + } } - class InstanceCallbackEvent_16 { + @SepNode + class InstanceCallbackEvent_16 extends NamedNodeSimple { + public InstanceCallbackEvent_16() { + super("callBackTriggerEvent_16"); + } } - class InstanceCallbackEvent_17 { + @SepNode + class InstanceCallbackEvent_17 extends NamedNodeSimple { + public InstanceCallbackEvent_17() { + super("callBackTriggerEvent_17"); + } } - class InstanceCallbackEvent_18 { + @SepNode + class InstanceCallbackEvent_18 extends NamedNodeSimple { + public InstanceCallbackEvent_18() { + super("callBackTriggerEvent_18"); + } } - class InstanceCallbackEvent_19 { + @SepNode + class InstanceCallbackEvent_19 extends NamedNodeSimple { + public InstanceCallbackEvent_19() { + super("callBackTriggerEvent_19"); + } } - class InstanceCallbackEvent_20 { + @SepNode + class InstanceCallbackEvent_20 extends NamedNodeSimple { + public InstanceCallbackEvent_20() { + super("callBackTriggerEvent_20"); + } } - class InstanceCallbackEvent_21 { + @SepNode + class InstanceCallbackEvent_21 extends NamedNodeSimple { + public InstanceCallbackEvent_21() { + super("callBackTriggerEvent_21"); + } } - class InstanceCallbackEvent_22 { + @SepNode + class InstanceCallbackEvent_22 extends NamedNodeSimple { + public InstanceCallbackEvent_22() { + super("callBackTriggerEvent_22"); + } } - class InstanceCallbackEvent_23 { + @SepNode + class InstanceCallbackEvent_23 extends NamedNodeSimple { + public InstanceCallbackEvent_23() { + super("callBackTriggerEvent_23"); + } } - class InstanceCallbackEvent_24 { + @SepNode + class InstanceCallbackEvent_24 extends NamedNodeSimple { + public InstanceCallbackEvent_24() { + super("callBackTriggerEvent_24"); + } } - class InstanceCallbackEvent_25 { + @SepNode + class InstanceCallbackEvent_25 extends NamedNodeSimple { + public InstanceCallbackEvent_25() { + super("callBackTriggerEvent_25"); + } } - class InstanceCallbackEvent_26 { + @SepNode + class InstanceCallbackEvent_26 extends NamedNodeSimple { + public InstanceCallbackEvent_26() { + super("callBackTriggerEvent_26"); + } } - class InstanceCallbackEvent_27 { + @SepNode + class InstanceCallbackEvent_27 extends NamedNodeSimple { + public InstanceCallbackEvent_27() { + super("callBackTriggerEvent_27"); + } } - class InstanceCallbackEvent_28 { + @SepNode + class InstanceCallbackEvent_28 extends NamedNodeSimple { + public InstanceCallbackEvent_28() { + super("callBackTriggerEvent_28"); + } } - class InstanceCallbackEvent_29 { + @SepNode + class InstanceCallbackEvent_29 extends NamedNodeSimple { + public InstanceCallbackEvent_29() { + super("callBackTriggerEvent_29"); + } } - class InstanceCallbackEvent_30 { + @SepNode + class InstanceCallbackEvent_30 extends NamedNodeSimple { + public InstanceCallbackEvent_30() { + super("callBackTriggerEvent_30"); + } } - class InstanceCallbackEvent_31 { + @SepNode + class InstanceCallbackEvent_31 extends NamedNodeSimple { + public InstanceCallbackEvent_31() { + super("callBackTriggerEvent_31"); + } } - class InstanceCallbackEvent_32 { + @SepNode + class InstanceCallbackEvent_32 extends NamedNodeSimple { + public InstanceCallbackEvent_32() { + super("callBackTriggerEvent_32"); + } } - class InstanceCallbackEvent_33 { + @SepNode + class InstanceCallbackEvent_33 extends NamedNodeSimple { + public InstanceCallbackEvent_33() { + super("callBackTriggerEvent_33"); + } } - class InstanceCallbackEvent_34 { + @SepNode + class InstanceCallbackEvent_34 extends NamedNodeSimple { + public InstanceCallbackEvent_34() { + super("callBackTriggerEvent_34"); + } } - class InstanceCallbackEvent_35 { + @SepNode + class InstanceCallbackEvent_35 extends NamedNodeSimple { + public InstanceCallbackEvent_35() { + super("callBackTriggerEvent_35"); + } } - class InstanceCallbackEvent_36 { + @SepNode + class InstanceCallbackEvent_36 extends NamedNodeSimple { + public InstanceCallbackEvent_36() { + super("callBackTriggerEvent_36"); + } } - class InstanceCallbackEvent_37 { + @SepNode + class InstanceCallbackEvent_37 extends NamedNodeSimple { + public InstanceCallbackEvent_37() { + super("callBackTriggerEvent_37"); + } } - class InstanceCallbackEvent_38 { + @SepNode + class InstanceCallbackEvent_38 extends NamedNodeSimple { + public InstanceCallbackEvent_38() { + super("callBackTriggerEvent_38"); + } } - class InstanceCallbackEvent_39 { + @SepNode + class InstanceCallbackEvent_39 extends NamedNodeSimple { + public InstanceCallbackEvent_39() { + super("callBackTriggerEvent_39"); + } } - class InstanceCallbackEvent_40 { + @SepNode + class InstanceCallbackEvent_40 extends NamedNodeSimple { + public InstanceCallbackEvent_40() { + super("callBackTriggerEvent_40"); + } } - class InstanceCallbackEvent_41 { + @SepNode + class InstanceCallbackEvent_41 extends NamedNodeSimple { + public InstanceCallbackEvent_41() { + super("callBackTriggerEvent_41"); + } } - class InstanceCallbackEvent_42 { + @SepNode + class InstanceCallbackEvent_42 extends NamedNodeSimple { + public InstanceCallbackEvent_42() { + super("callBackTriggerEvent_42"); + } } - class InstanceCallbackEvent_43 { + @SepNode + class InstanceCallbackEvent_43 extends NamedNodeSimple { + public InstanceCallbackEvent_43() { + super("callBackTriggerEvent_43"); + } } - class InstanceCallbackEvent_44 { + @SepNode + class InstanceCallbackEvent_44 extends NamedNodeSimple { + public InstanceCallbackEvent_44() { + super("callBackTriggerEvent_44"); + } } - class InstanceCallbackEvent_45 { + @SepNode + class InstanceCallbackEvent_45 extends NamedNodeSimple { + public InstanceCallbackEvent_45() { + super("callBackTriggerEvent_45"); + } } - class InstanceCallbackEvent_46 { + @SepNode + class InstanceCallbackEvent_46 extends NamedNodeSimple { + public InstanceCallbackEvent_46() { + super("callBackTriggerEvent_46"); + } } - class InstanceCallbackEvent_47 { + @SepNode + class InstanceCallbackEvent_47 extends NamedNodeSimple { + public InstanceCallbackEvent_47() { + super("callBackTriggerEvent_47"); + } } - class InstanceCallbackEvent_48 { + @SepNode + class InstanceCallbackEvent_48 extends NamedNodeSimple { + public InstanceCallbackEvent_48() { + super("callBackTriggerEvent_48"); + } } - class InstanceCallbackEvent_49 { + @SepNode + class InstanceCallbackEvent_49 extends NamedNodeSimple { + public InstanceCallbackEvent_49() { + super("callBackTriggerEvent_49"); + } } - class InstanceCallbackEvent_50 { + @SepNode + class InstanceCallbackEvent_50 extends NamedNodeSimple { + public InstanceCallbackEvent_50() { + super("callBackTriggerEvent_50"); + } } - class InstanceCallbackEvent_51 { + @SepNode + class InstanceCallbackEvent_51 extends NamedNodeSimple { + public InstanceCallbackEvent_51() { + super("callBackTriggerEvent_51"); + } } - class InstanceCallbackEvent_52 { + @SepNode + class InstanceCallbackEvent_52 extends NamedNodeSimple { + public InstanceCallbackEvent_52() { + super("callBackTriggerEvent_52"); + } } - class InstanceCallbackEvent_53 { + @SepNode + class InstanceCallbackEvent_53 extends NamedNodeSimple { + public InstanceCallbackEvent_53() { + super("callBackTriggerEvent_53"); + } } - class InstanceCallbackEvent_54 { + @SepNode + class InstanceCallbackEvent_54 extends NamedNodeSimple { + public InstanceCallbackEvent_54() { + super("callBackTriggerEvent_54"); + } } - class InstanceCallbackEvent_55 { + @SepNode + class InstanceCallbackEvent_55 extends NamedNodeSimple { + public InstanceCallbackEvent_55() { + super("callBackTriggerEvent_55"); + } } - class InstanceCallbackEvent_56 { + @SepNode + class InstanceCallbackEvent_56 extends NamedNodeSimple { + public InstanceCallbackEvent_56() { + super("callBackTriggerEvent_56"); + } } - class InstanceCallbackEvent_57 { + @SepNode + class InstanceCallbackEvent_57 extends NamedNodeSimple { + public InstanceCallbackEvent_57() { + super("callBackTriggerEvent_57"); + } } - class InstanceCallbackEvent_58 { + @SepNode + class InstanceCallbackEvent_58 extends NamedNodeSimple { + public InstanceCallbackEvent_58() { + super("callBackTriggerEvent_58"); + } } - class InstanceCallbackEvent_59 { + @SepNode + class InstanceCallbackEvent_59 extends NamedNodeSimple { + public InstanceCallbackEvent_59() { + super("callBackTriggerEvent_59"); + } } - class InstanceCallbackEvent_60 { + @SepNode + class InstanceCallbackEvent_60 extends NamedNodeSimple { + public InstanceCallbackEvent_60() { + super("callBackTriggerEvent_60"); + } } - class InstanceCallbackEvent_61 { + @SepNode + class InstanceCallbackEvent_61 extends NamedNodeSimple { + public InstanceCallbackEvent_61() { + super("callBackTriggerEvent_61"); + } } - class InstanceCallbackEvent_62 { + @SepNode + class InstanceCallbackEvent_62 extends NamedNodeSimple { + public InstanceCallbackEvent_62() { + super("callBackTriggerEvent_62"); + } } - class InstanceCallbackEvent_63 { + @SepNode + class InstanceCallbackEvent_63 extends NamedNodeSimple { + public InstanceCallbackEvent_63() { + super("callBackTriggerEvent_63"); + } } - class InstanceCallbackEvent_64 { + @SepNode + class InstanceCallbackEvent_64 extends NamedNodeSimple { + public InstanceCallbackEvent_64() { + super("callBackTriggerEvent_64"); + } } - class InstanceCallbackEvent_65 { + @SepNode + class InstanceCallbackEvent_65 extends NamedNodeSimple { + public InstanceCallbackEvent_65() { + super("callBackTriggerEvent_65"); + } } - class InstanceCallbackEvent_66 { + @SepNode + class InstanceCallbackEvent_66 extends NamedNodeSimple { + public InstanceCallbackEvent_66() { + super("callBackTriggerEvent_66"); + } } - class InstanceCallbackEvent_67 { + @SepNode + class InstanceCallbackEvent_67 extends NamedNodeSimple { + public InstanceCallbackEvent_67() { + super("callBackTriggerEvent_67"); + } } - class InstanceCallbackEvent_68 { + @SepNode + class InstanceCallbackEvent_68 extends NamedNodeSimple { + public InstanceCallbackEvent_68() { + super("callBackTriggerEvent_68"); + } } - class InstanceCallbackEvent_69 { + @SepNode + class InstanceCallbackEvent_69 extends NamedNodeSimple { + public InstanceCallbackEvent_69() { + super("callBackTriggerEvent_69"); + } } - class InstanceCallbackEvent_70 { + @SepNode + class InstanceCallbackEvent_70 extends NamedNodeSimple { + public InstanceCallbackEvent_70() { + super("callBackTriggerEvent_70"); + } } - class InstanceCallbackEvent_71 { + @SepNode + class InstanceCallbackEvent_71 extends NamedNodeSimple { + public InstanceCallbackEvent_71() { + super("callBackTriggerEvent_71"); + } } - class InstanceCallbackEvent_72 { + @SepNode + class InstanceCallbackEvent_72 extends NamedNodeSimple { + public InstanceCallbackEvent_72() { + super("callBackTriggerEvent_72"); + } } - class InstanceCallbackEvent_73 { + @SepNode + class InstanceCallbackEvent_73 extends NamedNodeSimple { + public InstanceCallbackEvent_73() { + super("callBackTriggerEvent_73"); + } } - class InstanceCallbackEvent_74 { + @SepNode + class InstanceCallbackEvent_74 extends NamedNodeSimple { + public InstanceCallbackEvent_74() { + super("callBackTriggerEvent_74"); + } } - class InstanceCallbackEvent_75 { + @SepNode + class InstanceCallbackEvent_75 extends NamedNodeSimple { + public InstanceCallbackEvent_75() { + super("callBackTriggerEvent_75"); + } } - class InstanceCallbackEvent_76 { + @SepNode + class InstanceCallbackEvent_76 extends NamedNodeSimple { + public InstanceCallbackEvent_76() { + super("callBackTriggerEvent_76"); + } } - class InstanceCallbackEvent_77 { + @SepNode + class InstanceCallbackEvent_77 extends NamedNodeSimple { + public InstanceCallbackEvent_77() { + super("callBackTriggerEvent_77"); + } } - class InstanceCallbackEvent_78 { + @SepNode + class InstanceCallbackEvent_78 extends NamedNodeSimple { + public InstanceCallbackEvent_78() { + super("callBackTriggerEvent_78"); + } } - class InstanceCallbackEvent_79 { + @SepNode + class InstanceCallbackEvent_79 extends NamedNodeSimple { + public InstanceCallbackEvent_79() { + super("callBackTriggerEvent_79"); + } } - class InstanceCallbackEvent_80 { + @SepNode + class InstanceCallbackEvent_80 extends NamedNodeSimple { + public InstanceCallbackEvent_80() { + super("callBackTriggerEvent_80"); + } } - class InstanceCallbackEvent_81 { + @SepNode + class InstanceCallbackEvent_81 extends NamedNodeSimple { + public InstanceCallbackEvent_81() { + super("callBackTriggerEvent_81"); + } } - class InstanceCallbackEvent_82 { + @SepNode + class InstanceCallbackEvent_82 extends NamedNodeSimple { + public InstanceCallbackEvent_82() { + super("callBackTriggerEvent_82"); + } } - class InstanceCallbackEvent_83 { + @SepNode + class InstanceCallbackEvent_83 extends NamedNodeSimple { + public InstanceCallbackEvent_83() { + super("callBackTriggerEvent_83"); + } } - class InstanceCallbackEvent_84 { + @SepNode + class InstanceCallbackEvent_84 extends NamedNodeSimple { + public InstanceCallbackEvent_84() { + super("callBackTriggerEvent_84"); + } } - class InstanceCallbackEvent_85 { + @SepNode + class InstanceCallbackEvent_85 extends NamedNodeSimple { + public InstanceCallbackEvent_85() { + super("callBackTriggerEvent_85"); + } } - class InstanceCallbackEvent_86 { + @SepNode + class InstanceCallbackEvent_86 extends NamedNodeSimple { + public InstanceCallbackEvent_86() { + super("callBackTriggerEvent_86"); + } } - class InstanceCallbackEvent_87 { + @SepNode + class InstanceCallbackEvent_87 extends NamedNodeSimple { + public InstanceCallbackEvent_87() { + super("callBackTriggerEvent_87"); + } } - class InstanceCallbackEvent_88 { + @SepNode + class InstanceCallbackEvent_88 extends NamedNodeSimple { + public InstanceCallbackEvent_88() { + super("callBackTriggerEvent_88"); + } } - class InstanceCallbackEvent_89 { + @SepNode + class InstanceCallbackEvent_89 extends NamedNodeSimple { + public InstanceCallbackEvent_89() { + super("callBackTriggerEvent_89"); + } } - class InstanceCallbackEvent_90 { + @SepNode + class InstanceCallbackEvent_90 extends NamedNodeSimple { + public InstanceCallbackEvent_90() { + super("callBackTriggerEvent_90"); + } } - class InstanceCallbackEvent_91 { + @SepNode + class InstanceCallbackEvent_91 extends NamedNodeSimple { + public InstanceCallbackEvent_91() { + super("callBackTriggerEvent_91"); + } } - class InstanceCallbackEvent_92 { + @SepNode + class InstanceCallbackEvent_92 extends NamedNodeSimple { + public InstanceCallbackEvent_92() { + super("callBackTriggerEvent_92"); + } } - class InstanceCallbackEvent_93 { + @SepNode + class InstanceCallbackEvent_93 extends NamedNodeSimple { + public InstanceCallbackEvent_93() { + super("callBackTriggerEvent_93"); + } } - class InstanceCallbackEvent_94 { + @SepNode + class InstanceCallbackEvent_94 extends NamedNodeSimple { + public InstanceCallbackEvent_94() { + super("callBackTriggerEvent_94"); + } } - class InstanceCallbackEvent_95 { + @SepNode + class InstanceCallbackEvent_95 extends NamedNodeSimple { + public InstanceCallbackEvent_95() { + super("callBackTriggerEvent_95"); + } } - class InstanceCallbackEvent_96 { + @SepNode + class InstanceCallbackEvent_96 extends NamedNodeSimple { + public InstanceCallbackEvent_96() { + super("callBackTriggerEvent_96"); + } } - class InstanceCallbackEvent_97 { + @SepNode + class InstanceCallbackEvent_97 extends NamedNodeSimple { + public InstanceCallbackEvent_97() { + super("callBackTriggerEvent_97"); + } } - class InstanceCallbackEvent_98 { + @SepNode + class InstanceCallbackEvent_98 extends NamedNodeSimple { + public InstanceCallbackEvent_98() { + super("callBackTriggerEvent_98"); + } } - class InstanceCallbackEvent_99 { + @SepNode + class InstanceCallbackEvent_99 extends NamedNodeSimple { + public InstanceCallbackEvent_99() { + super("callBackTriggerEvent_99"); + } } - class InstanceCallbackEvent_100 { + @SepNode + class InstanceCallbackEvent_100 extends NamedNodeSimple { + public InstanceCallbackEvent_100() { + super("callBackTriggerEvent_100"); + } } - class InstanceCallbackEvent_101 { + @SepNode + class InstanceCallbackEvent_101 extends NamedNodeSimple { + public InstanceCallbackEvent_101() { + super("callBackTriggerEvent_101"); + } } - class InstanceCallbackEvent_102 { + @SepNode + class InstanceCallbackEvent_102 extends NamedNodeSimple { + public InstanceCallbackEvent_102() { + super("callBackTriggerEvent_102"); + } } - class InstanceCallbackEvent_103 { + @SepNode + class InstanceCallbackEvent_103 extends NamedNodeSimple { + public InstanceCallbackEvent_103() { + super("callBackTriggerEvent_103"); + } } - class InstanceCallbackEvent_104 { + @SepNode + class InstanceCallbackEvent_104 extends NamedNodeSimple { + public InstanceCallbackEvent_104() { + super("callBackTriggerEvent_104"); + } } - class InstanceCallbackEvent_105 { + @SepNode + class InstanceCallbackEvent_105 extends NamedNodeSimple { + public InstanceCallbackEvent_105() { + super("callBackTriggerEvent_105"); + } } - class InstanceCallbackEvent_106 { + @SepNode + class InstanceCallbackEvent_106 extends NamedNodeSimple { + public InstanceCallbackEvent_106() { + super("callBackTriggerEvent_106"); + } } - class InstanceCallbackEvent_107 { + @SepNode + class InstanceCallbackEvent_107 extends NamedNodeSimple { + public InstanceCallbackEvent_107() { + super("callBackTriggerEvent_107"); + } } - class InstanceCallbackEvent_108 { + @SepNode + class InstanceCallbackEvent_108 extends NamedNodeSimple { + public InstanceCallbackEvent_108() { + super("callBackTriggerEvent_108"); + } } - class InstanceCallbackEvent_109 { + @SepNode + class InstanceCallbackEvent_109 extends NamedNodeSimple { + public InstanceCallbackEvent_109() { + super("callBackTriggerEvent_109"); + } } - class InstanceCallbackEvent_110 { + @SepNode + class InstanceCallbackEvent_110 extends NamedNodeSimple { + public InstanceCallbackEvent_110() { + super("callBackTriggerEvent_110"); + } } - class InstanceCallbackEvent_111 { + @SepNode + class InstanceCallbackEvent_111 extends NamedNodeSimple { + public InstanceCallbackEvent_111() { + super("callBackTriggerEvent_111"); + } } - class InstanceCallbackEvent_112 { + @SepNode + class InstanceCallbackEvent_112 extends NamedNodeSimple { + public InstanceCallbackEvent_112() { + super("callBackTriggerEvent_112"); + } } - class InstanceCallbackEvent_113 { + @SepNode + class InstanceCallbackEvent_113 extends NamedNodeSimple { + public InstanceCallbackEvent_113() { + super("callBackTriggerEvent_113"); + } } - class InstanceCallbackEvent_114 { + @SepNode + class InstanceCallbackEvent_114 extends NamedNodeSimple { + public InstanceCallbackEvent_114() { + super("callBackTriggerEvent_114"); + } } - class InstanceCallbackEvent_115 { + @SepNode + class InstanceCallbackEvent_115 extends NamedNodeSimple { + public InstanceCallbackEvent_115() { + super("callBackTriggerEvent_115"); + } } - class InstanceCallbackEvent_116 { + @SepNode + class InstanceCallbackEvent_116 extends NamedNodeSimple { + public InstanceCallbackEvent_116() { + super("callBackTriggerEvent_116"); + } } - class InstanceCallbackEvent_117 { + @SepNode + class InstanceCallbackEvent_117 extends NamedNodeSimple { + public InstanceCallbackEvent_117() { + super("callBackTriggerEvent_117"); + } } - class InstanceCallbackEvent_118 { + @SepNode + class InstanceCallbackEvent_118 extends NamedNodeSimple { + public InstanceCallbackEvent_118() { + super("callBackTriggerEvent_118"); + } } - class InstanceCallbackEvent_119 { + @SepNode + class InstanceCallbackEvent_119 extends NamedNodeSimple { + public InstanceCallbackEvent_119() { + super("callBackTriggerEvent_119"); + } } - class InstanceCallbackEvent_120 { + @SepNode + class InstanceCallbackEvent_120 extends NamedNodeSimple { + public InstanceCallbackEvent_120() { + super("callBackTriggerEvent_120"); + } } - class InstanceCallbackEvent_121 { + @SepNode + class InstanceCallbackEvent_121 extends NamedNodeSimple { + public InstanceCallbackEvent_121() { + super("callBackTriggerEvent_121"); + } } - class InstanceCallbackEvent_122 { + @SepNode + class InstanceCallbackEvent_122 extends NamedNodeSimple { + public InstanceCallbackEvent_122() { + super("callBackTriggerEvent_122"); + } } - class InstanceCallbackEvent_123 { + @SepNode + class InstanceCallbackEvent_123 extends NamedNodeSimple { + public InstanceCallbackEvent_123() { + super("callBackTriggerEvent_123"); + } } - class InstanceCallbackEvent_124 { + @SepNode + class InstanceCallbackEvent_124 extends NamedNodeSimple { + public InstanceCallbackEvent_124() { + super("callBackTriggerEvent_124"); + } } - class InstanceCallbackEvent_125 { + @SepNode + class InstanceCallbackEvent_125 extends NamedNodeSimple { + public InstanceCallbackEvent_125() { + super("callBackTriggerEvent_125"); + } } - class InstanceCallbackEvent_126 { + @SepNode + class InstanceCallbackEvent_126 extends NamedNodeSimple { + public InstanceCallbackEvent_126() { + super("callBackTriggerEvent_126"); + } } - class InstanceCallbackEvent_127 { + @SepNode + class InstanceCallbackEvent_127 extends NamedNodeSimple { + public InstanceCallbackEvent_127() { + super("callBackTriggerEvent_127"); + } } } diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/NamedNodeSimple.java b/runtime/src/main/java/com/fluxtion/runtime/callback/NamedNodeSimple.java new file mode 100644 index 000000000..ab0ad6dc5 --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/NamedNodeSimple.java @@ -0,0 +1,33 @@ +package com.fluxtion.runtime.callback; + +import com.fluxtion.runtime.audit.EventLogNode; +import com.fluxtion.runtime.node.NamedNode; + +import java.util.Objects; + +public abstract class NamedNodeSimple extends EventLogNode implements NamedNode { + + private String name; + + public NamedNodeSimple(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + NamedNodeSimple that = (NamedNodeSimple) o; + return Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return name.hashCode(); + } +} From 6dc045e9445c1f34e6969fd622e16268db9c0bb0 Mon Sep 17 00:00:00 2001 From: command-line Date: Mon, 17 Jul 2023 06:30:30 +0100 Subject: [PATCH 087/228] start work on export interface --- .../ValidateExportFunctionAnnotations.java | 7 +++++-- .../ValidatingAnnotationProcessorTest.java | 21 ++++++++++++++++++- .../exportfunction/ExportFunctionTest.java | 12 +++++++++++ .../exportservice/ExportedServiceTest.java | 20 ++++++++++++++++++ .../runtime/annotations/ExportService.java | 11 ++++++++++ 5 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java create mode 100644 runtime/src/main/java/com/fluxtion/runtime/annotations/ExportService.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java b/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java index 34527856d..acbe0fe4e 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/annotationprocessor/ValidateExportFunctionAnnotations.java @@ -26,8 +26,11 @@ public boolean process(Set annotations, RoundEnvironment Set annotatedElements = roundEnv.getElementsAnnotatedWith(annotation); Set typeElements = annotatedElements.stream() .filter(element -> - ((ExecutableType) element.asType()).getReturnType().getKind() != TypeKind.BOOLEAN - || !element.getModifiers().contains(Modifier.PUBLIC) + { + TypeKind returnType = ((ExecutableType) element.asType()).getReturnType().getKind(); + boolean validReturn = returnType == TypeKind.BOOLEAN || returnType == TypeKind.VOID; + return !validReturn || !element.getModifiers().contains(Modifier.PUBLIC); + } ) .collect(Collectors.toSet()); diff --git a/compiler/src/test/java/com/fluxtion/compiler/annotationprocessor/ValidatingAnnotationProcessorTest.java b/compiler/src/test/java/com/fluxtion/compiler/annotationprocessor/ValidatingAnnotationProcessorTest.java index 999b9540a..21f000d57 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/annotationprocessor/ValidatingAnnotationProcessorTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/annotationprocessor/ValidatingAnnotationProcessorTest.java @@ -172,7 +172,26 @@ public void failCompileString_ExportFunction() { @SneakyThrows @Test(expected = RuntimeException.class) - public void failCompileString_ExportFunction_NoBooleanReturn() { + public void failCompileString_ExportFunction_NoBooleanOrVoidReturn() { + String source = " " + + "import com.fluxtion.runtime.annotations.OnEventHandler;\n" + + "import com.fluxtion.runtime.annotations.ExportFunction;\n" + + "import com.fluxtion.runtime.callback.ExportFunctionNode;\n" + + "\n" + + "public class MyStringHandler extends ExportFunctionNode{\n" + + " String in;\n" + + "\n" + + " @ExportFunction\n" + + " public int stringUpdated(String in) {\n" + + " this.in = in;\n" + + " return 0;\n" + + " }\n" + + "}"; + StringCompilation.compile("MyStringHandler", source); + } + + @SneakyThrows + public void success_ExportFunction_VoidReturn() { String source = " " + "import com.fluxtion.runtime.annotations.OnEventHandler;\n" + "import com.fluxtion.runtime.annotations.ExportFunction;\n" + diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java index 59ff980f4..861ca28e5 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java @@ -8,6 +8,7 @@ import com.fluxtion.runtime.annotations.builder.AssignToField; import com.fluxtion.runtime.callback.ExportFunctionNode; import com.fluxtion.runtime.callback.ExportFunctionTrigger; +import lombok.Getter; import org.junit.Assert; import org.junit.Test; @@ -221,4 +222,15 @@ public boolean triggered() { return true; } } + + @Getter + public static class AlwaysTrueExport extends ExportFunctionNode { + private int result; + + @ExportFunction() + public void addFunction(int x, int y) { + result = x + y; +// return true; + } + } } diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java new file mode 100644 index 000000000..c17d7774f --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java @@ -0,0 +1,20 @@ +package com.fluxtion.compiler.generation.exportservice; + +import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest; +import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; +import com.fluxtion.runtime.annotations.ExportService; + +public class ExportedServiceTest extends MultipleSepTargetInProcessTest { + + public ExportedServiceTest(CompiledAndInterpretedSepTest.SepTestConfig testConfig) { + super(testConfig); + } + + public interface MyService { + + } + + public static class MyExportingServiceNode implements @ExportService MyService { + + } +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/annotations/ExportService.java b/runtime/src/main/java/com/fluxtion/runtime/annotations/ExportService.java new file mode 100644 index 000000000..44f56a67c --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/annotations/ExportService.java @@ -0,0 +1,11 @@ +package com.fluxtion.runtime.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE_USE}) +public @interface ExportService { +} From b2027bac6a9d00dd4ee2be818fb763f7de8d34ee Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 17 Jul 2023 10:00:05 +0100 Subject: [PATCH 088/228] replace logRecord for all registered EventSource nodes --- .../compiler/generation/util/ClassUtils.java | 16 ++-- .../generation/audit/LifecycleAuditTest.java | 22 ++++++ .../exportservice/ExportedServiceTest.java | 75 ++++++++++++++++++- .../runtime/audit/EventLogManager.java | 14 ++++ 4 files changed, 118 insertions(+), 9 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java index 8fb493403..5d400c195 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java @@ -32,12 +32,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.StringJoiner; +import java.util.*; import java.util.concurrent.atomic.LongAdder; import java.util.stream.Collectors; @@ -245,8 +240,13 @@ static String wrapExportedFunctionCall(String exportedMethodName, ExportFunction } callBackList.forEach(cb -> { String variableName = cb.getVariableName(); - signature.append(variableName).append(".setTriggered("). - append(variableName).append(".").append(cb.getMethod().getName()).append(sjInvoker); + if (cb.getMethod().getReturnType() == void.class) { + signature.append(variableName).append(".").append(cb.getMethod().getName()).append(sjInvoker.toString().replace("));", ");")); + signature.append(variableName).append(".setTriggered(true);\n"); + } else { + signature.append(variableName).append(".setTriggered("). + append(variableName).append(".").append(cb.getMethod().getName()).append(sjInvoker); + } }); //close //onEvent(handlerExportFunctionTriggerEvent_0.getEvent()); diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java index 7e2ab9820..9dd301e06 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java @@ -9,7 +9,9 @@ import org.junit.Test; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class LifecycleAuditTest extends MultipleSepTargetInProcessTest { public LifecycleAuditTest(SepTestConfig testConfig) { @@ -44,14 +46,27 @@ public void replaceLogRecord() { sep.setAuditLogProcessor(logSink::add); sep.setAuditLogRecordEncoder(myLogRecord); start(); + Assert.assertEquals("started", myLogRecord.logMap.get("lifecycle")); Assert.assertEquals(2, myLogRecord.getTerminateCount()); + onEvent("test"); + Assert.assertEquals("eventHandler", myLogRecord.logMap.get("lifecycle")); + Assert.assertEquals("test", myLogRecord.logMap.get("message")); Assert.assertEquals(3, myLogRecord.getTerminateCount()); + onEvent("test2"); + Assert.assertEquals("eventHandler", myLogRecord.logMap.get("lifecycle")); + Assert.assertEquals("test2", myLogRecord.logMap.get("message")); Assert.assertEquals(4, myLogRecord.getTerminateCount()); + stop(); + Assert.assertEquals("stop", myLogRecord.logMap.get("lifecycle")); + Assert.assertEquals("test2", myLogRecord.logMap.get("message")); Assert.assertEquals(5, myLogRecord.getTerminateCount()); + tearDown(); + Assert.assertEquals("teardown", myLogRecord.logMap.get("lifecycle")); + Assert.assertEquals("test2", myLogRecord.logMap.get("message")); Assert.assertEquals(6, myLogRecord.getTerminateCount()); } @@ -79,6 +94,7 @@ public void teardown() { @OnEventHandler public boolean eventHandler(String in) { auditLog.info("lifecycle", "eventHandler"); + auditLog.info("message", in); return false; } } @@ -121,11 +137,17 @@ public boolean eventHandler(String in) { public static class MyLogRecord extends LogRecord { public int terminateCount; + public Map logMap = new HashMap<>(); public MyLogRecord() { super(null); } + @Override + public void addRecord(String sourceId, String propertyKey, CharSequence value) { + logMap.put(propertyKey, value.toString()); + } + @Override public boolean terminateRecord() { terminateCount++; diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java index c17d7774f..c87484cf2 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java @@ -2,7 +2,13 @@ import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest; import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; +import com.fluxtion.runtime.annotations.ExportFunction; import com.fluxtion.runtime.annotations.ExportService; +import com.fluxtion.runtime.annotations.OnTrigger; +import com.fluxtion.runtime.callback.ExportFunctionNode; +import com.fluxtion.runtime.node.NamedNode; +import org.junit.Assert; +import org.junit.Test; public class ExportedServiceTest extends MultipleSepTargetInProcessTest { @@ -10,11 +16,78 @@ public ExportedServiceTest(CompiledAndInterpretedSepTest.SepTestConfig testConfi super(testConfig); } + @Test + public void exportVoidReturn() { +// writeSourceFile = true; + sep(c -> { + c.addNode(new MyExportingServiceNode()); + c.addInterfaceImplementation(MyService.class); + }); + init(); + MyService mySvc = sep.asInterface(); + mySvc.testAdd(23, 50); + MyExportingServiceNode myNode = getField("myService"); + Assert.assertEquals(73, myNode.result); + } + + @Test + public void exportVoidAndAlwaysTrigger() { + sep(c -> { + c.addNode(new MyResultHolder()); + c.addInterfaceImplementation(MyService.class); + }); + init(); + MyService mySvc = sep.asInterface(); + MyResultHolder myResultHolder = getField("myResultHolder"); + mySvc.testAdd(23, 50); + MyExportingServiceNode myNode = getField("myService"); + Assert.assertEquals(73, myNode.result); + Assert.assertEquals(1, myResultHolder.triggerCount); + } + public interface MyService { + void testAdd(int a, int b); } - public static class MyExportingServiceNode implements @ExportService MyService { + public static class MyExportingServiceNode extends ExportFunctionNode implements @ExportService MyService, NamedNode { + int result; + + @ExportFunction + @Override + public void testAdd(int a, int b) { + result = a + b; + System.out.println("resilt:" + result); + } + + @Override + public String getName() { + return "myService"; + } + } + + public static class MyResultHolder implements NamedNode { + private final MyExportingServiceNode myExportingServiceNode; + private int triggerCount; + + public MyResultHolder() { + this(new MyExportingServiceNode()); + } + + public MyResultHolder(MyExportingServiceNode myExportingServiceNode) { + this.myExportingServiceNode = myExportingServiceNode; + } + + @OnTrigger + public boolean triggered() { + triggerCount++; + System.out.println("triggerCount:" + triggerCount); + return true; + } + @Override + public String getName() { + return "myResultHolder"; + } } } diff --git a/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java b/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java index 3b137a0f4..26dba8d57 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java +++ b/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java @@ -53,6 +53,7 @@ public class EventLogManager implements Auditor { private LogRecordListener sink; private LogRecord logRecord; private Map node2Logger; + private Map name2LogSourceMap; private boolean clearAfterPublish; private static final Logger LOGGER = Logger.getLogger(EventLogManager.class.getName()); public boolean trace = false; @@ -105,11 +106,22 @@ public void nodeRegistered(Object node, String nodeName) { if (node instanceof EventLogSource) { EventLogSource calcSource = (EventLogSource) node; calcSource.setLogger(logger); + name2LogSourceMap.put(nodeName, calcSource); } node2Logger.put(nodeName, logger); canTrace = trace && node2Logger.values().stream().filter(e -> e.canLog(traceLevel)).findAny().isPresent(); } + private void updateLogRecord() { + for (Map.Entry stringEventLogSourceEntry : name2LogSourceMap.entrySet()) { + String nodeName = stringEventLogSourceEntry.getKey(); + EventLogSource calcSource = stringEventLogSourceEntry.getValue(); + EventLogger logger = new EventLogger(logRecord, nodeName); + calcSource.setLogger(logger); + name2LogSourceMap.put(nodeName, calcSource); + } + } + @Override public boolean auditInvocations() { return trace; @@ -138,6 +150,7 @@ public void calculationLogConfig(EventLogControlEvent newConfig) { if (newConfig.getLogRecord() != null) { this.logRecord = newConfig.getLogRecord(); this.logRecord.setClock(clock); + updateLogRecord(); } final EventLogControlEvent.LogLevel level = newConfig.getLevel(); if (level != null @@ -202,6 +215,7 @@ public void init() { logRecord.printEventToString(printEventToString); logRecord.setPrintThreadName(printThreadName); node2Logger = new HashMap<>(); + name2LogSourceMap = new HashMap<>(); clearAfterPublish = true; } From 5b0ee643c37f4cf63fd141ceb1e2ffb21a45f506 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 09:04:42 +0000 Subject: [PATCH 089/228] updating poms for 9.0.19-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 2bfd77660..b0b12864f 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.18-SNAPSHOT + 9.0.19-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index b5e3d35d9..4135d9e26 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.18-SNAPSHOT + 9.0.19-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 64c1fbb15..0bebcfd7c 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.18-SNAPSHOT + 9.0.19-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 08955ca9b..a460b1234 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.18-SNAPSHOT + 9.0.19-SNAPSHOT ../parent-root/pom.xml From 8150e2bb118e0efde9cf66838ef28ff4cc88c934 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 09:04:52 +0000 Subject: [PATCH 090/228] updating poms for branch'release/9.0.18' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 2bfd77660..5fed39b0c 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.18-SNAPSHOT + 9.0.18 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index b5e3d35d9..cbd6dd892 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.18-SNAPSHOT + 9.0.18 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 64c1fbb15..7fa7a5e48 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.18-SNAPSHOT + 9.0.18 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 08955ca9b..d2d372768 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.18-SNAPSHOT + 9.0.18 ../parent-root/pom.xml From b93c15d564b997bc4c7fd6448217703aff1a9af7 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 09:08:33 +0000 Subject: [PATCH 091/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index b0b12864f..5fed39b0c 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.19-SNAPSHOT + 9.0.18 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 4135d9e26..cbd6dd892 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.19-SNAPSHOT + 9.0.18 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 0bebcfd7c..7fa7a5e48 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.19-SNAPSHOT + 9.0.18 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index a460b1234..d2d372768 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.19-SNAPSHOT + 9.0.18 ../parent-root/pom.xml From 796227e110bd6d82f7a5bdc81c20437598b2897a Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 09:08:33 +0000 Subject: [PATCH 092/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 5fed39b0c..b0b12864f 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.18 + 9.0.19-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index cbd6dd892..4135d9e26 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.18 + 9.0.19-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 7fa7a5e48..0bebcfd7c 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.18 + 9.0.19-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index d2d372768..a460b1234 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.18 + 9.0.19-SNAPSHOT ../parent-root/pom.xml From 0b2e014f0b72c13f90feebee436ca64eec9c7802 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 17 Jul 2023 10:49:38 +0100 Subject: [PATCH 093/228] replace logRecord for all registered EventSource nodes, after log level changes dynamically --- .../generation/audit/LifecycleAuditTest.java | 20 +++++++++++++++---- .../runtime/audit/EventLogManager.java | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java index 9dd301e06..a8eddf827 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/audit/LifecycleAuditTest.java @@ -3,6 +3,7 @@ import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; import com.fluxtion.runtime.annotations.*; +import com.fluxtion.runtime.audit.EventLogControlEvent; import com.fluxtion.runtime.audit.EventLogNode; import com.fluxtion.runtime.audit.LogRecord; import org.junit.Assert; @@ -57,17 +58,27 @@ public void replaceLogRecord() { onEvent("test2"); Assert.assertEquals("eventHandler", myLogRecord.logMap.get("lifecycle")); Assert.assertEquals("test2", myLogRecord.logMap.get("message")); + Assert.assertNull(myLogRecord.logMap.get("debugMessage")); Assert.assertEquals(4, myLogRecord.getTerminateCount()); + sep.setAuditLogLevel(EventLogControlEvent.LogLevel.DEBUG); + Assert.assertEquals(5, myLogRecord.getTerminateCount()); + + onEvent("testDebug"); + Assert.assertEquals("eventHandler", myLogRecord.logMap.get("lifecycle")); + Assert.assertEquals("testDebug", myLogRecord.logMap.get("message")); + Assert.assertEquals("testDebug", myLogRecord.logMap.get("debugMessage")); + Assert.assertEquals(6, myLogRecord.getTerminateCount()); + stop(); Assert.assertEquals("stop", myLogRecord.logMap.get("lifecycle")); - Assert.assertEquals("test2", myLogRecord.logMap.get("message")); - Assert.assertEquals(5, myLogRecord.getTerminateCount()); + Assert.assertEquals("testDebug", myLogRecord.logMap.get("message")); + Assert.assertEquals(7, myLogRecord.getTerminateCount()); tearDown(); Assert.assertEquals("teardown", myLogRecord.logMap.get("lifecycle")); - Assert.assertEquals("test2", myLogRecord.logMap.get("message")); - Assert.assertEquals(6, myLogRecord.getTerminateCount()); + Assert.assertEquals("testDebug", myLogRecord.logMap.get("message")); + Assert.assertEquals(8, myLogRecord.getTerminateCount()); } public static class Parent extends EventLogNode { @@ -95,6 +106,7 @@ public void teardown() { public boolean eventHandler(String in) { auditLog.info("lifecycle", "eventHandler"); auditLog.info("message", in); + auditLog.debug("debugMessage", in); return false; } } diff --git a/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java b/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java index 26dba8d57..fd786d23c 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java +++ b/runtime/src/main/java/com/fluxtion/runtime/audit/EventLogManager.java @@ -119,6 +119,7 @@ private void updateLogRecord() { EventLogger logger = new EventLogger(logRecord, nodeName); calcSource.setLogger(logger); name2LogSourceMap.put(nodeName, calcSource); + node2Logger.put(nodeName, logger); } } From ca363c96ba3acac3c5886d0b11f5ef567ccfdbf1 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 10:19:11 +0000 Subject: [PATCH 094/228] updating poms for 9.0.20-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index b0b12864f..08119c625 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.19-SNAPSHOT + 9.0.20-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 4135d9e26..2e2d9bdf5 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.19-SNAPSHOT + 9.0.20-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 0bebcfd7c..31307dcdf 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.19-SNAPSHOT + 9.0.20-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index a460b1234..802d57d5d 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.19-SNAPSHOT + 9.0.20-SNAPSHOT ../parent-root/pom.xml From 80ca254c192652e19f7b73fa14e616743863bc04 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 10:19:18 +0000 Subject: [PATCH 095/228] updating poms for branch'release/9.0.19' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index b0b12864f..9148c13cc 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.19-SNAPSHOT + 9.0.19 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 4135d9e26..61cc88c86 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.19-SNAPSHOT + 9.0.19 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 0bebcfd7c..603906e43 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.19-SNAPSHOT + 9.0.19 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index a460b1234..f540b434c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.19-SNAPSHOT + 9.0.19 ../parent-root/pom.xml From e2ed8aae7a33ad234c0096dbee75a9359384a79c Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 10:22:50 +0000 Subject: [PATCH 096/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 08119c625..9148c13cc 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.20-SNAPSHOT + 9.0.19 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2e2d9bdf5..61cc88c86 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.20-SNAPSHOT + 9.0.19 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 31307dcdf..603906e43 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.20-SNAPSHOT + 9.0.19 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 802d57d5d..f540b434c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.20-SNAPSHOT + 9.0.19 ../parent-root/pom.xml From baa140ade35698da8e4e7eea08a1ea096f71bbbe Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 10:22:50 +0000 Subject: [PATCH 097/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 9148c13cc..08119c625 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.19 + 9.0.20-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 61cc88c86..2e2d9bdf5 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.19 + 9.0.20-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 603906e43..31307dcdf 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.19 + 9.0.20-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index f540b434c..802d57d5d 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.19 + 9.0.20-SNAPSHOT ../parent-root/pom.xml From f10cc6f6bccc00aabc002faa6983c3352c891041 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 17 Jul 2023 15:24:21 +0100 Subject: [PATCH 098/228] tests for logrecord --- .../generation/model/ExportFunctionData.java | 19 ++ .../TopologicallySortedDependencyGraph.java | 60 +++---- .../compiler/generation/util/ClassUtils.java | 9 +- .../ExportedFunctionVoidReturnTest.java | 92 ++++++++++ .../ExportMultipleServiceTest.java | 163 ++++++++++++++++++ .../exportservice/ExportedServiceTest.java | 113 ++++++++++-- 6 files changed, 406 insertions(+), 50 deletions(-) create mode 100644 compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportedFunctionVoidReturnTest.java create mode 100644 compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportMultipleServiceTest.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/model/ExportFunctionData.java b/compiler/src/main/java/com/fluxtion/compiler/generation/model/ExportFunctionData.java index 5bdf864c9..fb76cef6b 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/model/ExportFunctionData.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/model/ExportFunctionData.java @@ -10,6 +10,7 @@ public class ExportFunctionData { private final String publicMethodName; private final ExportFunctionTrigger exportFunctionTrigger = new ExportFunctionTrigger(); private final List functionCallBackList = new ArrayList<>(); + private boolean exportedInterface = false; public ExportFunctionData(String publicMethodName) { this.publicMethodName = publicMethodName; @@ -31,4 +32,22 @@ public void addCbMethodHandle(CbMethodHandle cbMethodHandle) { functionCallBackList.add(cbMethodHandle); exportFunctionTrigger.getFunctionPointerList().add(cbMethodHandle.getInstance()); } + + public boolean isBooleanReturn() { + for (int i = 0, functionCallBackListSize = functionCallBackList.size(); i < functionCallBackListSize; i++) { + CbMethodHandle cbMethodHandle = functionCallBackList.get(i); + if (cbMethodHandle.getMethod().getReturnType() == boolean.class) { + return true; + } + } + return false; + } + + public void setExportedInterface(boolean exportedInterface) { + this.exportedInterface = exportedInterface; + } + + public boolean isExportedInterface() { + return exportedInterface; + } } diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java b/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java index 8f070999b..f7b107d11 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java @@ -27,24 +27,8 @@ import com.fluxtion.compiler.generation.GenerationContext; import com.fluxtion.compiler.generation.exporter.JgraphGraphMLExporter; import com.fluxtion.compiler.generation.util.NaturalOrderComparator; -import com.fluxtion.runtime.annotations.AfterEvent; -import com.fluxtion.runtime.annotations.AfterTrigger; -import com.fluxtion.runtime.annotations.ExportFunction; -import com.fluxtion.runtime.annotations.Initialise; -import com.fluxtion.runtime.annotations.NoTriggerReference; -import com.fluxtion.runtime.annotations.OnBatchEnd; -import com.fluxtion.runtime.annotations.OnBatchPause; -import com.fluxtion.runtime.annotations.OnEventHandler; -import com.fluxtion.runtime.annotations.OnParentUpdate; -import com.fluxtion.runtime.annotations.OnTrigger; -import com.fluxtion.runtime.annotations.PushReference; -import com.fluxtion.runtime.annotations.TearDown; -import com.fluxtion.runtime.annotations.TriggerEventOverride; -import com.fluxtion.runtime.annotations.builder.Config; -import com.fluxtion.runtime.annotations.builder.ConfigVariable; -import com.fluxtion.runtime.annotations.builder.ExcludeNode; -import com.fluxtion.runtime.annotations.builder.Inject; -import com.fluxtion.runtime.annotations.builder.SepNode; +import com.fluxtion.runtime.annotations.*; +import com.fluxtion.runtime.annotations.builder.*; import com.fluxtion.runtime.audit.Auditor; import com.fluxtion.runtime.event.Event; import com.fluxtion.runtime.node.Anchor; @@ -69,24 +53,9 @@ import javax.xml.transform.TransformerConfigurationException; import java.io.Writer; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Array; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import java.lang.reflect.*; +import java.util.*; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -773,6 +742,27 @@ private void addExportedMethods(Object object) { exportFunctionData.getExportFunctionTrigger().getFunctionPointerList().add(object); exportFunctionData.addCbMethodHandle(new CbMethodHandle(method, object, name)); }); + //now find the methods for an interface + for (AnnotatedType annotatedInterface : clazz.getAnnotatedInterfaces()) { + if (annotatedInterface.isAnnotationPresent(ExportService.class)) { + Class interfaceType = (Class) annotatedInterface.getType(); + config.addInterfaceImplementation(interfaceType); + for (Method method : interfaceType.getMethods()) { + String exportMethodName = method.getName(); + ExportFunctionData exportFunctionData = exportedFunctionMap.computeIfAbsent( + exportMethodName, n -> { + ExportFunctionData data = new ExportFunctionData(exportMethodName); + registerNode(data.getExportFunctionTrigger(), null); + return data; + }); + final String name = inst2Name.get(object); + exportFunctionData.getExportFunctionTrigger().getFunctionPointerList().add(object); + exportFunctionData.addCbMethodHandle(new CbMethodHandle(method, object, name)); + exportFunctionData.setExportedInterface(true); + } + } + } + } @SuppressWarnings("unchecked") diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java index 5d400c195..3ec108a10 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java @@ -206,7 +206,8 @@ static String wrapExportedFunctionCall(String exportedMethodName, ExportFunction LongAdder argNumber = new LongAdder(); List callBackList = exportFunctionData.getFunctionCallBackList(); Method delegateMethod = callBackList.get(0).getMethod(); - StringBuilder signature = new StringBuilder("public void " + exportedMethodName); + boolean booleanReturn = exportFunctionData.isBooleanReturn() && exportFunctionData.isExportedInterface(); + StringBuilder signature = booleanReturn ? new StringBuilder("public boolean " + exportedMethodName) : new StringBuilder("public void " + exportedMethodName); signature.append('('); StringJoiner sj = new StringJoiner(", "); Type[] params = delegateMethod.getGenericParameterTypes(); @@ -249,7 +250,6 @@ static String wrapExportedFunctionCall(String exportedMethodName, ExportFunction } }); //close - //onEvent(handlerExportFunctionTriggerEvent_0.getEvent()); ExportFunctionTrigger exportFunctionTrigger = exportFunctionData.getExportFunctionTrigger(); if (onEventDispatch) { signature.append("onEvent(") @@ -261,7 +261,10 @@ static String wrapExportedFunctionCall(String exportedMethodName, ExportFunction ; } if (!onEventDispatch) { - signature.append(" processing = false;"); + signature.append(" processing = false;\n"); + } + if (booleanReturn) { + signature.append(" return true;\n"); } signature.append("}"); return signature.toString(); diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportedFunctionVoidReturnTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportedFunctionVoidReturnTest.java new file mode 100644 index 000000000..b72870fa4 --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportedFunctionVoidReturnTest.java @@ -0,0 +1,92 @@ +package com.fluxtion.compiler.generation.exportfunction; + +import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest; +import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; +import com.fluxtion.runtime.annotations.ExportFunction; +import com.fluxtion.runtime.annotations.ExportService; +import com.fluxtion.runtime.annotations.OnTrigger; +import com.fluxtion.runtime.callback.ExportFunctionNode; +import com.fluxtion.runtime.node.NamedNode; +import org.junit.Assert; +import org.junit.Test; + +public class ExportedFunctionVoidReturnTest extends MultipleSepTargetInProcessTest { + + public ExportedFunctionVoidReturnTest(CompiledAndInterpretedSepTest.SepTestConfig testConfig) { + super(testConfig); + } + + @Test + public void exportVoidReturn() { +// writeSourceFile = true; + sep(c -> { + c.addNode(new MyExportingServiceNode()); + c.addInterfaceImplementation(MyService.class); + }); + init(); + MyService mySvc = sep.asInterface(); + mySvc.testAdd(23, 50); + MyExportingServiceNode myNode = getField("myService"); + Assert.assertEquals(73, myNode.result); + } + + @Test + public void exportVoidAndAlwaysTrigger() { +// writeSourceFile = true; + sep(c -> { + c.addNode(new MyResultHolder()); + c.addInterfaceImplementation(MyService.class); + }); + init(); + MyService mySvc = sep.asInterface(); + MyResultHolder myResultHolder = getField("myResultHolder"); + mySvc.testAdd(23, 50); + MyExportingServiceNode myNode = getField("myService"); + Assert.assertEquals(73, myNode.result); + Assert.assertEquals(1, myResultHolder.triggerCount); + } + + public interface MyService { + + void testAdd(int a, int b); + } + + public static class MyExportingServiceNode extends ExportFunctionNode implements @ExportService MyService, NamedNode { + int result; + + @ExportFunction + @Override + public void testAdd(int a, int b) { + result = a + b; + } + + @Override + public String getName() { + return "myService"; + } + } + + public static class MyResultHolder implements NamedNode { + private final MyExportingServiceNode myExportingServiceNode; + private int triggerCount; + + public MyResultHolder() { + this(new MyExportingServiceNode()); + } + + public MyResultHolder(MyExportingServiceNode myExportingServiceNode) { + this.myExportingServiceNode = myExportingServiceNode; + } + + @OnTrigger + public boolean triggered() { + triggerCount++; + return true; + } + + @Override + public String getName() { + return "myResultHolder"; + } + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportMultipleServiceTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportMultipleServiceTest.java new file mode 100644 index 000000000..20a74965e --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportMultipleServiceTest.java @@ -0,0 +1,163 @@ +package com.fluxtion.compiler.generation.exportservice; + +import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest; +import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; +import com.fluxtion.runtime.annotations.ExportService; +import com.fluxtion.runtime.annotations.OnParentUpdate; +import com.fluxtion.runtime.annotations.OnTrigger; +import com.fluxtion.runtime.callback.ExportFunctionNode; +import com.fluxtion.runtime.node.NamedNode; +import org.junit.Assert; +import org.junit.Test; + +public class ExportMultipleServiceTest extends MultipleSepTargetInProcessTest { + + + public ExportMultipleServiceTest(CompiledAndInterpretedSepTest.SepTestConfig testConfig) { + super(testConfig); + } + + @Test + public void multiServiceExportTest() { +// writeSourceFile = true; + sep(new BottomNode()); + //services + Top top = sep.asInterface(); + Middle middle = sep.asInterface(); + Bottom bottom = sep.asInterface(); + //nodes + TopNode topNode = getField("top"); + MiddleNode middleNode = getField("middle"); + BottomNode bottomNode = getField("bottom"); + // + top.notifyTop(10); + Assert.assertEquals(1, topNode.functionCount); + Assert.assertEquals(0, middleNode.functionCount); + Assert.assertEquals(1, middleNode.triggerCount); + Assert.assertEquals(0, bottomNode.functionCount); + Assert.assertEquals(1, bottomNode.triggerCount); + + // + bottom.notifyBottom(10); + Assert.assertEquals(1, topNode.functionCount); + Assert.assertEquals(0, middleNode.functionCount); + Assert.assertEquals(1, middleNode.triggerCount); + Assert.assertEquals(1, bottomNode.functionCount); + Assert.assertEquals(2, bottomNode.triggerCount); + + //no trigger bottom + middle.notifyMiddle(-10); + Assert.assertEquals(1, topNode.functionCount); + Assert.assertEquals(1, middleNode.functionCount); + Assert.assertEquals(2, middleNode.triggerCount);//? + Assert.assertEquals(1, bottomNode.functionCount); + Assert.assertEquals(2, bottomNode.triggerCount); + + //trigger middle + middle.notifyMiddle(10); + Assert.assertEquals(1, topNode.functionCount); + Assert.assertEquals(2, middleNode.functionCount); + Assert.assertEquals(3, middleNode.triggerCount); + Assert.assertEquals(1, bottomNode.functionCount); + Assert.assertEquals(3, bottomNode.triggerCount); + } + + public interface Top { + void notifyTop(int arg); + } + + public interface Middle { + boolean notifyMiddle(int arg); + } + + public interface Bottom { + boolean notifyBottom(int arg); + } + + public static class TopNode extends ExportFunctionNode implements @ExportService Top, NamedNode { + + int functionCount = 0; + + @Override + public void notifyTop(int arg) { + functionCount++; + } + + @Override + public String getName() { + return "top"; + } + } + + public static class MiddleNode extends ExportFunctionNode implements @ExportService Middle, NamedNode { + private final TopNode topNode; + int triggerCount = 0; + int functionCount = 0; + private boolean parentTriggered; + + public MiddleNode(TopNode topNode) { + this.topNode = topNode; + } + + public MiddleNode() { + this(new TopNode()); + } + + @OnParentUpdate + public void topUpdated(TopNode topNode) { + parentTriggered = true; + } + + @Override + public boolean notifyMiddle(int arg) { + functionCount++; + return arg > 0; + } + + @OnTrigger + public boolean triggered() { + triggerCount++; + boolean tmp = parentTriggered; + parentTriggered = false; + return tmp || isTriggered(); + } + + @Override + public String getName() { + return "middle"; + } + } + + public static class BottomNode extends ExportFunctionNode implements @ExportService Bottom, NamedNode { + + private final MiddleNode middleNode; + int triggerCount = 0; + int functionCount = 0; + + public BottomNode(MiddleNode middleNode) { + this.middleNode = middleNode; + } + + public BottomNode() { + this(new MiddleNode()); + } + + @Override + public boolean notifyBottom(int arg) { + functionCount++; + return false; + } + + @OnTrigger + public boolean triggered() { + triggerCount++; + return isTriggered(); + } + + @Override + public String getName() { + return "bottom"; + } + } + +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java index c87484cf2..bac617bba 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java @@ -2,7 +2,6 @@ import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest; import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; -import com.fluxtion.runtime.annotations.ExportFunction; import com.fluxtion.runtime.annotations.ExportService; import com.fluxtion.runtime.annotations.OnTrigger; import com.fluxtion.runtime.callback.ExportFunctionNode; @@ -19,10 +18,7 @@ public ExportedServiceTest(CompiledAndInterpretedSepTest.SepTestConfig testConfi @Test public void exportVoidReturn() { // writeSourceFile = true; - sep(c -> { - c.addNode(new MyExportingServiceNode()); - c.addInterfaceImplementation(MyService.class); - }); + sep(new MyExportingServiceNode()); init(); MyService mySvc = sep.asInterface(); mySvc.testAdd(23, 50); @@ -30,12 +26,21 @@ public void exportVoidReturn() { Assert.assertEquals(73, myNode.result); } + @Test + public void exportBooleanReturn() { +// writeSourceFile = true; + sep(new MyExportingTriggerServiceNode()); + init(); + MyTriggeringService mySvc = sep.asInterface(); + mySvc.testAdd(23, 50); + MyExportingTriggerServiceNode myNode = getField("myService"); + Assert.assertEquals(73, myNode.result); + } + @Test public void exportVoidAndAlwaysTrigger() { - sep(c -> { - c.addNode(new MyResultHolder()); - c.addInterfaceImplementation(MyService.class); - }); +// writeSourceFile = true; + sep(new MyResultHolder()); init(); MyService mySvc = sep.asInterface(); MyResultHolder myResultHolder = getField("myResultHolder"); @@ -43,21 +48,58 @@ public void exportVoidAndAlwaysTrigger() { MyExportingServiceNode myNode = getField("myService"); Assert.assertEquals(73, myNode.result); Assert.assertEquals(1, myResultHolder.triggerCount); + + mySvc.testSubtract(23, 8); + Assert.assertEquals(15, myNode.result); + Assert.assertEquals(2, myResultHolder.triggerCount); + } + + @Test + public void exportBooleanTriggerWhenPositive() { +// writeSourceFile = true; + sep(new MyResultHolderTrigger()); + init(); + MyTriggeringService mySvc = sep.asInterface(); + MyResultHolderTrigger myResultHolder = getField("myResultHolder"); + mySvc.testAdd(23, 50); + MyExportingTriggerServiceNode myNode = getField("myService"); + Assert.assertEquals(73, myNode.result); + Assert.assertEquals(1, myResultHolder.triggerCount); + + mySvc.testSubtract(23, 8); + Assert.assertEquals(15, myNode.result); + Assert.assertEquals(2, myResultHolder.triggerCount); + + mySvc.triggerPositive(10); + Assert.assertEquals(3, myResultHolder.triggerCount); + + mySvc.triggerPositive(-10); + Assert.assertEquals(3, myResultHolder.triggerCount); + } + + public interface MyTriggeringService extends MyService { + boolean triggerPositive(int x); + } public interface MyService { void testAdd(int a, int b); + + void testSubtract(int a, int b); } public static class MyExportingServiceNode extends ExportFunctionNode implements @ExportService MyService, NamedNode { int result; - @ExportFunction @Override public void testAdd(int a, int b) { result = a + b; - System.out.println("resilt:" + result); + } + + @Override + public void testSubtract(int a, int b) { + result = a - b; } @Override @@ -66,6 +108,30 @@ public String getName() { } } + public static class MyExportingTriggerServiceNode extends ExportFunctionNode implements @ExportService MyTriggeringService, NamedNode { + int result; + + @Override + public void testAdd(int a, int b) { + result = a + b; + } + + @Override + public void testSubtract(int a, int b) { + result = a - b; + } + + @Override + public String getName() { + return "myService"; + } + + @Override + public boolean triggerPositive(int x) { + return x > 0; + } + } + public static class MyResultHolder implements NamedNode { private final MyExportingServiceNode myExportingServiceNode; private int triggerCount; @@ -81,7 +147,30 @@ public MyResultHolder(MyExportingServiceNode myExportingServiceNode) { @OnTrigger public boolean triggered() { triggerCount++; - System.out.println("triggerCount:" + triggerCount); + return true; + } + + @Override + public String getName() { + return "myResultHolder"; + } + } + + public static class MyResultHolderTrigger implements NamedNode { + private final MyExportingTriggerServiceNode myExportingServiceNode; + private int triggerCount; + + public MyResultHolderTrigger() { + this(new MyExportingTriggerServiceNode()); + } + + public MyResultHolderTrigger(MyExportingTriggerServiceNode myExportingServiceNode) { + this.myExportingServiceNode = myExportingServiceNode; + } + + @OnTrigger + public boolean triggered() { + triggerCount++; return true; } From bf3c37ee3dfe9ae5374754bd64b7847f4274b8bb Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 14:36:33 +0000 Subject: [PATCH 099/228] updating poms for 9.0.21-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 08119c625..821c0e781 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.20-SNAPSHOT + 9.0.21-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2e2d9bdf5..769334514 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.20-SNAPSHOT + 9.0.21-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 31307dcdf..3384598fe 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.20-SNAPSHOT + 9.0.21-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 802d57d5d..fe9a5648f 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.20-SNAPSHOT + 9.0.21-SNAPSHOT ../parent-root/pom.xml From 09864e715a483e5f75eba21a7839b52508ed440c Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 14:36:43 +0000 Subject: [PATCH 100/228] updating poms for branch'release/9.0.20' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 08119c625..2229a90f8 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.20-SNAPSHOT + 9.0.20 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2e2d9bdf5..720e372f1 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.20-SNAPSHOT + 9.0.20 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 31307dcdf..8b311b39a 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.20-SNAPSHOT + 9.0.20 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 802d57d5d..6f6423c2a 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.20-SNAPSHOT + 9.0.20 ../parent-root/pom.xml From bb0ff6e9e452326215987aee7e733812a75f0b40 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 14:41:38 +0000 Subject: [PATCH 101/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 821c0e781..2229a90f8 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.21-SNAPSHOT + 9.0.20 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 769334514..720e372f1 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.21-SNAPSHOT + 9.0.20 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 3384598fe..8b311b39a 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.21-SNAPSHOT + 9.0.20 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fe9a5648f..6f6423c2a 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.21-SNAPSHOT + 9.0.20 ../parent-root/pom.xml From a6085260b359907c42b5f28a87f16ee35b111cce Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 17 Jul 2023 14:41:38 +0000 Subject: [PATCH 102/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 2229a90f8..821c0e781 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.20 + 9.0.21-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 720e372f1..769334514 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.20 + 9.0.21-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 8b311b39a..3384598fe 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.20 + 9.0.21-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 6f6423c2a..fe9a5648f 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.20 + 9.0.21-SNAPSHOT ../parent-root/pom.xml From 23f9d4330911c3970bf7a68a3d0bc9f60f390a71 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 18 Jul 2023 18:46:35 +0100 Subject: [PATCH 103/228] add factory for sink publisher. --- .../fluxtion/compiler/EventProcessorConfig.java | 4 +++- .../context/InstanceSupplierFactory.java | 4 +++- .../builder/output/SinkPublisherFactory.java | 17 +++++++++++++++++ .../generation/inject/InjectFromContext.java | 1 + .../fluxtion/runtime/output/SinkPublisher.java | 14 ++++++-------- 5 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 compiler/src/main/java/com/fluxtion/compiler/builder/output/SinkPublisherFactory.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java b/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java index 1bd35004c..c5544d88a 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java +++ b/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java @@ -22,6 +22,7 @@ import com.fluxtion.compiler.builder.factory.*; import com.fluxtion.compiler.builder.filter.EventHandlerFilterOverride; import com.fluxtion.compiler.builder.input.SubscriptionManagerFactory; +import com.fluxtion.compiler.builder.output.SinkPublisherFactory; import com.fluxtion.compiler.builder.time.ClockFactory; import com.fluxtion.compiler.generation.serialiser.*; import com.fluxtion.runtime.audit.Auditor; @@ -499,7 +500,8 @@ enum NodeFactoryConfig { EventProcessorCallbackInternalFactory.class, EventProcessorContextFactory.class, NodeNameLookupFactory.class, - SubscriptionManagerFactory.class + SubscriptionManagerFactory.class, + SinkPublisherFactory.class ); private final HashSet>> defaultFactories = new HashSet<>(); diff --git a/compiler/src/main/java/com/fluxtion/compiler/builder/context/InstanceSupplierFactory.java b/compiler/src/main/java/com/fluxtion/compiler/builder/context/InstanceSupplierFactory.java index bbcef24f1..8f67fa05b 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/builder/context/InstanceSupplierFactory.java +++ b/compiler/src/main/java/com/fluxtion/compiler/builder/context/InstanceSupplierFactory.java @@ -3,6 +3,7 @@ import com.fluxtion.compiler.builder.factory.NodeFactory; import com.fluxtion.compiler.builder.factory.NodeRegistry; import com.fluxtion.compiler.generation.GenerationContext; +import com.fluxtion.runtime.EventProcessorContext; import com.fluxtion.runtime.audit.Auditor; import com.fluxtion.runtime.node.InstanceSupplier; import com.fluxtion.runtime.node.InstanceSupplierNode; @@ -35,10 +36,11 @@ public InstanceSupplier createNode(Map config, NodeRegistry r rawType = Object.class; } final String typeName = "contextService_" + rawType.getSimpleName() + "_" + instanceName + count++; + return new InstanceSupplierNode<>( hasInstanceQualifier ? rawType.getCanonicalName() + "_" + instanceName : rawType.getCanonicalName(), true, - null, + registry.findOrCreateNode(EventProcessorContext.class, config, null), typeName.replace(".", "_")); } diff --git a/compiler/src/main/java/com/fluxtion/compiler/builder/output/SinkPublisherFactory.java b/compiler/src/main/java/com/fluxtion/compiler/builder/output/SinkPublisherFactory.java new file mode 100644 index 000000000..e2cbea5ed --- /dev/null +++ b/compiler/src/main/java/com/fluxtion/compiler/builder/output/SinkPublisherFactory.java @@ -0,0 +1,17 @@ +package com.fluxtion.compiler.builder.output; + +import com.fluxtion.compiler.builder.factory.NodeFactory; +import com.fluxtion.compiler.builder.factory.NodeRegistry; +import com.fluxtion.runtime.output.SinkPublisher; + +import java.util.Map; + +public class SinkPublisherFactory implements NodeFactory { + + @Override + public SinkPublisher createNode(Map config, NodeRegistry registry) { + final String instanceName = (String) config.get(NodeFactory.INSTANCE_KEY); + return new SinkPublisher<>(instanceName); + } + +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/inject/InjectFromContext.java b/compiler/src/test/java/com/fluxtion/compiler/generation/inject/InjectFromContext.java index 1a9e9b268..d7ed663ce 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/inject/InjectFromContext.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/inject/InjectFromContext.java @@ -105,6 +105,7 @@ public void addLambdaAsInjectedService() { @Test public void addNamedLambda() { +// writeSourceFile = true; enableInitCheck(false); sep(c -> { c.addNode(new InjectNamedInterfaceType(), "injectionHolder"); diff --git a/runtime/src/main/java/com/fluxtion/runtime/output/SinkPublisher.java b/runtime/src/main/java/com/fluxtion/runtime/output/SinkPublisher.java index c1d124bf1..00dfa56b4 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/output/SinkPublisher.java +++ b/runtime/src/main/java/com/fluxtion/runtime/output/SinkPublisher.java @@ -1,16 +1,17 @@ package com.fluxtion.runtime.output; import com.fluxtion.runtime.annotations.OnEventHandler; -import com.fluxtion.runtime.node.NamedNode; +import com.fluxtion.runtime.annotations.builder.AssignToField; +import com.fluxtion.runtime.node.SingleNamedNode; import java.util.function.Consumer; import java.util.function.DoubleConsumer; import java.util.function.IntConsumer; import java.util.function.LongConsumer; -public class SinkPublisher implements NamedNode { +public class SinkPublisher extends SingleNamedNode { - private final String filterString; + private transient final String filterString; private Consumer sink; private IntConsumer intConsumer; @@ -18,7 +19,8 @@ public class SinkPublisher implements NamedNode { private DoubleConsumer doubleConsumer; - public SinkPublisher(String filterString) { + public SinkPublisher(@AssignToField("name") String filterString) { + super(filterString); this.filterString = filterString; } @@ -58,8 +60,4 @@ public void publishLong(long value) { longConsumer.accept(value); } - @Override - public String getName() { - return filterString + "_Sink"; - } } From 27fbf2a9054794681de717d6883887b309d172fe Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 18 Jul 2023 18:40:16 +0000 Subject: [PATCH 104/228] updating poms for 9.0.22-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 821c0e781..4e2767ddf 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.21-SNAPSHOT + 9.0.22-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 769334514..64d177243 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.21-SNAPSHOT + 9.0.22-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 3384598fe..dad7a5d11 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.21-SNAPSHOT + 9.0.22-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fe9a5648f..fa1bf1a18 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.21-SNAPSHOT + 9.0.22-SNAPSHOT ../parent-root/pom.xml From c4751f7c0aff3cc3e0157dd3c26d608197db3e55 Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 18 Jul 2023 18:40:26 +0000 Subject: [PATCH 105/228] updating poms for branch'release/9.0.21' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 821c0e781..6c47036b1 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.21-SNAPSHOT + 9.0.21 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 769334514..befb2b9fe 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.21-SNAPSHOT + 9.0.21 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 3384598fe..b1d9686e6 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.21-SNAPSHOT + 9.0.21 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fe9a5648f..e5bfbb97f 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.21-SNAPSHOT + 9.0.21 ../parent-root/pom.xml From ade1f2d2871323d074322255f6966622a92c7146 Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 18 Jul 2023 18:44:19 +0000 Subject: [PATCH 106/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 4e2767ddf..6c47036b1 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.22-SNAPSHOT + 9.0.21 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 64d177243..befb2b9fe 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.22-SNAPSHOT + 9.0.21 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index dad7a5d11..b1d9686e6 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.22-SNAPSHOT + 9.0.21 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fa1bf1a18..e5bfbb97f 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.22-SNAPSHOT + 9.0.21 ../parent-root/pom.xml From d5084416a7112abf547269f36b9b7f7f451003dc Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 18 Jul 2023 18:44:19 +0000 Subject: [PATCH 107/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 6c47036b1..4e2767ddf 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.21 + 9.0.22-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index befb2b9fe..64d177243 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.21 + 9.0.22-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index b1d9686e6..dad7a5d11 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.21 + 9.0.22-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index e5bfbb97f..fa1bf1a18 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.21 + 9.0.22-SNAPSHOT ../parent-root/pom.xml From cb066a6866e0bf790f1049bd51b90e1a57243f5b Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 18 Jul 2023 22:57:28 +0100 Subject: [PATCH 108/228] support no propagation annotation on exported functions --- .../generation/model/CbMethodHandle.java | 12 +++++--- .../TopologicallySortedDependencyGraph.java | 5 ++++ .../compiler/generation/util/ClassUtils.java | 5 +++- .../exportfunction/ExportFunctionTest.java | 30 +++++++++++++++++++ .../annotations/NoPropagateFunction.java | 18 +++++++++++ 5 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 runtime/src/main/java/com/fluxtion/runtime/annotations/NoPropagateFunction.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/model/CbMethodHandle.java b/compiler/src/main/java/com/fluxtion/compiler/generation/model/CbMethodHandle.java index e6a94ced6..f4e5d0234 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/model/CbMethodHandle.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/model/CbMethodHandle.java @@ -17,10 +17,7 @@ */ package com.fluxtion.compiler.generation.model; -import com.fluxtion.runtime.annotations.AfterTrigger; -import com.fluxtion.runtime.annotations.OnEventHandler; -import com.fluxtion.runtime.annotations.OnParentUpdate; -import com.fluxtion.runtime.annotations.OnTrigger; +import com.fluxtion.runtime.annotations.*; import com.fluxtion.runtime.dataflow.ParallelFunction; import java.lang.reflect.Method; @@ -64,6 +61,7 @@ public class CbMethodHandle { private final boolean isNoPropagateEventHandler; private final boolean failBuildOnUnguardedTrigger; private final boolean forkExecution; + private final boolean isNoPropagateFunction; public CbMethodHandle(Method method, Object instance, String variableName) { this(method, instance, variableName, null, false); @@ -79,12 +77,14 @@ public CbMethodHandle(Method method, Object instance, String variableName, Class OnTrigger onTriggerAnnotation = method.getAnnotation(OnTrigger.class); OnParentUpdate onParentUpdateAnnotation = method.getAnnotation(OnParentUpdate.class); OnEventHandler onEventHandlerAnnotation = method.getAnnotation(OnEventHandler.class); + NoPropagateFunction noPropagateFunction = method.getAnnotation(NoPropagateFunction.class); this.isInvertedDirtyHandler = onTriggerAnnotation != null && !onTriggerAnnotation.dirty(); boolean parallel = (instance instanceof ParallelFunction) ? ((ParallelFunction) instance).parallelCandidate() : false; this.forkExecution = parallel || onTriggerAnnotation != null && onTriggerAnnotation.parallelExecution(); this.failBuildOnUnguardedTrigger = onTriggerAnnotation != null && onTriggerAnnotation.failBuildIfNotGuarded(); this.isGuardedParent = onParentUpdateAnnotation != null && onParentUpdateAnnotation.guarded(); this.isNoPropagateEventHandler = onEventHandlerAnnotation != null && !onEventHandlerAnnotation.propagate(); + this.isNoPropagateFunction = noPropagateFunction != null; } public Method getMethod() { @@ -127,6 +127,10 @@ public boolean isForkExecution() { return forkExecution; } + public boolean isNoPropagateFunction() { + return isNoPropagateFunction; + } + public String getMethodTarget() { if (Modifier.isStatic(getMethod().getModifiers())) { return instance.getClass().getSimpleName(); diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java b/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java index f7b107d11..420a3d58b 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/model/TopologicallySortedDependencyGraph.java @@ -749,6 +749,11 @@ private void addExportedMethods(Object object) { config.addInterfaceImplementation(interfaceType); for (Method method : interfaceType.getMethods()) { String exportMethodName = method.getName(); + try { + method = object.getClass().getMethod(exportMethodName, method.getParameterTypes()); + } catch (NoSuchMethodException e) { + + } ExportFunctionData exportFunctionData = exportedFunctionMap.computeIfAbsent( exportMethodName, n -> { ExportFunctionData data = new ExportFunctionData(exportMethodName); diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java index 3ec108a10..39b63ff03 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/util/ClassUtils.java @@ -241,7 +241,10 @@ static String wrapExportedFunctionCall(String exportedMethodName, ExportFunction } callBackList.forEach(cb -> { String variableName = cb.getVariableName(); - if (cb.getMethod().getReturnType() == void.class) { + if (cb.isNoPropagateFunction()) { + signature.append(variableName).append(".").append(cb.getMethod().getName()).append(sjInvoker.toString().replace("));", ");")); + signature.append(variableName).append(".setTriggered(false);\n"); + } else if (cb.getMethod().getReturnType() == void.class) { signature.append(variableName).append(".").append(cb.getMethod().getName()).append(sjInvoker.toString().replace("));", ");")); signature.append(variableName).append(".setTriggered(true);\n"); } else { diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java index 861ca28e5..12c99b8c2 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java @@ -3,6 +3,7 @@ import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; import com.fluxtion.runtime.annotations.ExportFunction; +import com.fluxtion.runtime.annotations.NoPropagateFunction; import com.fluxtion.runtime.annotations.OnParentUpdate; import com.fluxtion.runtime.annotations.OnTrigger; import com.fluxtion.runtime.annotations.builder.AssignToField; @@ -99,6 +100,19 @@ public void exportTestNoOverride() { Assert.assertEquals("ExportingNode{name='export2', result='myfunction s:3 y:33'}", aggregator.parent2.toString()); } + @Test + public void noPropagateTest() { + writeSourceFile = true; + sep(c -> { + c.addNode(new NoPropagateExport(), "exportNode"); + c.addInterfaceImplementation(AddService.class); + }); + AddService svc = sep.asInterface(); + svc.addFunction(10, 10); + NoPropagateExport node = getField("exportNode"); + Assert.assertFalse(node.isTriggered()); + } + public static class ExportingNode extends ExportFunctionNode { @@ -233,4 +247,20 @@ public void addFunction(int x, int y) { // return true; } } + + @Getter + public static class NoPropagateExport extends ExportFunctionNode { + private int result; + + @ExportFunction() + @NoPropagateFunction + public boolean addFunction(int x, int y) { + result = x + y; + return true; + } + } + + public static interface AddService { + void addFunction(int x, int y); + } } diff --git a/runtime/src/main/java/com/fluxtion/runtime/annotations/NoPropagateFunction.java b/runtime/src/main/java/com/fluxtion/runtime/annotations/NoPropagateFunction.java new file mode 100644 index 000000000..0ba99ac7b --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/annotations/NoPropagateFunction.java @@ -0,0 +1,18 @@ +package com.fluxtion.runtime.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marks an exported function as non propagating. + * + * @author Greg Higgins + * @see ExportFunction + * @see ExportService + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface NoPropagateFunction { +} From fa3aa803301b9d97e912f10c05288ca87df73dfb Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 18 Jul 2023 22:04:52 +0000 Subject: [PATCH 109/228] updating poms for 9.0.23-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 4e2767ddf..40df26f4f 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.22-SNAPSHOT + 9.0.23-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 64d177243..583769c68 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.22-SNAPSHOT + 9.0.23-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index dad7a5d11..7f1b56ada 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.22-SNAPSHOT + 9.0.23-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fa1bf1a18..225ad3288 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.22-SNAPSHOT + 9.0.23-SNAPSHOT ../parent-root/pom.xml From 8cd1afc1605ec26ee3bad6a1d820b88ee4e076f5 Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 18 Jul 2023 22:05:02 +0000 Subject: [PATCH 110/228] updating poms for branch'release/9.0.22' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 4e2767ddf..b4e37de26 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.22-SNAPSHOT + 9.0.22 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 64d177243..cf48e843b 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.22-SNAPSHOT + 9.0.22 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index dad7a5d11..1eb037037 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.22-SNAPSHOT + 9.0.22 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fa1bf1a18..0f339a21e 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.22-SNAPSHOT + 9.0.22 ../parent-root/pom.xml From e62182e1827b1012702a89e0b1f90da04211576c Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 18 Jul 2023 22:08:35 +0000 Subject: [PATCH 111/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 40df26f4f..b4e37de26 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.23-SNAPSHOT + 9.0.22 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 583769c68..cf48e843b 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.23-SNAPSHOT + 9.0.22 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 7f1b56ada..1eb037037 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.23-SNAPSHOT + 9.0.22 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 225ad3288..0f339a21e 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.23-SNAPSHOT + 9.0.22 ../parent-root/pom.xml From 09b54cc179304aff05f433cc229f57fbb6c0b0db Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 18 Jul 2023 22:08:36 +0000 Subject: [PATCH 112/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index b4e37de26..40df26f4f 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.22 + 9.0.23-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index cf48e843b..583769c68 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.22 + 9.0.23-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 1eb037037..7f1b56ada 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.22 + 9.0.23-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 0f339a21e..225ad3288 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.22 + 9.0.23-SNAPSHOT ../parent-root/pom.xml From 51e72eb857cef78f869a859391fde7c84f44905d Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 26 Jul 2023 10:04:08 +0200 Subject: [PATCH 113/228] support spring xml files to build event processor --- compiler/pom.xml | 12 +- .../extern/spring/FluxtionSpring.java | 129 ++++++++++++++++++ .../compiler/spring/extern/Account.java | 7 + .../compiler/spring/extern/AccountNode.java | 35 +++++ .../spring/extern/BankTransactionStore.java | 15 ++ .../compiler/spring/extern/EventBean.java | 14 ++ .../spring/extern/SpringLoaderTest.java | 73 ++++++++++ .../spring/application-context-test-1.xml | 11 ++ .../application-context-test-accountgraph.xml | 15 ++ 9 files changed, 310 insertions(+), 1 deletion(-) create mode 100644 compiler/src/main/java/com/fluxtion/compiler/extern/spring/FluxtionSpring.java create mode 100644 compiler/src/test/java/com/fluxtion/compiler/spring/extern/Account.java create mode 100644 compiler/src/test/java/com/fluxtion/compiler/spring/extern/AccountNode.java create mode 100644 compiler/src/test/java/com/fluxtion/compiler/spring/extern/BankTransactionStore.java create mode 100644 compiler/src/test/java/com/fluxtion/compiler/spring/extern/EventBean.java create mode 100644 compiler/src/test/java/com/fluxtion/compiler/spring/extern/SpringLoaderTest.java create mode 100644 compiler/src/test/spring/application-context-test-1.xml create mode 100644 compiler/src/test/spring/application-context-test-accountgraph.xml diff --git a/compiler/pom.xml b/compiler/pom.xml index 4e2767ddf..e4bea8030 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -25,7 +25,11 @@ Copyright (C) 2018 V12 Technology Ltd. compiler fluxtion :: compiler - + + + 5.2.21.RELEASE + + @@ -82,6 +86,12 @@ Copyright (C) 2018 V12 Technology Ltd. + + org.springframework + spring-context + ${org.springframework.version} + provided + com.fluxtion.csv-compiler csv-compiler diff --git a/compiler/src/main/java/com/fluxtion/compiler/extern/spring/FluxtionSpring.java b/compiler/src/main/java/com/fluxtion/compiler/extern/spring/FluxtionSpring.java new file mode 100644 index 000000000..39ff07e18 --- /dev/null +++ b/compiler/src/main/java/com/fluxtion/compiler/extern/spring/FluxtionSpring.java @@ -0,0 +1,129 @@ +package com.fluxtion.compiler.extern.spring; + +import com.fluxtion.compiler.EventProcessorConfig; +import com.fluxtion.compiler.Fluxtion; +import com.fluxtion.compiler.FluxtionCompilerConfig; +import com.fluxtion.runtime.EventProcessor; +import com.fluxtion.runtime.partition.LambdaReflection; +import com.fluxtion.runtime.partition.LambdaReflection.SerializableConsumer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.FileSystemXmlApplicationContext; + +import java.nio.file.Path; +import java.util.function.Consumer; + +/** + * Provides utility functions to build Fluxtion {@link EventProcessor} using a spring {@link ApplicationContext} to define + * the object instances managed by Fluxtion. + */ +public class FluxtionSpring { + + private final static Logger LOGGER = LoggerFactory.getLogger(FluxtionSpring.class); + private final ApplicationContext context; + private Consumer configCustomizer = c -> { + }; + + public FluxtionSpring(String springFile) { + this(new FileSystemXmlApplicationContext(springFile)); + LOGGER.debug("loading spring springFile:{}", springFile); + } + + public FluxtionSpring(String springFile, Consumer configCustomizer) { + this(new FileSystemXmlApplicationContext(springFile), configCustomizer); + LOGGER.debug("loading spring springFile:{}", springFile); + } + + public FluxtionSpring(ApplicationContext context, Consumer configCustomizer) { + this.context = context; + this.configCustomizer = configCustomizer; + } + + public FluxtionSpring(ApplicationContext context) { + this.context = context; + } + + public static EventProcessor compileAot( + Path springFile, + SerializableConsumer compilerConfig) { + FluxtionSpring fluxtionSpring = new FluxtionSpring(springFile.toAbsolutePath().toUri().toString()); + return fluxtionSpring._compileAot(compilerConfig); + } + + public static EventProcessor compileAot( + Path springFile, + Consumer configCustomizer, + SerializableConsumer compilerConfig) { + return new FluxtionSpring(springFile.toAbsolutePath().toUri().toString(), configCustomizer)._compileAot(compilerConfig); + } + + public static EventProcessor compileAot( + ApplicationContext context, + SerializableConsumer compilerConfig) { + return new FluxtionSpring(context)._compileAot(compilerConfig); + } + + public static EventProcessor compileAot( + ApplicationContext context, + Consumer configCustomizer, + SerializableConsumer compilerConfig) { + return new FluxtionSpring(context, configCustomizer)._compileAot(compilerConfig); + } + + public static EventProcessor compile(Path springFile) { + FluxtionSpring fluxtionSpring = new FluxtionSpring(springFile.toAbsolutePath().toUri().toString()); + return fluxtionSpring._compile(); + } + + public static EventProcessor compile(Path springFile, Consumer configCustomizer) { + return new FluxtionSpring(springFile.toAbsolutePath().toUri().toString(), configCustomizer)._compile(); + } + + public static EventProcessor compile(ApplicationContext context) { + return new FluxtionSpring(context)._compile(); + } + + public static EventProcessor compile(ApplicationContext context, Consumer configCustomizer) { + return new FluxtionSpring(context, configCustomizer)._compile(); + } + + public static EventProcessor interpret(Path springFile) { + FluxtionSpring fluxtionSpring = new FluxtionSpring(springFile.toAbsolutePath().toUri().toString()); + return fluxtionSpring._interpret(); + } + + public static EventProcessor interpret(Path springFile, Consumer configCustomizer) { + return new FluxtionSpring(springFile.toAbsolutePath().toUri().toString(), configCustomizer)._interpret(); + } + + public static EventProcessor interpret(ApplicationContext context) { + return new FluxtionSpring(context)._interpret(); + } + + public static EventProcessor interpret(ApplicationContext context, Consumer configCustomizer) { + return new FluxtionSpring(context, configCustomizer)._interpret(); + } + + private EventProcessor _compileAot(LambdaReflection.SerializableConsumer compilerConfig) { + return Fluxtion.compile(this::addNodes, compilerConfig); + } + + private EventProcessor _compile() { + return Fluxtion.compile(this::addNodes); + } + + private EventProcessor _interpret() { + return Fluxtion.interpret(this::addNodes); + } + + private void addNodes(EventProcessorConfig config) { + LOGGER.debug("loading spring context:{}", context); + for (String beanDefinitionName : context.getBeanDefinitionNames()) { + Object bean = context.getBean(beanDefinitionName); + LOGGER.debug("adding bean:{} to fluxtion", beanDefinitionName); + config.addNode(bean, beanDefinitionName); + } + configCustomizer.accept(config); + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/spring/extern/Account.java b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/Account.java new file mode 100644 index 000000000..9b7ed3f40 --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/Account.java @@ -0,0 +1,7 @@ +package com.fluxtion.compiler.spring.extern; + +public interface Account { + void debit(double debitAmount); + + void credit(double creditAmount); +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/spring/extern/AccountNode.java b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/AccountNode.java new file mode 100644 index 000000000..e9a3edaec --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/AccountNode.java @@ -0,0 +1,35 @@ +package com.fluxtion.compiler.spring.extern; + +import com.fluxtion.runtime.annotations.ExportService; +import com.fluxtion.runtime.callback.ExportFunctionNode; +import lombok.ToString; + +@ToString +public class AccountNode extends ExportFunctionNode implements @ExportService Account { + + private double debitAmount; + private double creditAmount; + + @Override + public void debit(double debitAmount) { + this.debitAmount = debitAmount; + } + + @Override + public void credit(double creditAmount) { + this.creditAmount = creditAmount; + } + + public double getDebitAmount() { + return debitAmount; + } + + public double getCreditAmount() { + return creditAmount; + } + + void clearTransaction() { + creditAmount = Double.NaN; + debitAmount = Double.NaN; + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/spring/extern/BankTransactionStore.java b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/BankTransactionStore.java new file mode 100644 index 000000000..af8f5ab19 --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/BankTransactionStore.java @@ -0,0 +1,15 @@ +package com.fluxtion.compiler.spring.extern; + +import com.fluxtion.runtime.annotations.OnTrigger; +import lombok.Data; + +@Data +public class BankTransactionStore { + private AccountNode accountNode; + + @OnTrigger + public boolean updateAccounts() { + System.out.println("updating account:" + accountNode); + return false; + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/spring/extern/EventBean.java b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/EventBean.java new file mode 100644 index 000000000..506f05a52 --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/EventBean.java @@ -0,0 +1,14 @@ +package com.fluxtion.compiler.spring.extern; + +import com.fluxtion.runtime.annotations.OnEventHandler; + +public class EventBean { + + public String input; + + @OnEventHandler + public boolean stringUpdate(String in) { + input = in; + return true; + } +} diff --git a/compiler/src/test/java/com/fluxtion/compiler/spring/extern/SpringLoaderTest.java b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/SpringLoaderTest.java new file mode 100644 index 000000000..6de818a3a --- /dev/null +++ b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/SpringLoaderTest.java @@ -0,0 +1,73 @@ +package com.fluxtion.compiler.spring.extern; + +import com.fluxtion.compiler.FluxtionCompilerConfig; +import com.fluxtion.compiler.extern.spring.FluxtionSpring; +import com.fluxtion.compiler.generation.OutputRegistry; +import com.fluxtion.runtime.EventProcessor; +import org.junit.Assert; +import org.junit.Test; + +import java.nio.file.FileSystems; +import java.nio.file.Path; + +public class SpringLoaderTest { + + @Test + public void loadSingleSpringBeanInterpret() throws NoSuchFieldException { + Path path = FileSystems.getDefault().getPath("src/test/spring/application-context-test-1.xml"); + EventProcessor eventProcessor = FluxtionSpring.interpret(path); + eventProcessor.init(); + eventProcessor.onEvent("HELLO WORLD"); + EventBean eventBean = eventProcessor.getNodeById("eventBean"); + Assert.assertEquals("HELLO WORLD", eventBean.input); + } + + @Test + public void loadSingleSpringBeanCompile() throws NoSuchFieldException { + Path path = FileSystems.getDefault().getPath("src/test/spring/application-context-test-1.xml"); + EventProcessor eventProcessor = FluxtionSpring.compile(path); + eventProcessor.init(); + eventProcessor.onEvent("HELLO WORLD"); + EventBean eventBean = eventProcessor.getNodeById("eventBean"); + Assert.assertEquals("HELLO WORLD", eventBean.input); + } + + @Test + public void loadSingleSpringBeanCompileAot() throws NoSuchFieldException { + Path path = FileSystems.getDefault().getPath("src/test/spring/application-context-test-1.xml"); + EventProcessor eventProcessor = FluxtionSpring.compileAot(path, (FluxtionCompilerConfig c) -> { + c.setOutputDirectory(OutputRegistry.JAVA_TESTGEN_DIR); + c.setGenerateDescription(false); + c.setWriteSourceToFile(false); + }); + eventProcessor.init(); + eventProcessor.onEvent("HELLO WORLD"); + EventBean eventBean = eventProcessor.getNodeById("eventBean"); + Assert.assertEquals("HELLO WORLD", eventBean.input); + } + + @Test + public void customiseConfig() throws NoSuchFieldException { + Path path = FileSystems.getDefault().getPath("src/test/spring/application-context-test-1.xml"); + EventProcessor eventProcessor = FluxtionSpring.interpret(path, c -> { + c.addNode(new EventBean(), "customBean"); + }); + eventProcessor.init(); + eventProcessor.onEvent("HELLO WORLD"); + EventBean eventBean = eventProcessor.getNodeById("eventBean"); + Assert.assertEquals("HELLO WORLD", eventBean.input); + // + eventBean = eventProcessor.getNodeById("customBean"); + Assert.assertEquals("HELLO WORLD", eventBean.input); + } + + @Test + public void loadGraphSpringInterpret() throws NoSuchFieldException { + Path path = FileSystems.getDefault().getPath("src/test/spring/application-context-test-accountgraph.xml"); + EventProcessor eventProcessor = FluxtionSpring.interpret(path); + eventProcessor.init(); + Account account = eventProcessor.asInterface(); + account.credit(12.4); + account.debit(31.6); + } +} diff --git a/compiler/src/test/spring/application-context-test-1.xml b/compiler/src/test/spring/application-context-test-1.xml new file mode 100644 index 000000000..4ae01d872 --- /dev/null +++ b/compiler/src/test/spring/application-context-test-1.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/compiler/src/test/spring/application-context-test-accountgraph.xml b/compiler/src/test/spring/application-context-test-accountgraph.xml new file mode 100644 index 000000000..80365c2cc --- /dev/null +++ b/compiler/src/test/spring/application-context-test-accountgraph.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + \ No newline at end of file From e1ed536feb5e2b88f02861b3edf00551e173cc8f Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 26 Jul 2023 17:57:51 +0000 Subject: [PATCH 114/228] updating poms for 9.0.24-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 85042b20c..15bcdde67 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.23-SNAPSHOT + 9.0.24-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 583769c68..2992b0493 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.23-SNAPSHOT + 9.0.24-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 7f1b56ada..62c362d12 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.23-SNAPSHOT + 9.0.24-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 225ad3288..d21a712e3 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.23-SNAPSHOT + 9.0.24-SNAPSHOT ../parent-root/pom.xml From 9ad8cfadb89b7132470a33edef05a6a5ef6dd462 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 26 Jul 2023 17:58:02 +0000 Subject: [PATCH 115/228] updating poms for branch'release/9.0.23' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 85042b20c..5c4910910 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.23-SNAPSHOT + 9.0.23 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 583769c68..bb5fff843 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.23-SNAPSHOT + 9.0.23 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 7f1b56ada..967a64e13 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.23-SNAPSHOT + 9.0.23 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 225ad3288..91b1a818c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.23-SNAPSHOT + 9.0.23 ../parent-root/pom.xml From d5753644e2a82b1def6140be7357f90551feab0e Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 26 Jul 2023 18:02:19 +0000 Subject: [PATCH 116/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 15bcdde67..5c4910910 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.24-SNAPSHOT + 9.0.23 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2992b0493..bb5fff843 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.24-SNAPSHOT + 9.0.23 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 62c362d12..967a64e13 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.24-SNAPSHOT + 9.0.23 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index d21a712e3..91b1a818c 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.24-SNAPSHOT + 9.0.23 ../parent-root/pom.xml From e225c8d7790eb98ffc442c7473e4b7d56980ed8f Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 26 Jul 2023 18:02:20 +0000 Subject: [PATCH 117/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 5c4910910..15bcdde67 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.23 + 9.0.24-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index bb5fff843..2992b0493 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.23 + 9.0.24-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 967a64e13..62c362d12 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.23 + 9.0.24-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 91b1a818c..d21a712e3 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.23 + 9.0.24-SNAPSHOT ../parent-root/pom.xml From 4a9f2688c43b49610ae5c31e1fcb3d009c10e07c Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 26 Jul 2023 20:05:37 +0200 Subject: [PATCH 118/228] disable write to file for tests --- .../test/java/com/fluxtion/compiler/builder/PricerTest.java | 4 +--- .../generation/customfieldserializer/MetaSerializerTest.java | 4 ---- .../generation/exportfunction/ExportFunctionTest.java | 1 - 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/compiler/src/test/java/com/fluxtion/compiler/builder/PricerTest.java b/compiler/src/test/java/com/fluxtion/compiler/builder/PricerTest.java index 5a293036b..64fd53207 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/builder/PricerTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/builder/PricerTest.java @@ -15,7 +15,7 @@ public PricerTest(SepTestConfig compile) { @Test public void pricer() { - writeOutputsToFile(true); +// writeOutputsToFile(true); sep(c -> { ParamsChecker checker = new ParamsChecker(); PriceCalc priceCalc = new PriceCalc(); @@ -33,8 +33,6 @@ public void pricer() { .filter(PricerTest::sanityCheck) .map(stepAway::applyStepaway) .filter(new ThrottlePublisher()::canPublish); - - }); } diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/MetaSerializerTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/MetaSerializerTest.java index 108a3d98f..b0e209086 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/MetaSerializerTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/customfieldserializer/MetaSerializerTest.java @@ -17,25 +17,21 @@ public MetaSerializerTest(CompiledAndInterpretedSepTest.SepTestConfig testConfig @Test public void serializeFieldTest() { - writeSourceFile = true; sep(new ClassFieldHolder(String.class)); } @Test public void serializeConstructorTest() { - writeSourceFile = true; sep(new ClassFieldHolder(String.class)); } @Test public void serializeInnerClassConstructorTest() { - writeSourceFile = true; sep(new ClassFieldHolder(MyInnerClass.class)); } @Test public void serializeField_WithSingleNamedNodeTest() { - writeSourceFile = true; InstanceCallbackEvent.reset(); sep(new CbSample("test")); } diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java index 12c99b8c2..8f005eaae 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java @@ -102,7 +102,6 @@ public void exportTestNoOverride() { @Test public void noPropagateTest() { - writeSourceFile = true; sep(c -> { c.addNode(new NoPropagateExport(), "exportNode"); c.addInterfaceImplementation(AddService.class); From 79f44c2cf625eb95447f206e82d73a02a5cf6ea4 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 28 Jul 2023 12:37:22 +0200 Subject: [PATCH 119/228] rename StaticEventProcessor#asInterface to StaticEventProcessor#getExportedService. Support separate trigger method for nodes exporting a service, by overriding ExportFunctionNode#propagateTrigger --- .../targets/InMemoryEventProcessor.java | 14 +----- .../exportfunction/ExportFunctionTest.java | 6 +-- .../exportfunction/ExportInterpretedTest.java | 4 +- .../ExportedFunctionVoidReturnTest.java | 4 +- .../ExportMultipleServiceTest.java | 38 ++++++---------- .../exportservice/ExportedServiceTest.java | 45 +++++++++++++++++-- .../spring/extern/SpringLoaderTest.java | 4 +- .../runtime/StaticEventProcessor.java | 2 +- .../runtime/callback/ExportFunctionNode.java | 40 +++++++++++++---- 9 files changed, 98 insertions(+), 59 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java index 1beb484ba..c0bd71e65 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/targets/InMemoryEventProcessor.java @@ -33,17 +33,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.BitSet; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.StringJoiner; -import java.util.UUID; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BooleanSupplier; import java.util.stream.Collectors; @@ -528,7 +518,7 @@ private CallbackInstance(CbMethodHandle cbMethodHandle) { @SneakyThrows @SuppressWarnings("unchecked") - public T asInterface() { + public T getExportedService() { if (exportingWrapper != null) { return (T) exportingWrapper; } diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java index 8f005eaae..01f31a094 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportFunctionTest.java @@ -46,7 +46,7 @@ public void exportTest() { ), "aggregator"); c.addInterfaceImplementation(MyExportedInterface.class); }); - MyExportedInterface myExportedInterface = sep.asInterface(); + MyExportedInterface myExportedInterface = sep.getExportedService(); Aggregator aggregator = getField("aggregator"); myExportedInterface.updatedDetails("hello", 300); Assert.assertEquals(2, aggregator.updateCount); @@ -78,7 +78,7 @@ public void exportTestNoOverride() { ), "aggregator"); c.addInterfaceImplementation(MyExportedInterfaceNoOverride.class); }); - MyExportedInterfaceNoOverride myExportedInterface = sep.asInterface(); + MyExportedInterfaceNoOverride myExportedInterface = sep.getExportedService(); Aggregator2 aggregator = getField("aggregator"); myExportedInterface.myfunctionString("hello", 300); Assert.assertEquals(2, aggregator.updateCount); @@ -106,7 +106,7 @@ public void noPropagateTest() { c.addNode(new NoPropagateExport(), "exportNode"); c.addInterfaceImplementation(AddService.class); }); - AddService svc = sep.asInterface(); + AddService svc = sep.getExportedService(); svc.addFunction(10, 10); NoPropagateExport node = getField("exportNode"); Assert.assertFalse(node.isTriggered()); diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportInterpretedTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportInterpretedTest.java index 763ffca2f..e11cb1f8e 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportInterpretedTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportInterpretedTest.java @@ -25,7 +25,7 @@ public void exportTest() { ), "aggregator"); c.addInterfaceImplementation(MyExportedInterface.class); }); - MyExportedInterface myExportedInterface = sep.asInterface(); + MyExportedInterface myExportedInterface = sep.getExportedService(); Aggregator aggregator = getField("aggregator"); myExportedInterface.updatedDetails("hello", 300); Assert.assertEquals(2, aggregator.updateCount); @@ -56,7 +56,7 @@ public void exportTestNoOverride() { ), "aggregator"); c.addInterfaceImplementation(MyExportedInterfaceNoOverride.class); }); - MyExportedInterfaceNoOverride myExportedInterface = sep.asInterface(); + MyExportedInterfaceNoOverride myExportedInterface = sep.getExportedService(); Aggregator2 aggregator = getField("aggregator"); myExportedInterface.myfunctionString("hello", 300); Assert.assertEquals(2, aggregator.updateCount); diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportedFunctionVoidReturnTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportedFunctionVoidReturnTest.java index b72870fa4..fc9dbf85e 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportedFunctionVoidReturnTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportfunction/ExportedFunctionVoidReturnTest.java @@ -24,7 +24,7 @@ public void exportVoidReturn() { c.addInterfaceImplementation(MyService.class); }); init(); - MyService mySvc = sep.asInterface(); + MyService mySvc = sep.getExportedService(); mySvc.testAdd(23, 50); MyExportingServiceNode myNode = getField("myService"); Assert.assertEquals(73, myNode.result); @@ -38,7 +38,7 @@ public void exportVoidAndAlwaysTrigger() { c.addInterfaceImplementation(MyService.class); }); init(); - MyService mySvc = sep.asInterface(); + MyService mySvc = sep.getExportedService(); MyResultHolder myResultHolder = getField("myResultHolder"); mySvc.testAdd(23, 50); MyExportingServiceNode myNode = getField("myService"); diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportMultipleServiceTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportMultipleServiceTest.java index 20a74965e..c3b32ad4c 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportMultipleServiceTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportMultipleServiceTest.java @@ -3,8 +3,6 @@ import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest; import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; import com.fluxtion.runtime.annotations.ExportService; -import com.fluxtion.runtime.annotations.OnParentUpdate; -import com.fluxtion.runtime.annotations.OnTrigger; import com.fluxtion.runtime.callback.ExportFunctionNode; import com.fluxtion.runtime.node.NamedNode; import org.junit.Assert; @@ -22,9 +20,9 @@ public void multiServiceExportTest() { // writeSourceFile = true; sep(new BottomNode()); //services - Top top = sep.asInterface(); - Middle middle = sep.asInterface(); - Bottom bottom = sep.asInterface(); + Top top = sep.getExportedService(); + Middle middle = sep.getExportedService(); + Bottom bottom = sep.getExportedService(); //nodes TopNode topNode = getField("top"); MiddleNode middleNode = getField("middle"); @@ -43,23 +41,23 @@ public void multiServiceExportTest() { Assert.assertEquals(0, middleNode.functionCount); Assert.assertEquals(1, middleNode.triggerCount); Assert.assertEquals(1, bottomNode.functionCount); - Assert.assertEquals(2, bottomNode.triggerCount); + Assert.assertEquals(1, bottomNode.triggerCount); //no trigger bottom middle.notifyMiddle(-10); Assert.assertEquals(1, topNode.functionCount); Assert.assertEquals(1, middleNode.functionCount); - Assert.assertEquals(2, middleNode.triggerCount);//? + Assert.assertEquals(1, middleNode.triggerCount);//? Assert.assertEquals(1, bottomNode.functionCount); - Assert.assertEquals(2, bottomNode.triggerCount); + Assert.assertEquals(1, bottomNode.triggerCount); //trigger middle middle.notifyMiddle(10); Assert.assertEquals(1, topNode.functionCount); Assert.assertEquals(2, middleNode.functionCount); - Assert.assertEquals(3, middleNode.triggerCount); + Assert.assertEquals(1, middleNode.triggerCount); Assert.assertEquals(1, bottomNode.functionCount); - Assert.assertEquals(3, bottomNode.triggerCount); + Assert.assertEquals(2, bottomNode.triggerCount); } public interface Top { @@ -93,7 +91,6 @@ public static class MiddleNode extends ExportFunctionNode implements @ExportServ private final TopNode topNode; int triggerCount = 0; int functionCount = 0; - private boolean parentTriggered; public MiddleNode(TopNode topNode) { this.topNode = topNode; @@ -103,23 +100,16 @@ public MiddleNode() { this(new TopNode()); } - @OnParentUpdate - public void topUpdated(TopNode topNode) { - parentTriggered = true; - } - @Override public boolean notifyMiddle(int arg) { functionCount++; return arg > 0; } - @OnTrigger - public boolean triggered() { + @Override + protected boolean propagateParentNotification() { triggerCount++; - boolean tmp = parentTriggered; - parentTriggered = false; - return tmp || isTriggered(); + return true; } @Override @@ -148,10 +138,10 @@ public boolean notifyBottom(int arg) { return false; } - @OnTrigger - public boolean triggered() { + @Override + protected boolean propagateParentNotification() { triggerCount++; - return isTriggered(); + return true; } @Override diff --git a/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java index bac617bba..c6913338d 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/generation/exportservice/ExportedServiceTest.java @@ -1,5 +1,6 @@ package com.fluxtion.compiler.generation.exportservice; +import com.fluxtion.compiler.builder.dataflow.DataFlow; import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest; import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; import com.fluxtion.runtime.annotations.ExportService; @@ -20,7 +21,7 @@ public void exportVoidReturn() { // writeSourceFile = true; sep(new MyExportingServiceNode()); init(); - MyService mySvc = sep.asInterface(); + MyService mySvc = sep.getExportedService(); mySvc.testAdd(23, 50); MyExportingServiceNode myNode = getField("myService"); Assert.assertEquals(73, myNode.result); @@ -31,7 +32,7 @@ public void exportBooleanReturn() { // writeSourceFile = true; sep(new MyExportingTriggerServiceNode()); init(); - MyTriggeringService mySvc = sep.asInterface(); + MyTriggeringService mySvc = sep.getExportedService(); mySvc.testAdd(23, 50); MyExportingTriggerServiceNode myNode = getField("myService"); Assert.assertEquals(73, myNode.result); @@ -42,7 +43,7 @@ public void exportVoidAndAlwaysTrigger() { // writeSourceFile = true; sep(new MyResultHolder()); init(); - MyService mySvc = sep.asInterface(); + MyService mySvc = sep.getExportedService(); MyResultHolder myResultHolder = getField("myResultHolder"); mySvc.testAdd(23, 50); MyExportingServiceNode myNode = getField("myService"); @@ -59,7 +60,7 @@ public void exportBooleanTriggerWhenPositive() { // writeSourceFile = true; sep(new MyResultHolderTrigger()); init(); - MyTriggeringService mySvc = sep.asInterface(); + MyTriggeringService mySvc = sep.getExportedService(); MyResultHolderTrigger myResultHolder = getField("myResultHolder"); mySvc.testAdd(23, 50); MyExportingTriggerServiceNode myNode = getField("myService"); @@ -77,6 +78,35 @@ public void exportBooleanTriggerWhenPositive() { Assert.assertEquals(3, myResultHolder.triggerCount); } + @Test + public void exportServiceAndParentNotification() { + writeSourceFile = true; + sep(c -> { + MyResultHolderTrigger resultHolderTrigger = c.addNode(new MyResultHolderTrigger()); + resultHolderTrigger.myExportingServiceNode.triggerObject = DataFlow.subscribe(String.class).flowSupplier(); + }); + init(); + MyTriggeringService mySvc = sep.getExportedService(); + MyResultHolderTrigger myResultHolder = getField("myResultHolder"); + mySvc.testAdd(23, 50); + MyExportingTriggerServiceNode myNode = getField("myService"); + Assert.assertEquals(73, myNode.result); + Assert.assertEquals(1, myResultHolder.triggerCount); + + mySvc.testSubtract(23, 8); + Assert.assertEquals(15, myNode.result); + Assert.assertEquals(2, myResultHolder.triggerCount); + + mySvc.triggerPositive(10); + Assert.assertEquals(3, myResultHolder.triggerCount); + + mySvc.triggerPositive(-10); + Assert.assertEquals(3, myResultHolder.triggerCount); + + onEvent("Hello"); + Assert.assertEquals(4, myResultHolder.triggerCount); + } + public interface MyTriggeringService extends MyService { boolean triggerPositive(int x); @@ -111,6 +141,8 @@ public String getName() { public static class MyExportingTriggerServiceNode extends ExportFunctionNode implements @ExportService MyTriggeringService, NamedNode { int result; + public Object triggerObject; + @Override public void testAdd(int a, int b) { result = a + b; @@ -130,6 +162,11 @@ public String getName() { public boolean triggerPositive(int x) { return x > 0; } + + @Override + protected boolean propagateParentNotification() { + return true; + } } public static class MyResultHolder implements NamedNode { diff --git a/compiler/src/test/java/com/fluxtion/compiler/spring/extern/SpringLoaderTest.java b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/SpringLoaderTest.java index 6de818a3a..f4e7e9252 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/spring/extern/SpringLoaderTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/spring/extern/SpringLoaderTest.java @@ -60,13 +60,13 @@ public void customiseConfig() throws NoSuchFieldException { eventBean = eventProcessor.getNodeById("customBean"); Assert.assertEquals("HELLO WORLD", eventBean.input); } - + @Test public void loadGraphSpringInterpret() throws NoSuchFieldException { Path path = FileSystems.getDefault().getPath("src/test/spring/application-context-test-accountgraph.xml"); EventProcessor eventProcessor = FluxtionSpring.interpret(path); eventProcessor.init(); - Account account = eventProcessor.asInterface(); + Account account = eventProcessor.getExportedService(); account.credit(12.4); account.debit(31.6); } diff --git a/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java b/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java index cee073121..624dba51e 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java +++ b/runtime/src/main/java/com/fluxtion/runtime/StaticEventProcessor.java @@ -373,7 +373,7 @@ default void setClockStrategy(ClockStrategy clockStrategy) { * @return The {@link StaticEventProcessor} cast to an interface */ @SuppressWarnings("unchecked") - default T asInterface() { + default T getExportedService() { return (T) this; } } diff --git a/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionNode.java b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionNode.java index 70bacb650..88cac8777 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionNode.java +++ b/runtime/src/main/java/com/fluxtion/runtime/callback/ExportFunctionNode.java @@ -1,6 +1,5 @@ package com.fluxtion.runtime.callback; -import com.fluxtion.runtime.annotations.AfterEvent; import com.fluxtion.runtime.annotations.Initialise; import com.fluxtion.runtime.annotations.OnTrigger; import com.fluxtion.runtime.annotations.Start; @@ -8,32 +7,55 @@ public class ExportFunctionNode { private boolean triggered; + private boolean functionTriggered; @OnTrigger - public boolean triggered() { - return triggered; + public final boolean triggered() { + boolean tempTriggered = triggered; + boolean tempFunctionTriggered = functionTriggered; + triggered = false; + functionTriggered = false; + if (tempFunctionTriggered) { + return tempTriggered; + } else { + return propagateParentNotification(); + } + } + + /** + * Overriding classes should subclass this method if they want to be notified + * when parents have triggered a notification. + * + * @return flag to propagate event notification, true -> propagate, false -> swallow + */ + protected boolean propagateParentNotification() { + return true; } - @AfterEvent - public void afterEvent() { + // @AfterEvent + public final void afterEvent() { triggered = false; + functionTriggered = false; } @Initialise - public void init() { + public final void init() { triggered = false; + functionTriggered = false; } @Start - public void start() { + public final void start() { triggered = false; + functionTriggered = false; } - public boolean isTriggered() { + public final boolean isTriggered() { return triggered; } - public void setTriggered(boolean triggered) { + public final void setTriggered(boolean triggered) { this.triggered = triggered; + functionTriggered = true; } } From f1f445d29fa6a608edd9454261c5d0f49f501706 Mon Sep 17 00:00:00 2001 From: runner Date: Fri, 28 Jul 2023 10:44:14 +0000 Subject: [PATCH 120/228] updating poms for 9.0.25-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 15bcdde67..b6499c19b 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.24-SNAPSHOT + 9.0.25-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2992b0493..a6e1811c2 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.24-SNAPSHOT + 9.0.25-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 62c362d12..2289f4316 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.24-SNAPSHOT + 9.0.25-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index d21a712e3..271c1db40 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.24-SNAPSHOT + 9.0.25-SNAPSHOT ../parent-root/pom.xml From 2c972e1fc3bd121fb453994d0fb0930d6cd4dee4 Mon Sep 17 00:00:00 2001 From: runner Date: Fri, 28 Jul 2023 10:44:24 +0000 Subject: [PATCH 121/228] updating poms for branch'release/9.0.24' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 15bcdde67..fbf6d73fd 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.24-SNAPSHOT + 9.0.24 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 2992b0493..ff800403f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.24-SNAPSHOT + 9.0.24 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 62c362d12..8f29369c1 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.24-SNAPSHOT + 9.0.24 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index d21a712e3..fb76e6eb0 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.24-SNAPSHOT + 9.0.24 ../parent-root/pom.xml From bba29a027b14f71193b74017925496fd8614f6ca Mon Sep 17 00:00:00 2001 From: runner Date: Fri, 28 Jul 2023 10:48:49 +0000 Subject: [PATCH 122/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index b6499c19b..fbf6d73fd 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.25-SNAPSHOT + 9.0.24 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index a6e1811c2..ff800403f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.25-SNAPSHOT + 9.0.24 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 2289f4316..8f29369c1 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.25-SNAPSHOT + 9.0.24 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 271c1db40..fb76e6eb0 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.25-SNAPSHOT + 9.0.24 ../parent-root/pom.xml From 53e340cb6717005492d278eb40f18d5ac1c59e13 Mon Sep 17 00:00:00 2001 From: runner Date: Fri, 28 Jul 2023 10:48:50 +0000 Subject: [PATCH 123/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index fbf6d73fd..b6499c19b 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.24 + 9.0.25-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index ff800403f..a6e1811c2 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.0.24 + 9.0.25-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 8f29369c1..2289f4316 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.0.24 + 9.0.25-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index fb76e6eb0..271c1db40 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.0.24 + 9.0.25-SNAPSHOT ../parent-root/pom.xml From 4de577c46877a08bb1cb1f611a4aa1e9c2ec959e Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 30 Jul 2023 18:49:37 +0200 Subject: [PATCH 124/228] updating spring example --- docs/_config.yml | 16 ++-- docs/cookbook/injecting_context.md | 2 +- docs/cookbook/spring_integration.md | 115 ++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 9 deletions(-) create mode 100644 docs/cookbook/spring_integration.md diff --git a/docs/_config.yml b/docs/_config.yml index c806a82fa..7b1f7b6d0 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -23,8 +23,8 @@ title: Fluxtion streaming description: Documentation for Fluxtion event processor remote_theme: pmarsceill/just-the-docs aux_links: - "release 9.0.7": - - "//github.com/v12technology/fluxtion/tree/9.0.7" + "release 9.0.24": + - "//github.com/v12technology/fluxtion/tree/9.0.24" heading_anchors: true # Color scheme supports "light" (default) and "dark" @@ -39,12 +39,12 @@ kramdown: block: line_numbers: true -fluxtion_version: 9.0.7 -fluxtion_src: https://github.com/v12technology/fluxtion/blob/9.0.7 -fluxtion_src_runtime: https://github.com/v12technology/fluxtion/blob/9.0.7/runtime/src/main/java/com/fluxtion/runtime -fluxtion_src_compiler: https://github.com/v12technology/fluxtion/blob/9.0.7/compiler/src/main/java/com/fluxtion/compiler -EventProcessor_link: https://github.com/v12technology/fluxtion/blob/9.0.7/runtime/src/main/java/com/fluxtion/runtime/EventProcessor.java -Fluxtion_link: https://github.com/v12technology/fluxtion/blob/9.0.7/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java +fluxtion_version: 9.0.24 +fluxtion_src: https://github.com/v12technology/fluxtion/blob/9.0.24 +fluxtion_src_runtime: https://github.com/v12technology/fluxtion/blob/9.0.24/runtime/src/main/java/com/fluxtion/runtime +fluxtion_src_compiler: https://github.com/v12technology/fluxtion/blob/9.0.24/compiler/src/main/java/com/fluxtion/compiler +EventProcessor_link: https://github.com/v12technology/fluxtion/blob/9.0.24/runtime/src/main/java/com/fluxtion/runtime/EventProcessor.java +Fluxtion_link: https://github.com/v12technology/fluxtion/blob/9.0.24/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java cookbook_src: https://github.com/v12technology/fluxtion-examples/tree/cook_subscription_example/cookbook/src/main/java/com/fluxtion/example/cookbook/ ga_tracking: G-NGDV621P1P diff --git a/docs/cookbook/injecting_context.md b/docs/cookbook/injecting_context.md index deee04aaa..2a83c1145 100644 --- a/docs/cookbook/injecting_context.md +++ b/docs/cookbook/injecting_context.md @@ -2,7 +2,7 @@ title: Injecting user context parent: Cookbook has_children: false -nav_order: 1 +nav_order: 9 published: true --- diff --git a/docs/cookbook/spring_integration.md b/docs/cookbook/spring_integration.md new file mode 100644 index 000000000..f1ed1bc42 --- /dev/null +++ b/docs/cookbook/spring_integration.md @@ -0,0 +1,115 @@ +--- +title: Spring integration +parent: Cookbook +has_children: false +nav_order: 1 +published: true +example_src: https://github.com/v12technology/fluxtion-examples/tree/main/cookbook/src/main/java/com/fluxtion/example/cookbook/spring +--- + +## Introduction + +Fluxtion acts as dependency injection container for event driven applications routing service calls to managed +instances. An instance can expose a service interface at the container level using annotations. Any child connected to +the service instance will be triggered as the event propagates through the container. + +In this example we will construct a small banking app, that supports credit, debit, account query, credit checking, +opening hours and persistence functions. The methods are grouped into service interfaces that are exposed by the +container. + +Spring is a popular DI container in the java world. This example demonstrates how the construction logic of spring can +be combined with the dispatching logic of Fluxtion to simplify building event driven applications. The goal is to allow +the developer to concentrate on developing application logic and the container automatically builds the object graph and +constructs event dispatch logic. + +The steps to combine spring and fluxtion are: + +- Use a spring config file to define the instances that are to be managed +- Create service interfaces that define the api of the banking app +- Create implementing classes for the services +- Use Fluxtion annotations to export services and define event notification methods +- Pass the spring config file to the Fluxtion compiler and generate the DI container AOT +- Create an instance of the DI container and locate the service interfaces +- Use the service interfaces in the sample application + +## Application structure + +The top level java package is, com.fluxtion.example.cookbook.spring.service, see the [example here]({{page.example_src}}). + +sample app package structure is: + +- top level: Banking app and a sample main +- service: interfaces the sample main and banking app invoke +- node: implementations of the service interfaces +- data: data types used by services +- generation: location of the Fluxtion ahead of time generated DI container + +## Invoking a service + +The main method acquires references to the exported service interfaces via tbe BankingApp. The BankingApp instance +creates an instance of the Fluxtion DI container and passes references to exported services back to the client code. The +reference the client code receives is a proxy handler the DI container creates, the proxy handler routes method calls +to managed instances in the container. + +Services the DI container exposes are event driven, they are designed to be invoked asynchronously and not return a +value to client code. A service can optionally return a boolean value that is used by the container as a dirty flag, +if the flag is true then child references are notified the parent has been updated. Child instances are notified by +calling a method if it is annotated with an OnTrigger annotation. OnTrigger methods return a boolean flag that is used +to signal children should be notified of a change. + +The fluxtion DI container manages all the proxy creation, event dispatch to services, monitoring dirty flags and +propagating event notifications to child references. + +### Main method execution + +{% highlight java %} +public class Main { + + public static void main(String[] args) { + BankingApp bankingApp = new BankingApp(GenerationStrategy.USE_AOT); + //get services + Account accountService = bankingApp.getBankAccount(); + BankingOperations bankControllerService = bankingApp.getBankingOperations(); + CreditCheck creditCheckService = bankingApp.getCreditCheck(); + //persistence + FileDataStore fileDataStore = new FileDataStore(Paths.get("data/spring/bank")); + bankControllerService.setDataStore(fileDataStore); + //replay state + fileDataStore.replay(bankingApp.getEventConsumer()); + + bankingApp.start(); + //should reject unknown account + accountService.deposit(999, 250.12); + + //get opening balance for acc 100 + accountService.publishBalance(100); + + //should reject bank closed + accountService.openAccount(100); + accountService.deposit(100, 250.12); + + //open bank + bankControllerService.openForBusiness(); + accountService.deposit(100, 250.12); + + //blacklist an account + creditCheckService.blackListAccount(100); + accountService.deposit(100, 46.90); + + //remove account from blacklist + creditCheckService.whiteListAccount(100); + accountService.deposit(100, 46.90); + + //close bank + bankControllerService.closedForBusiness(); + accountService.deposit(100, 13); + } + +} +{% endhighlight %} + +## Exporting a service + + + + From c810c0ce54688f2c5aad19cf3dac6d83c2c277f3 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 31 Jul 2023 09:07:44 +0200 Subject: [PATCH 125/228] updating spring example --- docs/Gemfile | 3 +-- docs/Gemfile.lock | 6 +++++ docs/_config.yml | 6 +++-- docs/_sass/color_schemes/fluxtion_style.scss | 2 +- docs/cookbook/spring_integration.md | 26 +++++++++++--------- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/docs/Gemfile b/docs/Gemfile index e786b102c..2fab11f60 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -16,6 +16,7 @@ gem "github-pages", "~> 226", group: :jekyll_plugins # If you have any plugins, put them here! group :jekyll_plugins do gem "jekyll-feed", "~> 0.12" + gem "just-the-docs" # always download the latest release end # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem @@ -33,5 +34,3 @@ gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] gem "webrick", "~> 1.8" - -gem "webrick", "~> 1.8" diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index d0aabf3f8..3dc2d938b 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -197,6 +197,10 @@ GEM gemoji (~> 3.0) html-pipeline (~> 2.2) jekyll (>= 3.0, < 5.0) + just-the-docs (0.5.4) + jekyll (>= 3.8.5) + jekyll-seo-tag (>= 2.0) + rake (>= 12.3.1) kramdown (2.3.2) rexml kramdown-parser-gfm (1.1.0) @@ -224,6 +228,7 @@ GEM forwardable-extended (~> 2.6) public_suffix (4.0.7) racc (1.6.0) + rake (13.0.6) rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) @@ -265,6 +270,7 @@ DEPENDENCIES github-pages (~> 226) http_parser.rb (~> 0.6.0) jekyll-feed (~> 0.12) + just-the-docs minima (~> 2.5) tzinfo (~> 1.2) tzinfo-data diff --git a/docs/_config.yml b/docs/_config.yml index 7b1f7b6d0..62dd1b04e 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -18,10 +18,12 @@ # You can create any custom variable you would like, and they will be accessible # in the templates via {{ site.myvariable }}. -theme: jekyll-theme-cayman +theme: just-the-docs + +url: https://just-the-docs.github.io title: Fluxtion streaming description: Documentation for Fluxtion event processor -remote_theme: pmarsceill/just-the-docs +#remote_theme: pmarsceill/just-the-docs aux_links: "release 9.0.24": - "//github.com/v12technology/fluxtion/tree/9.0.24" diff --git a/docs/_sass/color_schemes/fluxtion_style.scss b/docs/_sass/color_schemes/fluxtion_style.scss index dee8725a5..56f8b6399 100644 --- a/docs/_sass/color_schemes/fluxtion_style.scss +++ b/docs/_sass/color_schemes/fluxtion_style.scss @@ -1,3 +1,3 @@ @import "./color_schemes/dark"; -$content-width: 1000px; +//$content-width: 6rem; diff --git a/docs/cookbook/spring_integration.md b/docs/cookbook/spring_integration.md index f1ed1bc42..b2469a02d 100644 --- a/docs/cookbook/spring_integration.md +++ b/docs/cookbook/spring_integration.md @@ -10,23 +10,24 @@ example_src: https://github.com/v12technology/fluxtion-examples/tree/main/cookbo ## Introduction Fluxtion acts as dependency injection container for event driven applications routing service calls to managed -instances. An instance can expose a service interface at the container level using annotations. Any child connected to -the service instance will be triggered as the event propagates through the container. +instances, a service interface is exposed at the container level by adding annotations to the application classes. Any +instance referencing the service handler will be triggered by the container as the event propagates through the object +graph. -In this example we will construct a small banking app, that supports credit, debit, account query, credit checking, -opening hours and persistence functions. The methods are grouped into service interfaces that are exposed by the -container. - -Spring is a popular DI container in the java world. This example demonstrates how the construction logic of spring can +Spring is a popular DI container in the java world, the tutorial demonstrates how the construction logic of spring can be combined with the dispatching logic of Fluxtion to simplify building event driven applications. The goal is to allow -the developer to concentrate on developing application logic and the container automatically builds the object graph and +the developer to concentrate on developing application logic while the container automatically builds the object graph and constructs event dispatch logic. -The steps to combine spring and fluxtion are: +This example constructs a small banking application, that supports credit, debit, account query, credit checking, +opening hours and persistence functions. The methods are grouped into service interfaces that are exposed by the +container. + +The steps to combine spring and fluxtion: -- Use a spring config file to define the instances that are to be managed - Create service interfaces that define the api of the banking app -- Create implementing classes for the services +- Create implementing classes for the service interfaces +- Create a spring config file defining instances the DI container will manage - Use Fluxtion annotations to export services and define event notification methods - Pass the spring config file to the Fluxtion compiler and generate the DI container AOT - Create an instance of the DI container and locate the service interfaces @@ -34,7 +35,8 @@ The steps to combine spring and fluxtion are: ## Application structure -The top level java package is, com.fluxtion.example.cookbook.spring.service, see the [example here]({{page.example_src}}). +The top level java package is, com.fluxtion.example.cookbook.spring.service, see +the [example here]({{page.example_src}}). sample app package structure is: From e6a429f89f89acda97e18cb10f5ac18ed805a281 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 31 Jul 2023 09:13:30 +0200 Subject: [PATCH 126/228] updating just the docs gem plugin for github pages --- docs/Gemfile | 3 ++- docs/Gemfile.lock | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/Gemfile b/docs/Gemfile index 2fab11f60..26fe023a2 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -16,7 +16,8 @@ gem "github-pages", "~> 226", group: :jekyll_plugins # If you have any plugins, put them here! group :jekyll_plugins do gem "jekyll-feed", "~> 0.12" - gem "just-the-docs" # always download the latest release + gem "just-the-docs", "0.5.4" # pinned to the current release + # gem "just-the-docs" # always download the latest release end # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 3dc2d938b..0aca42b17 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -270,7 +270,7 @@ DEPENDENCIES github-pages (~> 226) http_parser.rb (~> 0.6.0) jekyll-feed (~> 0.12) - just-the-docs + just-the-docs (= 0.5.4) minima (~> 2.5) tzinfo (~> 1.2) tzinfo-data From 801c4b1edaefba97f7cf014d8f76f8cf3a91f103 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 31 Jul 2023 09:19:26 +0200 Subject: [PATCH 127/228] use remote theme for github pages --- docs/_config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index 62dd1b04e..c37f18cdb 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -18,12 +18,12 @@ # You can create any custom variable you would like, and they will be accessible # in the templates via {{ site.myvariable }}. -theme: just-the-docs +#theme: just-the-docs -url: https://just-the-docs.github.io +#url: https://just-the-docs.github.io title: Fluxtion streaming description: Documentation for Fluxtion event processor -#remote_theme: pmarsceill/just-the-docs +remote_theme: pmarsceill/just-the-docs aux_links: "release 9.0.24": - "//github.com/v12technology/fluxtion/tree/9.0.24" From 04766e47ba3d3e209220ffb7518fecb968537be4 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 31 Jul 2023 15:12:17 +0200 Subject: [PATCH 128/228] updating spring example --- docs/cookbook/spring_integration.md | 175 ++++++++++++++++++++++++---- 1 file changed, 152 insertions(+), 23 deletions(-) diff --git a/docs/cookbook/spring_integration.md b/docs/cookbook/spring_integration.md index b2469a02d..6f43d3600 100644 --- a/docs/cookbook/spring_integration.md +++ b/docs/cookbook/spring_integration.md @@ -9,12 +9,12 @@ example_src: https://github.com/v12technology/fluxtion-examples/tree/main/cookbo ## Introduction -Fluxtion acts as dependency injection container for event driven applications routing service calls to managed +Fluxtion is as dependency injection container for event driven applications routing service calls to managed instances, a service interface is exposed at the container level by adding annotations to the application classes. Any -instance referencing the service handler will be triggered by the container as the event propagates through the object -graph. +managed instance referencing the service handler will be triggered by the container as it propagates the event through +the object graph. -Spring is a popular DI container in the java world, the tutorial demonstrates how the construction logic of spring can +Spring is a popular DI container in the java world, this tutorial demonstrates how the construction logic of spring can be combined with the dispatching logic of Fluxtion to simplify building event driven applications. The goal is to allow the developer to concentrate on developing application logic while the container automatically builds the object graph and constructs event dispatch logic. @@ -27,7 +27,7 @@ The steps to combine spring and fluxtion: - Create service interfaces that define the api of the banking app - Create implementing classes for the service interfaces -- Create a spring config file defining instances the DI container will manage +- Create a spring config file declaring instances the DI container will manage - Use Fluxtion annotations to export services and define event notification methods - Pass the spring config file to the Fluxtion compiler and generate the DI container AOT - Create an instance of the DI container and locate the service interfaces @@ -35,35 +35,42 @@ The steps to combine spring and fluxtion: ## Application structure -The top level java package is, com.fluxtion.example.cookbook.spring.service, see -the [example here]({{page.example_src}}). +[See the example on GitHUb]({{page.example_src}}), top level package is `com.fluxtion.example.cookbook.spring.service`. -sample app package structure is: +Package structure: -- top level: Banking app and a sample main -- service: interfaces the sample main and banking app invoke -- node: implementations of the service interfaces -- data: data types used by services -- generation: location of the Fluxtion ahead of time generated DI container +- **top level**: Banking app and a sample main +- **service**: interfaces the sample main and banking app invoke +- **node**: implementations of the service interfaces +- **data**: data types used by services +- **generation**: location of the Fluxtion ahead of time generated DI container ## Invoking a service -The main method acquires references to the exported service interfaces via tbe BankingApp. The BankingApp instance -creates an instance of the Fluxtion DI container and passes references to exported services back to the client code. The -reference the client code receives is a proxy handler the DI container creates, the proxy handler routes method calls -to managed instances in the container. +The BankingApp instance creates an instance of the AOT generated Fluxtion DI container and provides access to container +exported services. The service reference the client code receives is a proxy the DI container creates, the +proxy handler routes method calls to instances managed by the container. -Services the DI container exposes are event driven, they are designed to be invoked asynchronously and not return a -value to client code. A service can optionally return a boolean value that is used by the container as a dirty flag, -if the flag is true then child references are notified the parent has been updated. Child instances are notified by -calling a method if it is annotated with an OnTrigger annotation. OnTrigger methods return a boolean flag that is used -to signal children should be notified of a change. +Services the DI container exposes are event driven, they are designed to be invoked asynchronously and do not return +application values to client code. A service method can optionally return a boolean value that is used by the container +as an event propagation flag. If the flag is true then child references are notified the parent has changed due to an +external event. Child instances are notified of event propagation by the container calling a trigger method. A trigger +method is any zero argument method marked with an `OnTrigger` annotation. `OnTrigger` methods return an event +propagation flag to control event notification dispatch in the same was as exported service methods. The fluxtion DI container manages all the proxy creation, event dispatch to services, monitoring dirty flags and -propagating event notifications to child references. +propagating event notifications to child references. To access an exported service client code calls: + +{% highlight java %} +T exportedService = eventProcessor.getExportedService(); +{% endhighlight %} ### Main method execution +The main method creates an instance of the BankingApp, rerieves service interfaces and invokes application methods on +the interfaces. It is expected the BankingApp would be instantiated and used within a larger application that marshalls +client requests from the network and then invokes the BankingApp appropiately. + {% highlight java %} public class Main { @@ -112,6 +119,128 @@ public class Main { ## Exporting a service +To export a service the following steps are required: +- Create an interface and then implement the interface with a concrete class +- The implementation class must extend ```ExportFunctionNode``` +- Mark the interface to export with ```@ExportService``` annotation + +For example to export the CreditCheck service: + +### CreditCheck interface + +{% highlight java %} +public interface CreditCheck { + void blackListAccount(int accountNumber); + void whiteListAccount(int accountNumber); +} + +{% endhighlight %} + +### CreditCheckNode concrete class +The CreditCheckNode implements two interfaces CreditCheck and TransactionProcessor. Only the CreditCheck interface +methods are exported as this is only interface marked with ```@ExportService``` + +{% highlight java %} +public class CreditCheckNode extends ExportFunctionNode implements @ExportService CreditCheck, TransactionProcessor { + + private transient Set blackListedAccounts = new HashSet<>(); + private TransactionProcessor transactionSource; + private ResponsePublisher responsePublisher; + + @Override + @NoPropagateFunction + public void blackListAccount(int accountNumber) { + log.info("credit check blacklisted:{}", accountNumber); + blackListedAccounts.add(accountNumber); + } + + @Override + @NoPropagateFunction + public void whiteListAccount(int accountNumber) { + log.info("credit check whitelisted:{}", accountNumber); + blackListedAccounts.remove(accountNumber); + } + + public boolean propagateParentNotification(){ + Transaction transaction = transactionSource.currentTransactionRequest(); + int accountNumber = transaction.accountNumber(); + if(blackListedAccounts.contains(accountNumber)){ + log.warn("credit check failed"); + transactionSource.rollbackTransaction(); + responsePublisher.rejectTransaction(transaction); + return false; + } + log.info("credit check passed"); + return true; + } + + @Override + public Transaction currentTransactionRequest() { + return transactionSource.currentTransactionRequest(); + } + + @Override + public void rollbackTransaction() { + transactionSource.rollbackTransaction(); + } + + @Override + public void commitTransaction(){ + transactionSource.commitTransaction(); + } +} +{% endhighlight %} + +Notice the two CreditCheck methods are annotated with ```@NoPropagateFunction```, telling Fluxtion that no event +propagation will occur when either of these methods is invoked. The credit black list is a map and these methods should +only change the state of the internal map and not cause further processing to occur in the object graph. + +## Locating a service + +The steps required to locate a service and invoke methods on it are: +- Build the DI container using one of the Fluxtion build methods +- To correctly intitialise the container call ```eventProcessor.init()``` on the DI instance +- To access the service call ```T service = eventProcessor.getExportedService()``` with the desired service type T + +### Accessing CreditCheck service +The code below uses an enum to allow the user to select the DI generation strategy, in this example we are using the +AOT strategy. After eventprocessor generation the exported service are located and assigned to member variables in +the BankingApp class. + +{% highlight java %} +public class BankingApp { + + private final EventProcessor eventProcessor; + private final Account bankAccount; + private final CreditCheck creditCheck; + private final BankingOperations bankingOperations; + private final Consumer eventConsumer; + + @SneakyThrows + public BankingApp(GenerationStrategy generationStrategy) { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("com/fluxtion/example/cookbook/spring/spring-account.xml"); + eventProcessor = switch (generationStrategy) { + case USE_AOT -> new SpringBankEventProcessor(); + case INTERPRET -> FluxtionSpring.interpret(context); + case COMPILE -> FluxtionSpring.compile(context); + case GENERATE_AOT -> FluxtionSpring.compileAot(context, c -> { + c.setPackageName("com.fluxtion.example.cookbook.spring.generated"); + c.setClassName("SpringBankEventProcessor"); + }); + }; + eventProcessor.init(); + bankAccount = eventProcessor.getExportedService(); + creditCheck = eventProcessor.getExportedService(); + bankingOperations = eventProcessor.getExportedService(); + eventConsumer = eventProcessor::onEvent; + } + + public CreditCheck getCreditCheck() { + return creditCheck; + } + +} +{% endhighlight %} From c5fea0fac3f99b90cac90071581eacec240fea86 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 2 Aug 2023 09:30:08 +0100 Subject: [PATCH 129/228] updating spring example --- docs/_config.yml | 4 +- docs/cookbook/spring_integration.md | 126 ++++++++++++++++++++++------ 2 files changed, 104 insertions(+), 26 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index c37f18cdb..c05999ed0 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -18,12 +18,12 @@ # You can create any custom variable you would like, and they will be accessible # in the templates via {{ site.myvariable }}. -#theme: just-the-docs +theme: just-the-docs #url: https://just-the-docs.github.io title: Fluxtion streaming description: Documentation for Fluxtion event processor -remote_theme: pmarsceill/just-the-docs +#remote_theme: pmarsceill/just-the-docs aux_links: "release 9.0.24": - "//github.com/v12technology/fluxtion/tree/9.0.24" diff --git a/docs/cookbook/spring_integration.md b/docs/cookbook/spring_integration.md index 6f43d3600..8103690ed 100644 --- a/docs/cookbook/spring_integration.md +++ b/docs/cookbook/spring_integration.md @@ -9,17 +9,21 @@ example_src: https://github.com/v12technology/fluxtion-examples/tree/main/cookbo ## Introduction -Fluxtion is as dependency injection container for event driven applications routing service calls to managed -instances, a service interface is exposed at the container level by adding annotations to the application classes. Any -managed instance referencing the service handler will be triggered by the container as it propagates the event through -the object graph. +Fluxtion is a dependency injection container specialised for event driven application deployments. The container +exposes event consumer end-points, routing events as methods calls to beans within the running container. A bean +registers a method as an event-handler by using Fluxtion annotations. Any beans referencing an event-handler bean will +be triggered by the container as the internal dispatcher propagates an event notification through the object graph. + +All methods on an interface can be exported by annotating the interface in an implementing bean, the container exports +the interface methods as a single service. A client can look up an exported service by interface type using the +container apis. All method calls on the service proxy are routed through the container's internal dispatcher. Spring is a popular DI container in the java world, this tutorial demonstrates how the construction logic of spring can be combined with the dispatching logic of Fluxtion to simplify building event driven applications. The goal is to allow -the developer to concentrate on developing application logic while the container automatically builds the object graph and -constructs event dispatch logic. +the developer to concentrate on developing application logic while the container automatically builds the object graph +and constructs event dispatch logic. -This example constructs a small banking application, that supports credit, debit, account query, credit checking, +This example builds a small banking application, that supports credit, debit, account query, credit checking, opening hours and persistence functions. The methods are grouped into service interfaces that are exposed by the container. @@ -47,15 +51,15 @@ Package structure: ## Invoking a service -The BankingApp instance creates an instance of the AOT generated Fluxtion DI container and provides access to container -exported services. The service reference the client code receives is a proxy the DI container creates, the +The BankingApp instance creates an instance of the AOT generated Fluxtion DI container and provides access to container +exported services. The service reference the client code receives is a proxy the DI container creates, the proxy handler routes method calls to instances managed by the container. -Services the DI container exposes are event driven, they are designed to be invoked asynchronously and do not return -application values to client code. A service method can optionally return a boolean value that is used by the container -as an event propagation flag. If the flag is true then child references are notified the parent has changed due to an -external event. Child instances are notified of event propagation by the container calling a trigger method. A trigger -method is any zero argument method marked with an `OnTrigger` annotation. `OnTrigger` methods return an event +Services the DI container exposes are event driven, they are designed to be invoked asynchronously and do not return +application values to client code. A service method can optionally return a boolean value that is used by the container +as an event propagation flag. If the flag is true then child references are notified the parent has changed due to an +external event. Child instances are notified of event propagation by the container calling a trigger method. A trigger +method is any zero argument method marked with an `OnTrigger` annotation. `OnTrigger` methods return an event propagation flag to control event notification dispatch in the same was as exported service methods. The fluxtion DI container manages all the proxy creation, event dispatch to services, monitoring dirty flags and @@ -117,11 +121,81 @@ public class Main { } {% endhighlight %} +running the main method prints the following to the console: + +{% highlight text %} +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=999, amount=250.12, debit=false] +[INFO] AccountNode - reject unknown account:999 +[INFO] ResponsePublisher - response reject:Transaction[accountNumber=999, amount=250.12, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] AccountNode - ------------------------------------------------------ +[INFO] ResponsePublisher - account:100, balance:3267.22 +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - opened account:100 +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=100, amount=250.12, debit=false] +[INFO] CreditCheckNode - credit check passed +[WARN] CentralTransactionProcessor - reject bank closed +[INFO] ResponsePublisher - response reject:Transaction[accountNumber=100, amount=250.12, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] CentralTransactionProcessor - open accepting transactions +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=100, amount=250.12, debit=false] +[INFO] CreditCheckNode - credit check passed +[INFO] CentralTransactionProcessor - accept bank open +[INFO] AccountNode - updated balance:3517.3399999999997 account:100 +[INFO] ResponsePublisher - response accept:Transaction[accountNumber=100, amount=250.12, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] CreditCheckNode - credit check blacklisted:100 +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=100, amount=46.9, debit=false] +[WARN] CreditCheckNode - credit check failed +[INFO] ResponsePublisher - response reject:Transaction[accountNumber=100, amount=46.9, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] CreditCheckNode - credit check whitelisted:100 +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=100, amount=46.9, debit=false] +[INFO] CreditCheckNode - credit check passed +[INFO] CentralTransactionProcessor - accept bank open +[INFO] AccountNode - updated balance:3564.24 account:100 +[INFO] ResponsePublisher - response accept:Transaction[accountNumber=100, amount=46.9, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[WARN] CentralTransactionProcessor - closed rejecting all transactions +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=100, amount=13.0, debit=false] +[INFO] CreditCheckNode - credit check passed +[WARN] CentralTransactionProcessor - reject bank closed +[INFO] ResponsePublisher - response reject:Transaction[accountNumber=100, amount=13.0, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + + +Process finished with exit code 0 +{% endhighlight %} + ## Exporting a service To export a service the following steps are required: + - Create an interface and then implement the interface with a concrete class -- The implementation class must extend ```ExportFunctionNode``` +- The implementation class must extend ```ExportFunctionNode``` - Mark the interface to export with ```@ExportService``` annotation For example to export the CreditCheck service: @@ -130,14 +204,15 @@ For example to export the CreditCheck service: {% highlight java %} public interface CreditCheck { - void blackListAccount(int accountNumber); - void whiteListAccount(int accountNumber); +void blackListAccount(int accountNumber); +void whiteListAccount(int accountNumber); } {% endhighlight %} ### CreditCheckNode concrete class -The CreditCheckNode implements two interfaces CreditCheck and TransactionProcessor. Only the CreditCheck interface + +The CreditCheckNode implements two interfaces CreditCheck and TransactionProcessor. Only the CreditCheck interface methods are exported as this is only interface marked with ```@ExportService``` {% highlight java %} @@ -150,14 +225,14 @@ public class CreditCheckNode extends ExportFunctionNode implements @ExportServic @Override @NoPropagateFunction public void blackListAccount(int accountNumber) { - log.info("credit check blacklisted:{}", accountNumber); + log.[INFO]("credit check blacklisted:{}", accountNumber); blackListedAccounts.add(accountNumber); } @Override @NoPropagateFunction public void whiteListAccount(int accountNumber) { - log.info("credit check whitelisted:{}", accountNumber); + log.[INFO]("credit check whitelisted:{}", accountNumber); blackListedAccounts.remove(accountNumber); } @@ -165,12 +240,12 @@ public class CreditCheckNode extends ExportFunctionNode implements @ExportServic Transaction transaction = transactionSource.currentTransactionRequest(); int accountNumber = transaction.accountNumber(); if(blackListedAccounts.contains(accountNumber)){ - log.warn("credit check failed"); + log.[WARN]("credit check failed"); transactionSource.rollbackTransaction(); responsePublisher.rejectTransaction(transaction); return false; } - log.info("credit check passed"); + log.[INFO]("credit check passed"); return true; } @@ -188,23 +263,26 @@ public class CreditCheckNode extends ExportFunctionNode implements @ExportServic public void commitTransaction(){ transactionSource.commitTransaction(); } + } {% endhighlight %} Notice the two CreditCheck methods are annotated with ```@NoPropagateFunction```, telling Fluxtion that no event -propagation will occur when either of these methods is invoked. The credit black list is a map and these methods should +propagation will occur when either of these methods is invoked. The credit black list is a map and these methods should only change the state of the internal map and not cause further processing to occur in the object graph. ## Locating a service The steps required to locate a service and invoke methods on it are: + - Build the DI container using one of the Fluxtion build methods - To correctly intitialise the container call ```eventProcessor.init()``` on the DI instance - To access the service call ```T service = eventProcessor.getExportedService()``` with the desired service type T ### Accessing CreditCheck service + The code below uses an enum to allow the user to select the DI generation strategy, in this example we are using the -AOT strategy. After eventprocessor generation the exported service are located and assigned to member variables in +AOT strategy. After eventprocessor generation the exported service are located and assigned to member variables in the BankingApp class. {% highlight java %} From ece4f01dd73a1fda25adcbad6c3cb57a04cf40e1 Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 2 Aug 2023 09:52:56 +0100 Subject: [PATCH 130/228] github needs remote theme for just the docs --- docs/_config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index c05999ed0..c37f18cdb 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -18,12 +18,12 @@ # You can create any custom variable you would like, and they will be accessible # in the templates via {{ site.myvariable }}. -theme: just-the-docs +#theme: just-the-docs #url: https://just-the-docs.github.io title: Fluxtion streaming description: Documentation for Fluxtion event processor -#remote_theme: pmarsceill/just-the-docs +remote_theme: pmarsceill/just-the-docs aux_links: "release 9.0.24": - "//github.com/v12technology/fluxtion/tree/9.0.24" From 3d1b6086f9dbb1360fed7f597d8d8f5cecd30669 Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 2 Aug 2023 15:07:53 +0100 Subject: [PATCH 131/228] work on docs --- docs/_config.yml | 5 + docs/_sass/color_schemes/fluxtion_style.scss | 4 +- docs/_sass/custom/custom.scss | 15 ++ docs/index.md | 164 +++++------------- .../detailpages/helloworld_functional.md | 2 +- .../detailpages/helloworld_imperative.md | 2 +- docs/overview/detailpages/keyterms.md | 85 +++++++++ 7 files changed, 152 insertions(+), 125 deletions(-) create mode 100644 docs/overview/detailpages/keyterms.md diff --git a/docs/_config.yml b/docs/_config.yml index c37f18cdb..1519e49b1 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -58,6 +58,11 @@ logo: "/images/fluxtion_logo_small.png" plugins: - jekyll-feed +callouts: + note: + title: NOTE + color: blue + # Exclude from processing. # The following items will not be processed, by default. # Any item listed under the `exclude:` key here will be automatically added to diff --git a/docs/_sass/color_schemes/fluxtion_style.scss b/docs/_sass/color_schemes/fluxtion_style.scss index 56f8b6399..772e91374 100644 --- a/docs/_sass/color_schemes/fluxtion_style.scss +++ b/docs/_sass/color_schemes/fluxtion_style.scss @@ -1,3 +1,3 @@ -@import "./color_schemes/dark"; +@import "./color_schemes/light"; -//$content-width: 6rem; +$content-width: 70rem; \ No newline at end of file diff --git a/docs/_sass/custom/custom.scss b/docs/_sass/custom/custom.scss index fd80779b0..cdca6f9d5 100644 --- a/docs/_sass/custom/custom.scss +++ b/docs/_sass/custom/custom.scss @@ -40,3 +40,18 @@ to {opacity: 1;} } +html { font-size: 1.05rem !important; scroll-behavior: smooth; } +@media (min-width: 31.25rem) { html { font-size: 1.05rem !important; } } + +//body { line-height: 1.3;} + +.grid { + display: flex; +} +.col-1-2 { + flex: 1; +} +.cole-1-2:last-child { + margin-left: 20px; +} + diff --git a/docs/index.md b/docs/index.md index c3129b935..a3dfa7fc7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,61 +7,51 @@ published: true # Introduction to Fluxtion -Welcome to Fluxtion, and thanks for coming, hope you enjoy exploring :) - -Fluxtion is a java library utility that builds embeddable, reactive complex event processors for data in motion -streaming -applications. Suitable use cases include: - -- **Real-time applications** processing multiple event streams -- **Embedding within an existing system** No middleware vendor lock-in -- **Edge processing** executing on edge devices zero dependency -- **Low latency** response time in microseconds -- **Fast start times** supports ahead of time compilation - -Write simple clean Java code to create real-time applications. programs are quick to build, test, deploy and debug ,with -no dependencies. Data streams can be merged, filtered, aggregated, joined, grouped and enriched. Windowing of data is -fully supported. - -A full set of tools for debugging, tracing, auditing and visualisation are provided to reduce development and support -costs. - -### Cant wait? [Dive into our 5 minute Fluxtion hello world](overview/detailpages/helloworld_imperative.html) - -## What is Fluxtion - -Fluxtion is a library that employs incremental computation and data flow programming for realtime data. Basically -Fluxtion is like a spreadsheet on steroids for realtime processing. When a cell or node changes the whole Fluxtion graph -is re-evaluated only recalculating nodes that are updated. - -Incremental computing is an approach that aims to minimize the amount of work required to compute a result by reusing as -much of the previous computation as possible. This is achieved by computing only the parts of the result that have -changed since the last time the computation was performed. This approach is often used in interactive systems, such as -spreadsheets, where computations need to be performed quickly and in response to user input. +Fluxtion is a java utility that builds embeddable dependency injection containers for use as a low latency event +processor within streaming applications. The Fluxtion DI container combines construction, instance lifecycle and event +dispatch, supporting: + +
+
+
+
    +
  • Streaming event processing
  • +
  • AOT compilation for fast start
  • +
  • Spring integration
  • +
+
+
+
+
+
    +
  • Low latency microsecond response
  • +
  • Event sourcing compatible
  • +
  • Functional and imperative construction
  • +
+
+
+
-Data flow programming, on the other hand, is an approach that focuses on the flow of data through a system. In a data -flow system, data is represented as streams of values that flow through a network of processing nodes. Each node -performs a specific operation on the data, and the results are passed on to the next node in the network. This approach -is often used in systems that process large amounts of data, such as signal processing and data analysis. +{: .note } +Developers concentrate on developing and extending business logic, dependency injection and event dispatch is handled by the +container. -A combined approach of incremental computation and data flow programming can offer several benefits over using either -approach alone. This combined approach can be particularly useful in systems that process large amounts of data in -real-time. +## Automatic event dispatch -In this approach, the data is represented as streams of values that flow through a network of processing nodes, as in -data flow programming. However, each node performs incremental computation, meaning it only processes the parts of the -stream that have changed since the last time the computation was performed. +The container exposes event consumer end-points, routing events as methods calls to beans within the container +via an internal dispatcher. The internal dispatcher propagates event notification through the object graph. -This approach can help reduce the computational cost of processing large amounts of data by avoiding redundant -computations. Instead of recomputing the entire data stream every time a new input arrives, the system only computes the -parts of the stream that have changed. +Fluxtion leverages the familiar dependency injection workflow for constructing the object graph. Annotated +event handler and trigger methods are dispatch targets. When building a container Fluxtion uses the annotations to +calculate the dispatch call trees for the internal dispatcher. A bean can export multiple service interfaces or just a +single method. For exported interfaces the container generates proxies that routes calls from the proxy handler methods +to the container's dispatcher. -Additionally, this approach can improve the responsiveness of the system by processing the data in real-time as it -arrives, rather than waiting for the entire data stream to be processed before producing an output. +## Event sourcing -Overall, a combined approach of incremental computation and data flow programming can provide a powerful and efficient -solution for processing large amounts of data in real-time, making it suitable for a wide range of applications, -including real-time data analysis, streaming video and audio processing, and more. +If an event sourcing architectural style is followed the application behaviour will be completely reflected in the +test environment. Data driven clocks and audit logs tracing method call stacks are supported, when combined with event +replay this gives the developer a powerful and easy to use toolset for supporting a deployed system. ## Fluxtion dependencies @@ -96,84 +86,16 @@ implementation 'com.fluxtion:compiler:{{site.fluxtion_version}}' -Fluxtion dependency description +### Dependency description | Fluxtion dependency | Example use | Description | 3rd party
dependencies | |---------------------|-----------------------------------------|-------------------------------------------------------|-----------------------------| | Compiler | Fluxtion#interpret
Fluxtion#compile | Generates the EventProcessor
from a description | Many | | Runtime | EventProcessor#onEvent | Runtime dispatch of events and helper libraries | None | -It is possible to use ```Fluxtion#compile``` to create an EventProcessor ahead of time and then only the runtime -library is required on the running classpath to support the source code generated EventProcessor. In this case -set the scope to provided in maven. - -## Key terms - -| Term | Description | -|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------| -| Event | An event is any valid java instance that is submitted to the event processor | -| Stream | A stream is a set of events | -| EventProcessor | Processes the event stream with user defined logic. An EventProcessor instance is generated by Fluxtion | -| Node | A pojo instance that is node within an EventProcessor | -| Event propagation | Invoking methods in a topological order on nodes within an EventProcessor | -| Event handler method | A method on a node that is an entry point for processing an external event | -| Trigger method | A method on a node that is triggered once all parent nodes have completed their trigger methods | -| Event notification | Trigger or event handler methods notify a change by returning a boolean flag to control event propagation | -| Graph space | Construction of the meta model occurs in graph space, before generating the EventProcessor and after the user has provided all node information | - -## Steps to create an EventProcessor instance - -1. **Describe** the processing logic in user code -2. **Generate** the EventProcessor by supplying a description to the Fluxtion eventProcessorGenerator -3. **Process** events in the Fluxtion generated EventProcessor instance from (2) - -# Processing events in a stream processor - -There are three main steps to building and running a stream processor application using Fluxtion - -## Step 1: Describe processing logic - -Describe the values that are calculated and actions invoked in response to an incoming event. Fluxtion provides two -api's to describe the processing logic: - -1. [A set of annotations]({{site.fluxtion_src_runtime}}/annotations) - that mark members of user written classes as being managed by the event processor -2. [A java 8 stream like api]({{site.fluxtion_src_compiler}}/builder/stream) - , that can describe processing with a fluent functional style - -## Step 2: Build an EventProcessor - -Fluxtion provides a eventProcessorGenerator that converts the description into an executable -[EventProcessor]({{site.fluxtion_src_runtime}}/EventProcessor.java) -instance. The eventProcessorGenerator -is invoked from -[Fluxtion]({{site.fluxtion_src_compiler}}/Fluxtion.java) -with one of two utility methods: - -1. **compile**: this generates a java source code version of the EventProcessor. The file is compiled in process and - used - to handle events. Total nodes are limited to the number of elements a source file can handle -2. **interpret**: Creates an in memory model of the processing backed with data structures. Can support millions of - nodes - -## Step 3: Process events - -Once the -[EventProcessor]({{site.fluxtion_src_runtime}}/EventProcessor.java) -has been generated the instance is ready to consume events. The EventProcessor has a lifecycle so **init must be called -before sending any events for processing**. - -The application pulls events from any source and invokes ```EventProcessor#onEvent``` - -# Application integration ---- - -![](images/integration-overview.png) - -A Fluxtion event processor embeds within a user application, processing events, -publishing events to sinks or interacting with user classes. Events are feed from -the application directly into the processor or into a pipeline. A pipeline provides -additional capabilities such as threading, scheduling, auditing, access control. +It is possible to use one of the [Fluxtion]({{site.fluxtion_src_compiler}}/Fluxtion.java) compileAOT methods to generate an +EventProcessor ahead of time. An aot generated event processor only requires the runtime library on the classpath. In +this case set the scope of the compiler dependency to provided in maven. \ No newline at end of file diff --git a/docs/sections/deploying-testing.md b/docs/sections/deploying-testing.md new file mode 100644 index 000000000..387013dc5 --- /dev/null +++ b/docs/sections/deploying-testing.md @@ -0,0 +1,10 @@ +--- +title: Deploying and testing +has_children: true +nav_order: 3 +published: true +--- + +# Introduction + +Hello \ No newline at end of file diff --git a/docs/sections/examples.md b/docs/sections/examples.md new file mode 100644 index 000000000..d227abbc2 --- /dev/null +++ b/docs/sections/examples.md @@ -0,0 +1,11 @@ +--- +title: Examples +has_children: true +nav_order: 5 +published: true +--- + +# Introduction + +A set of examples that explore the usage of Fluxtion in a variety of scenarios. All examples are on github as a single +project, cloning the repo will help the reader explore the code locally and improve the learning experience. \ No newline at end of file diff --git a/docs/sections/examples/spring_integration.md b/docs/sections/examples/spring_integration.md new file mode 100644 index 000000000..fbc711f4c --- /dev/null +++ b/docs/sections/examples/spring_integration.md @@ -0,0 +1,363 @@ +--- +title: Spring integration +parent: Examples +#grand_parent: Old stuff +has_children: false +nav_order: 1 +published: true +example_src: https://github.com/v12technology/fluxtion-examples/tree/main/cookbook/src/main/java/com/fluxtion/example/cookbook/spring +resources_src: https://github.com/v12technology/fluxtion-examples/tree/main/cookbook/src/main/resources/com/fluxtion/example/cookbook/spring +--- + +## Introduction + +Fluxtion is a dependency injection container specialised for event driven application deployments. The container +exposes event consumer end-points, routing events as methods calls to beans within the running container. A bean +registers a method as an event-handler by using Fluxtion annotations. Any beans referencing an event-handler bean will +be triggered by the container as the internal dispatcher propagates an event notification through the object graph. + +All methods on an interface can be exported by annotating the interface in an implementing bean, the container exports +the interface methods as a single service. A client can look up an exported service by interface type using the +container apis. All method calls on the service proxy are routed through the container's internal dispatcher. + +Spring is a popular DI container in the java world, this tutorial demonstrates how the construction logic of spring can +be combined with the dispatching logic of Fluxtion to simplify building event driven applications. The goal is to allow +the developer to concentrate on developing application logic while the container automatically builds the object graph +and constructs event dispatch logic. + +This example builds a small banking application, that supports credit, debit, account query, credit checking, +opening hours and persistence functions. The methods are grouped into service interfaces that are exposed by the +container. + +The steps to combine spring and fluxtion: + +- Create service interfaces that define the api of the banking app +- Create implementing classes for the service interfaces +- Create a spring config file declaring instances the DI container will manage +- Use Fluxtion annotations to export services and define event notification methods +- Pass the spring config file to the Fluxtion compiler and generate the DI container AOT +- Create an instance of the DI container and locate the service interfaces +- Use the service interfaces in the sample application + +## Application structure + +[See the example on GitHUb]({{page.example_src}}), top level package is `com.fluxtion.example.cookbook.spring.service`. + +Package structure: + +- **top level**: Banking app and a sample main +- **service**: interfaces the sample main and banking app invoke +- **node**: implementations of the service interfaces +- **data**: data types used by services +- **generation**: location of the Fluxtion ahead of time generated DI container + +## Spring beans +Fluxtion provides support for building the DI container using spring configuration. The example uses [a spring +configuration]({{page.resources_src}}/spring-account.xml) file to declare the beans that will be managed by the Fluxtion DI container: + +{% highlight xml %} + + + + + + + + + + + + + + + + + + + + +{% endhighlight %} + +Once the file is created the file location can be passed to Fluxtion to build the container: + +{% highlight java %} +ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("com/fluxtion/example/cookbook/spring/spring-account.xml"); +eventProcessor = FluxtionSpring.interpret(context); +{% endhighlight %} + +## Invoking a service + +The BankingApp instance creates an instance of the AOT generated Fluxtion DI container and provides access to container +exported services. The service reference the client code receives is a proxy the DI container creates, the +proxy handler routes method calls to instances managed by the container. + +Services the DI container exposes are event driven, they are designed to be invoked asynchronously and do not return +application values to client code. A service method can optionally return a boolean value that is used by the container +as an event propagation flag. If the flag is true then child references are notified the parent has changed due to an +external event. Child instances are notified of event propagation by the container calling a trigger method. A trigger +method is any zero argument method marked with an `OnTrigger` annotation. `OnTrigger` methods return an event +propagation flag to control event notification dispatch in the same was as exported service methods. + +The fluxtion DI container manages all the proxy creation, event dispatch to services, monitoring dirty flags and +propagating event notifications to child references. To access an exported service client code calls: + +{% highlight java %} +T exportedService = eventProcessor.getExportedService(); +{% endhighlight %} + +### Main method execution + +The main method creates an instance of the BankingApp, rerieves service interfaces and invokes application methods on +the interfaces. It is expected the BankingApp would be instantiated and used within a larger application that marshalls +client requests from the network and then invokes the BankingApp appropiately. + +{% highlight java %} +public class Main { + + public static void main(String[] args) { + BankingApp bankingApp = new BankingApp(GenerationStrategy.USE_AOT); + //get services + Account accountService = bankingApp.getBankAccount(); + BankingOperations bankControllerService = bankingApp.getBankingOperations(); + CreditCheck creditCheckService = bankingApp.getCreditCheck(); + //persistence + FileDataStore fileDataStore = new FileDataStore(Paths.get("data/spring/bank")); + bankControllerService.setDataStore(fileDataStore); + //replay state + fileDataStore.replay(bankingApp.getEventConsumer()); + + bankingApp.start(); + //should reject unknown account + accountService.deposit(999, 250.12); + + //get opening balance for acc 100 + accountService.publishBalance(100); + + //should reject bank closed + accountService.openAccount(100); + accountService.deposit(100, 250.12); + + //open bank + bankControllerService.openForBusiness(); + accountService.deposit(100, 250.12); + + //blacklist an account + creditCheckService.blackListAccount(100); + accountService.deposit(100, 46.90); + + //remove account from blacklist + creditCheckService.whiteListAccount(100); + accountService.deposit(100, 46.90); + + //close bank + bankControllerService.closedForBusiness(); + accountService.deposit(100, 13); + } + +} +{% endhighlight %} + +running the main method prints the following to the console: + +{% highlight text %} +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=999, amount=250.12, debit=false] +[INFO] AccountNode - reject unknown account:999 +[INFO] ResponsePublisher - response reject:Transaction[accountNumber=999, amount=250.12, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] AccountNode - ------------------------------------------------------ +[INFO] ResponsePublisher - account:100, balance:3267.22 +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - opened account:100 +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=100, amount=250.12, debit=false] +[INFO] CreditCheckNode - credit check passed +[WARN] CentralTransactionProcessor - reject bank closed +[INFO] ResponsePublisher - response reject:Transaction[accountNumber=100, amount=250.12, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] CentralTransactionProcessor - open accepting transactions +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=100, amount=250.12, debit=false] +[INFO] CreditCheckNode - credit check passed +[INFO] CentralTransactionProcessor - accept bank open +[INFO] AccountNode - updated balance:3517.3399999999997 account:100 +[INFO] ResponsePublisher - response accept:Transaction[accountNumber=100, amount=250.12, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] CreditCheckNode - credit check blacklisted:100 +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=100, amount=46.9, debit=false] +[WARN] CreditCheckNode - credit check failed +[INFO] ResponsePublisher - response reject:Transaction[accountNumber=100, amount=46.9, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[INFO] CreditCheckNode - credit check whitelisted:100 +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=100, amount=46.9, debit=false] +[INFO] CreditCheckNode - credit check passed +[INFO] CentralTransactionProcessor - accept bank open +[INFO] AccountNode - updated balance:3564.24 account:100 +[INFO] ResponsePublisher - response accept:Transaction[accountNumber=100, amount=46.9, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + +[WARN] CentralTransactionProcessor - closed rejecting all transactions +[INFO] AccountNode - ------------------------------------------------------ +[INFO] AccountNode - deposit request:Transaction[accountNumber=100, amount=13.0, debit=false] +[INFO] CreditCheckNode - credit check passed +[WARN] CentralTransactionProcessor - reject bank closed +[INFO] ResponsePublisher - response reject:Transaction[accountNumber=100, amount=13.0, debit=false] +[INFO] AccountNode - request complete +[INFO] AccountNode - ------------------------------------------------------ + + +Process finished with exit code 0 +{% endhighlight %} + +## Exporting a service + +To export a service the following steps are required: + +- Create an interface and then implement the interface with a concrete class +- The implementation class must extend ```ExportFunctionNode``` +- Mark the interface to export with ```@ExportService``` annotation + +For example to export the CreditCheck service: + +### CreditCheck interface + +{% highlight java %} +public interface CreditCheck { + void blackListAccount(int accountNumber); + void whiteListAccount(int accountNumber); +} + +{% endhighlight %} + +### CreditCheckNode concrete class + +The CreditCheckNode implements two interfaces CreditCheck and TransactionProcessor. Only the CreditCheck interface +methods are exported as this is only interface marked with ```@ExportService``` + +{% highlight java %} +public class CreditCheckNode extends ExportFunctionNode implements @ExportService CreditCheck, TransactionProcessor { + + private transient Set blackListedAccounts = new HashSet<>(); + private TransactionProcessor transactionSource; + private ResponsePublisher responsePublisher; + + @Override + @NoPropagateFunction + public void blackListAccount(int accountNumber) { + log.[INFO]("credit check blacklisted:{}", accountNumber); + blackListedAccounts.add(accountNumber); + } + + @Override + @NoPropagateFunction + public void whiteListAccount(int accountNumber) { + log.[INFO]("credit check whitelisted:{}", accountNumber); + blackListedAccounts.remove(accountNumber); + } + + public boolean propagateParentNotification(){ + Transaction transaction = transactionSource.currentTransactionRequest(); + int accountNumber = transaction.accountNumber(); + if(blackListedAccounts.contains(accountNumber)){ + log.[WARN]("credit check failed"); + transactionSource.rollbackTransaction(); + responsePublisher.rejectTransaction(transaction); + return false; + } + log.[INFO]("credit check passed"); + return true; + } + + @Override + public Transaction currentTransactionRequest() { + return transactionSource.currentTransactionRequest(); + } + + @Override + public void rollbackTransaction() { + transactionSource.rollbackTransaction(); + } + + @Override + public void commitTransaction(){ + transactionSource.commitTransaction(); + } + +} +{% endhighlight %} + +Notice the two CreditCheck methods are annotated with ```@NoPropagateFunction```, telling Fluxtion that no event +propagation will occur when either of these methods is invoked. The credit black list is a map and these methods should +only change the state of the internal map and not cause further processing to occur in the object graph. + +## Locating a service + +The steps required to locate a service and invoke methods on it are: + +- Build the DI container using one of the Fluxtion build methods +- To correctly intitialise the container call ```eventProcessor.init()``` on the DI instance +- To access the service call ```T service = eventProcessor.getExportedService()``` with the desired service type T + +### Accessing CreditCheck service + +The code below uses an enum to allow the user to select the DI generation strategy, in this example we are using the +AOT strategy. After eventprocessor generation the exported service are located and assigned to member variables in +the BankingApp class. + +```java +public class BankingApp { + + private final EventProcessor eventProcessor; + private final Account bankAccount; + private final CreditCheck creditCheck; + private final BankingOperations bankingOperations; + private final Consumer eventConsumer; + + @SneakyThrows + public BankingApp(GenerationStrategy generationStrategy) { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("com/fluxtion/example/cookbook/spring/spring-account.xml"); + eventProcessor = switch (generationStrategy) { + case USE_AOT -> new SpringBankEventProcessor(); + case INTERPRET -> FluxtionSpring.interpret(context); + case COMPILE -> FluxtionSpring.compile(context); + case GENERATE_AOT -> FluxtionSpring.compileAot(context, c -> { + c.setPackageName("com.fluxtion.example.cookbook.spring.generated"); + c.setClassName("SpringBankEventProcessor"); + }); + }; + eventProcessor.init(); + bankAccount = eventProcessor.getExportedService(); + creditCheck = eventProcessor.getExportedService(); + bankingOperations = eventProcessor.getExportedService(); + eventConsumer = eventProcessor::onEvent; + } + + public CreditCheck getCreditCheck() { + return creditCheck; + } +} +``` + +**line 22-24** acquire the exported services from the container by interface type + diff --git a/docs/overview/helloworld_imperative.md b/docs/sections/helloworld_imperative.md similarity index 99% rename from docs/overview/helloworld_imperative.md rename to docs/sections/helloworld_imperative.md index 8066e4417..39f71fb61 100644 --- a/docs/overview/helloworld_imperative.md +++ b/docs/sections/helloworld_imperative.md @@ -1,6 +1,5 @@ --- -title: Helloworld -parent: Overview +title: Hello fluxtion world has_children: false nav_order: 2 published: true diff --git a/docs/cookbook-functional/cookbook.md b/docs/sections/old-stuff/cookbook-functional.md similarity index 92% rename from docs/cookbook-functional/cookbook.md rename to docs/sections/old-stuff/cookbook-functional.md index faae31f0b..c5181c253 100644 --- a/docs/cookbook-functional/cookbook.md +++ b/docs/sections/old-stuff/cookbook-functional.md @@ -1,5 +1,6 @@ --- title: Cookbook functional +parent: Old stuff has_children: true nav_order: 103 published: true diff --git a/docs/cookbook-functional/combining_imperative.md b/docs/sections/old-stuff/cookbook-functional/combining_imperative.md similarity index 99% rename from docs/cookbook-functional/combining_imperative.md rename to docs/sections/old-stuff/cookbook-functional/combining_imperative.md index 0cae0b222..8b1295026 100644 --- a/docs/cookbook-functional/combining_imperative.md +++ b/docs/sections/old-stuff/cookbook-functional/combining_imperative.md @@ -1,6 +1,7 @@ --- title: Combining imperative parent: Cookbook functional +grand_parent: Old stuff has_children: false nav_order: 3 published: true diff --git a/docs/cookbook-functional/dynamic_filtering.md b/docs/sections/old-stuff/cookbook-functional/dynamic_filtering.md similarity index 99% rename from docs/cookbook-functional/dynamic_filtering.md rename to docs/sections/old-stuff/cookbook-functional/dynamic_filtering.md index 126247b1b..b81c02560 100644 --- a/docs/cookbook-functional/dynamic_filtering.md +++ b/docs/sections/old-stuff/cookbook-functional/dynamic_filtering.md @@ -1,6 +1,7 @@ --- title: Dynamic filtering parent: Cookbook functional +grand_parent: Old stuff has_children: false nav_order: 2 published: true diff --git a/docs/cookbook-functional/helloworld_functional.md b/docs/sections/old-stuff/cookbook-functional/helloworld_functional.md similarity index 98% rename from docs/cookbook-functional/helloworld_functional.md rename to docs/sections/old-stuff/cookbook-functional/helloworld_functional.md index 1352d3d6e..427b06fca 100644 --- a/docs/cookbook-functional/helloworld_functional.md +++ b/docs/sections/old-stuff/cookbook-functional/helloworld_functional.md @@ -1,6 +1,7 @@ --- title: Helloworld functional parent: Cookbook functional +grand_parent: Old stuff has_children: false nav_order: 1 published: true @@ -23,7 +24,7 @@ Code is available as a [maven project]({{page.example_src}}) Graphical representation of the processing graph that Fluxtion will generate. -![](../images/helloworld_eventstream.png) +![](../../../images/helloworld_eventstream.png) ## Dependencies diff --git a/docs/cookbook-functional/subscriptiption_functional.md b/docs/sections/old-stuff/cookbook-functional/subscriptiption_functional.md similarity index 99% rename from docs/cookbook-functional/subscriptiption_functional.md rename to docs/sections/old-stuff/cookbook-functional/subscriptiption_functional.md index 847548283..17ce2ef7d 100644 --- a/docs/cookbook-functional/subscriptiption_functional.md +++ b/docs/sections/old-stuff/cookbook-functional/subscriptiption_functional.md @@ -1,6 +1,7 @@ --- title: EventFeed integration parent: Cookbook functional +grand_parent: Old stuff has_children: false nav_order: 4 published: true diff --git a/docs/cookbook/cookbook.md b/docs/sections/old-stuff/cookbook.md similarity index 90% rename from docs/cookbook/cookbook.md rename to docs/sections/old-stuff/cookbook.md index 203b8ceda..58466feeb 100644 --- a/docs/cookbook/cookbook.md +++ b/docs/sections/old-stuff/cookbook.md @@ -1,5 +1,6 @@ --- title: Cookbook +parent: Old stuff has_children: true nav_order: 102 published: true diff --git a/docs/cookbook/audit_log.md b/docs/sections/old-stuff/cookbook/audit_log.md similarity index 99% rename from docs/cookbook/audit_log.md rename to docs/sections/old-stuff/cookbook/audit_log.md index 0e2c22f54..8b01637e2 100644 --- a/docs/cookbook/audit_log.md +++ b/docs/sections/old-stuff/cookbook/audit_log.md @@ -2,6 +2,7 @@ title: Audit logging parent: Cookbook has_children: false +grand_parent: Old stuff nav_order: 4 published: true example_src: https://github.com/v12technology/fluxtion-examples/tree/main/cookbook/src/main/java/com/fluxtion/example/cookbook/auditlog @@ -275,7 +276,7 @@ Process finished with exit code 0 ### EventProcessor graph for the example -![](../images/audit/Processor.png) +![](../../../images/audit/Processor.png) diff --git a/docs/cookbook/injecting_context.md b/docs/sections/old-stuff/cookbook/injecting_context.md similarity index 98% rename from docs/cookbook/injecting_context.md rename to docs/sections/old-stuff/cookbook/injecting_context.md index 2a83c1145..699d01e33 100644 --- a/docs/cookbook/injecting_context.md +++ b/docs/sections/old-stuff/cookbook/injecting_context.md @@ -1,6 +1,7 @@ --- title: Injecting user context parent: Cookbook +grand_parent: Old stuff has_children: false nav_order: 9 published: true diff --git a/docs/cookbook/injecting_runtime_instances.md b/docs/sections/old-stuff/cookbook/injecting_runtime_instances.md similarity index 99% rename from docs/cookbook/injecting_runtime_instances.md rename to docs/sections/old-stuff/cookbook/injecting_runtime_instances.md index a037dd453..a3c8ef9dd 100644 --- a/docs/cookbook/injecting_runtime_instances.md +++ b/docs/sections/old-stuff/cookbook/injecting_runtime_instances.md @@ -1,6 +1,7 @@ --- title: Injecting at runtime - InstanceSupplier parent: Cookbook +grand_parent: Old stuff has_children: false nav_order: 6 published: true diff --git a/docs/cookbook/injecting_runtime_instances_lookup.md b/docs/sections/old-stuff/cookbook/injecting_runtime_instances_lookup.md similarity index 99% rename from docs/cookbook/injecting_runtime_instances_lookup.md rename to docs/sections/old-stuff/cookbook/injecting_runtime_instances_lookup.md index 1e41af593..f5a76550f 100644 --- a/docs/cookbook/injecting_runtime_instances_lookup.md +++ b/docs/sections/old-stuff/cookbook/injecting_runtime_instances_lookup.md @@ -1,6 +1,7 @@ --- title: Injecting at runtime - instance Lookup parent: Cookbook +grand_parent: Old stuff has_children: false nav_order: 5 published: true diff --git a/docs/cookbook/integrate_lombok.md b/docs/sections/old-stuff/cookbook/integrate_lombok.md similarity index 98% rename from docs/cookbook/integrate_lombok.md rename to docs/sections/old-stuff/cookbook/integrate_lombok.md index e787513ff..72fd99314 100644 --- a/docs/cookbook/integrate_lombok.md +++ b/docs/sections/old-stuff/cookbook/integrate_lombok.md @@ -1,6 +1,7 @@ --- title: Integrating lombok parent: Cookbook +grand_parent: Old stuff has_children: false nav_order: 7 published: true diff --git a/docs/cookbook/node_callbacks.md b/docs/sections/old-stuff/cookbook/node_callbacks.md similarity index 99% rename from docs/cookbook/node_callbacks.md rename to docs/sections/old-stuff/cookbook/node_callbacks.md index 194b32bbd..4c99f2347 100644 --- a/docs/cookbook/node_callbacks.md +++ b/docs/sections/old-stuff/cookbook/node_callbacks.md @@ -1,6 +1,7 @@ --- title: Node callback pattern parent: Cookbook +grand_parent: Old stuff has_children: false nav_order: 3 published: true diff --git a/docs/cookbook/parallel_processing.md b/docs/sections/old-stuff/cookbook/parallel_processing.md similarity index 99% rename from docs/cookbook/parallel_processing.md rename to docs/sections/old-stuff/cookbook/parallel_processing.md index b492bdcdd..161b57c89 100644 --- a/docs/cookbook/parallel_processing.md +++ b/docs/sections/old-stuff/cookbook/parallel_processing.md @@ -1,6 +1,7 @@ --- title: Parallel processing parent: Cookbook +grand_parent: Old stuff has_children: false nav_order: 8 published: true @@ -127,7 +128,7 @@ public class Main { The execution graph image shows a set of tasks are triggered from the RequestHandler instance and their outputs are gathered in the TaskCollector instance. -![](../images/parallel/parallel.png) +![](../../../images/parallel/parallel.png) ## Running the example diff --git a/docs/cookbook/spring_integration.md b/docs/sections/old-stuff/cookbook/spring_integration.md similarity index 99% rename from docs/cookbook/spring_integration.md rename to docs/sections/old-stuff/cookbook/spring_integration.md index ba6e6b2a5..9c624cdee 100644 --- a/docs/cookbook/spring_integration.md +++ b/docs/sections/old-stuff/cookbook/spring_integration.md @@ -1,6 +1,7 @@ --- title: Spring integration parent: Cookbook +grand_parent: Old stuff has_children: false nav_order: 1 published: true diff --git a/docs/cookbook/subscription_imperative.md b/docs/sections/old-stuff/cookbook/subscription_imperative.md similarity index 97% rename from docs/cookbook/subscription_imperative.md rename to docs/sections/old-stuff/cookbook/subscription_imperative.md index 892e83a13..5e02ade2e 100644 --- a/docs/cookbook/subscription_imperative.md +++ b/docs/sections/old-stuff/cookbook/subscription_imperative.md @@ -1,6 +1,7 @@ --- title: EventFeed integration parent: Cookbook +grand_parent: Old stuff has_children: false nav_order: 2 published: true @@ -32,18 +33,18 @@ Diagrams below demonstrate the interaction between key subscription components f ### Register an EventFeed with EventProcessor
-![](../images/subscription/subscription_register.png) +![](../../../images/subscription/subscription_register.png) ### SharePriceNode subscribes to symbols
-![](../images/subscription/subscibe_to_symbol.png) +![](../../../images/subscription/subscibe_to_symbol.png) ### Publish data from legacy app
-![](../images/subscription/publish_data.png) +![](../../../images/subscription/publish_data.png) ## Example diff --git a/docs/development.md b/docs/sections/old-stuff/development.md similarity index 76% rename from docs/development.md rename to docs/sections/old-stuff/development.md index ec93ab8ce..a192dd1d6 100644 --- a/docs/development.md +++ b/docs/sections/old-stuff/development.md @@ -1,7 +1,8 @@ --- title: Development +parent: Old stuff has_children: true -nav_order: 2 +nav_order: 12 published: true --- diff --git a/docs/development/build_eventprocessor.md b/docs/sections/old-stuff/development/build_eventprocessor.md similarity index 97% rename from docs/development/build_eventprocessor.md rename to docs/sections/old-stuff/development/build_eventprocessor.md index 6ccadc239..06f51b602 100644 --- a/docs/development/build_eventprocessor.md +++ b/docs/sections/old-stuff/development/build_eventprocessor.md @@ -1,9 +1,10 @@ --- title: Build an EventProcessor parent: Development +grand_parent: Old stuff has_children: false nav_order: 1 -published: true +published: false --- # Build an EventProcessor diff --git a/docs/development/describe_processing.md b/docs/sections/old-stuff/development/describe_processing.md similarity index 95% rename from docs/development/describe_processing.md rename to docs/sections/old-stuff/development/describe_processing.md index e09a3cc26..c542b35b2 100644 --- a/docs/development/describe_processing.md +++ b/docs/sections/old-stuff/development/describe_processing.md @@ -1,9 +1,10 @@ --- title: Describe processing logic parent: Development +grand_parent: Old stuff has_children: false nav_order: 2 -published: true +published: false --- # Building the processing graph diff --git a/docs/development/streaming-building.md b/docs/sections/old-stuff/development/streaming-building.md similarity index 96% rename from docs/development/streaming-building.md rename to docs/sections/old-stuff/development/streaming-building.md index cf6c29571..242f7c972 100644 --- a/docs/development/streaming-building.md +++ b/docs/sections/old-stuff/development/streaming-building.md @@ -1,9 +1,10 @@ --- title: Functional support parent: Development +grand_parent: Old stuff has_children: false nav_order: 4 -published: true +published: false --- # Streaming api diff --git a/docs/overview/overview.md b/docs/sections/old-stuff/overview.md similarity index 98% rename from docs/overview/overview.md rename to docs/sections/old-stuff/overview.md index ef74fdb91..568a6fd15 100644 --- a/docs/overview/overview.md +++ b/docs/sections/old-stuff/overview.md @@ -24,7 +24,7 @@ When building a stream processing application the developer has to answer three Fluxtion is the automatic generation of the **WHEN** logic in a streaming application. Looking at the example diagram below Fluxtion acts as the arrows connecting components: -![](../images/flow-processing-example.png) +![](../../images/flow-processing-example.png) When a specific event is received only connected components are executed and always in the [correct predictable order](https://www.geeksforgeeks.org/topological-sorting/). diff --git a/docs/running.md b/docs/sections/old-stuff/running.md similarity index 81% rename from docs/running.md rename to docs/sections/old-stuff/running.md index 13318db81..ded61d95e 100644 --- a/docs/running.md +++ b/docs/sections/old-stuff/running.md @@ -1,7 +1,8 @@ --- title: Event stream processing +parent: Old stuff has_children: true -nav_order: 3 +nav_order: 13 published: true --- diff --git a/docs/running/minimal_runtime.md b/docs/sections/old-stuff/running/minimal_runtime.md similarity index 97% rename from docs/running/minimal_runtime.md rename to docs/sections/old-stuff/running/minimal_runtime.md index b74dacb96..b61230d93 100644 --- a/docs/running/minimal_runtime.md +++ b/docs/sections/old-stuff/running/minimal_runtime.md @@ -1,6 +1,7 @@ --- title: Zero dependency processor parent: Event stream processing +grand_parent: Old stuff has_children: false nav_order: 6 published: true @@ -24,7 +25,7 @@ To generate an event processor with no builder dependencies at runtime four step 1. Remove any calls to dynamically build a processor at runtime and use the fqn above to instantiate a statically generated processor, including test cases. 1. Update the pom file to exclude builder libraries as transitive dependencies. -The first three steps are covered in the previous [buildtime generation example](../old-stuff/starting/aot_compilation.md). +The first three steps are covered in the previous [buildtime generation example](../starting/aot_compilation.md). ### Build zero dependency artifact The builder libraries are compile time only and marked @@ -99,7 +100,7 @@ the relevant section are shown below. ## Artifact analysis As part of the build the maven shade plugin generates an uber jar that contains all the dependencies to run the application. The uber jar contains Fluxtion runtime libraries, application classes and slf4j interfaces only. -The table below shows a comparinson with the [prevous example](../old-stuff/starting/aot_compilation.md) where the +The table below shows a comparinson with the [prevous example](../starting/aot_compilation.md) where the final artifact contains all the Fluxtion builders and their transitive dependencies. | Fluxtion libraries | Size | External library count | diff --git a/docs/running/processing_events.md b/docs/sections/old-stuff/running/processing_events.md similarity index 99% rename from docs/running/processing_events.md rename to docs/sections/old-stuff/running/processing_events.md index d57514f19..bd5c16ecb 100644 --- a/docs/running/processing_events.md +++ b/docs/sections/old-stuff/running/processing_events.md @@ -1,6 +1,7 @@ --- title: Processing event streams parent: Event stream processing +grand_parent: Old stuff has_children: false nav_order: 1 published: true diff --git a/docs/old-stuff/starting/aot_compilation.md b/docs/sections/old-stuff/starting/aot_compilation.md similarity index 100% rename from docs/old-stuff/starting/aot_compilation.md rename to docs/sections/old-stuff/starting/aot_compilation.md diff --git a/docs/old-stuff/starting/get_started.md b/docs/sections/old-stuff/starting/get_started.md similarity index 100% rename from docs/old-stuff/starting/get_started.md rename to docs/sections/old-stuff/starting/get_started.md diff --git a/docs/sections/oldstuff.md b/docs/sections/oldstuff.md new file mode 100644 index 000000000..6e09c8634 --- /dev/null +++ b/docs/sections/oldstuff.md @@ -0,0 +1,10 @@ +--- +title: Old stuff +has_children: true +nav_order: 6 +published: false +--- + +# Introduction + +Hello \ No newline at end of file diff --git a/docs/tooling.md b/docs/sections/quick-reference.md similarity index 50% rename from docs/tooling.md rename to docs/sections/quick-reference.md index 7d1b53d0b..37fbba956 100644 --- a/docs/tooling.md +++ b/docs/sections/quick-reference.md @@ -1,9 +1,10 @@ --- -title: Tooling +title: Quick reference has_children: true nav_order: 4 published: true --- +# Introduction -## Guide to Fluxtion developer toolset +Hello \ No newline at end of file diff --git a/docs/sections/technical-deep-dive/event-processing.md b/docs/sections/technical-deep-dive/event-processing.md new file mode 100644 index 000000000..0409cd88e --- /dev/null +++ b/docs/sections/technical-deep-dive/event-processing.md @@ -0,0 +1,9 @@ +--- +title: Event processing +parent: Technical deep dive +has_children: false +nav_order: 1 +published: true +--- + +# Introduction \ No newline at end of file diff --git a/docs/overview/intro.md b/docs/sections/technical-deepdive.md similarity index 72% rename from docs/overview/intro.md rename to docs/sections/technical-deepdive.md index 07139924f..69ef8fae0 100644 --- a/docs/overview/intro.md +++ b/docs/sections/technical-deepdive.md @@ -1,8 +1,7 @@ --- -title: What is Fluxtion -parent: Overview -has_children: false -nav_order: 1 +title: Technical deep dive +has_children: true +nav_order: 3 published: true --- @@ -22,9 +21,9 @@ their reach without the support of the spreadsheet engine. Fluxtion brings this spreadsheet like paradigm and efficiency benefits to the realtime processing world. Methods on beans are the formula cells, references between beans are the formula dependencies. The Fluxtion dependency analyser uses the dependency information to calculate the global set of dependencies. When any bean is updated from an external -event dependent recalculation methods are called. +event dependent recalculation methods are called. -With Fluxtion a single junior developer can build and maintain event driven logic that would have previously required a +With Fluxtion a single junior developer can build and maintain event driven logic that would have previously required a team of specialist experienced developers {: .info } @@ -46,9 +45,60 @@ team of specialist experienced developers In formal terms Fluxtion can be classified as a combination of incremental computation and data flow programming. +## Event sourcing + +If an event sourcing architectural style is followed the application behaviour will be completely reflected in the +test environment. Data driven clocks and audit logs tracing method call stacks are supported, when combined with event +replay this gives the developer a powerful and easy to use toolset for supporting a deployed system. + +## Fluxtion dependencies + +
+ + +
+
+
+{% highlight xml %} + + + com.fluxtion + runtime + {{site.fluxtion_version}} + + + com.fluxtion + compiler + {{site.fluxtion_version}} + + +{% endhighlight %} +
+
+
+
+{% highlight groovy %} +implementation 'com.fluxtion:runtime:{{site.fluxtion_version}}' +implementation 'com.fluxtion:compiler:{{site.fluxtion_version}}' +{% endhighlight %} +
+
+ +### Dependency description + +| Fluxtion dependency | Example use | Description | 3rd party
dependencies | +|---------------------|-----------------------------------------|-------------------------------------------------------|-----------------------------| +| Compiler | Fluxtion#interpret
Fluxtion#compile | Generates the EventProcessor
from a description | Many | +| Runtime | EventProcessor#onEvent | Runtime dispatch of events and helper libraries | None | + +It is possible to use one of the [Fluxtion]({{site.fluxtion_src_compiler}}/Fluxtion.java) compileAOT methods to generate an +EventProcessor ahead of time. An aot generated event processor only requires the runtime library on the classpath. In +this case set the scope of the compiler dependency to provided in maven. + + # Event dispatch Notification connections between beans are calculated at construction time using the same data that is used to add beans -to the DI container and annotations that mark recalculation methods. +to the DI container and annotations that mark recalculation methods. When the proxy event handler method is called on the container it dispatches with the following with logic: @@ -102,4 +152,9 @@ before sending any events for processing**. The application pulls events from any source and invokes ```EventProcessor#onEvent``` -![](../images/integration-overview.png) +![](../../images/integration-overview.png) + + + \ No newline at end of file From 565772345a5e9f93a85b941bf91e6cbd5a5cece3 Mon Sep 17 00:00:00 2001 From: command-line Date: Sun, 17 Sep 2023 21:11:17 +0100 Subject: [PATCH 202/228] docs --- docs/index.md | 57 ++++++++++++++++++++++------ docs/sections/old-stuff/index.md | 65 ++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 docs/sections/old-stuff/index.md diff --git a/docs/index.md b/docs/index.md index 912d0153e..f3488fee0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,15 +7,16 @@ published: true # Introduction -Fluxtion is a java utility that builds embeddable dependency injection containers for use as a low latency event -processor within streaming applications. Developers concentrate on developing and extending business logic, dependency -injection and event dispatch is handled by the container. +Fluxtion is a java development productivity tool that makes writing and maintaining event driven business logic cheaper +and quicker. The Fluxtion dependency injection container exposes user beans as event driven service endpoints. A +container instance can be connected to any event delivery system freeing the business logic from messaging vendor lock-in. {: .info } -Fluxtion = Dependency injection + Event dispatch -{: .fs-8 } +Fluxtion combines dependency injection and event dispatch +{: .fs-4 } -The Fluxtion container combines construction, instance lifecycle and event dispatch, supporting: +Developers concentrate on developing and extending business logic, dependency injection and realtime event dispatch is +handled by the container. The container supports:
@@ -38,20 +39,54 @@ The Fluxtion container combines construction, instance lifecycle and event dispa
+# The cost of complexity problem + +Increasing system complexity makes delivery of new features expensive and time-consuming to deliver. Efficiently managing +complexity reduces both operational costs and time to market for new functionality, critical for a business to remain +profitable in a competitive environment. + +Event driven systems have two types of complexity to manage: + +- Delivering events to application components in a fault-tolerant predictable fashion. +- Developing application logic responses to events that meets business requirements + +Initially all the project complexity centres on the event delivery system, but over time this system becomes stable and +the complexity demands are minimal. Pre-packaged event delivery systems are a common solution to control complexity and +cost of event distribution. The opposite is true for event driven application logic, functional requirements increase +over time and developing application logic becomes ever more complex and expensive to deliver. + +{: .info } +Fluxtion minimises the cost of developing event driven business logic +{: .fs-4 } + +# Combining dependency injection and event processing + +The introduction of dependency injection gave developers a consistent approach to linking application components. +Fluxtion extends dependency injection to support container managed event driven beans. Extending a familiar development +pattern has the following benefits: +- Shallow learning curve for developers to use Fluxtion effectively +- Consistent programming model for event driven logic increases developer productivity +- Re-use of industrial quality and predictable event dispatch model + +{: .info } +Familiar programming model simplifies Fluxtion integration +{: .fs-4 } ## Dependency injection container -Fluxtion builds a dependency injection container from configuration information given by the programmer. Functions -supported by the container include: creating instances, injecting references between beans, setting properties, calling -lifecycle methods, factory methods, singleton injection, named references, constructor and setter injection. + +Fluxtion builds a dependency injection container from configuration information given by the programmer. Functions +supported by the container include: creating instances, injecting references between beans, setting properties, calling +lifecycle methods, factory methods, singleton injection, named references, constructor and setter injection. Configuration data can be programmatic, spring xml config, yaml or custom data format. There are three options for building a container: + - Interpreted - built and run in process, uses dynamic dispatch can handle millions of nodes - Compiled - static analysis, code generated and compiled in process. handles thousands of nodes - Compiled AOT - code generated at build time, zero cost start time when deployed -Fluxtion DI containers are very lightweight and designed to be run within an application. Multiple containers can be -used within a single application each container providing specialised processing. +Fluxtion DI containers are very lightweight and designed to be run within an application. Multiple containers can be +used within a single application each container providing specialised business processing logic. ## Automatic event dispatch diff --git a/docs/sections/old-stuff/index.md b/docs/sections/old-stuff/index.md new file mode 100644 index 000000000..c2c80eab8 --- /dev/null +++ b/docs/sections/old-stuff/index.md @@ -0,0 +1,65 @@ +--- +title: Overview +has_children: false +nav_order: 1 +published: false +--- + +# Introduction + +Fluxtion is a java utility that builds embeddable dependency injection containers for use as a low latency event +processor within streaming applications. Developers concentrate on developing and extending business logic, dependency +injection and event dispatch is handled by the container. + +{: .info } +Fluxtion = Dependency injection + Event dispatch +{: .fs-8 } + +The Fluxtion container combines construction, instance lifecycle and event dispatch, supporting: + +
+
+
+
    +
  • Streaming event processing
  • +
  • AOT compilation for fast start
  • +
  • Spring integration
  • +
+
+
+
+
+
    +
  • Low latency microsecond response
  • +
  • Event sourcing compatible
  • +
  • Functional and imperative construction
  • +
+
+
+
+ + +## Dependency injection container +Fluxtion builds a dependency injection container from configuration information given by the programmer. Functions +supported by the container include: creating instances, injecting references between beans, setting properties, calling +lifecycle methods, factory methods, singleton injection, named references, constructor and setter injection. +Configuration data can be programmatic, spring xml config, yaml or custom data format. + +There are three options for building a container: +- Interpreted - built and run in process, uses dynamic dispatch can handle millions of nodes +- Compiled - static analysis, code generated and compiled in process. handles thousands of nodes +- Compiled AOT - code generated at build time, zero cost start time when deployed + +Fluxtion DI containers are very lightweight and designed to be run within an application. Multiple containers can be +used within a single application each container providing specialised processing. + +## Automatic event dispatch + +The container exposes event consumer end-points, routing events as methods calls to beans within the container +via an internal dispatcher. The internal dispatcher propagates event notification through the object graph. + +Fluxtion leverages the familiar dependency injection workflow for constructing the object graph. Annotated +event handler and trigger methods are dispatch targets. When building a container Fluxtion uses the annotations to +calculate the dispatch call trees for the internal dispatcher. A bean can export multiple service interfaces or just a +single method. For exported interfaces the container generates proxies that routes calls from the proxy handler methods +to the container's dispatcher. From 44d758aa53065d8e612910b21273af087cde8d88 Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 20 Sep 2023 18:57:59 +0100 Subject: [PATCH 203/228] docs --- docs/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index f3488fee0..70bbebd89 100644 --- a/docs/index.md +++ b/docs/index.md @@ -12,7 +12,7 @@ and quicker. The Fluxtion dependency injection container exposes user beans as e container instance can be connected to any event delivery system freeing the business logic from messaging vendor lock-in. {: .info } -Fluxtion combines dependency injection and event dispatch +Fluxtion minimises the cost of developing and maintaining event driven business logic {: .fs-4 } Developers concentrate on developing and extending business logic, dependency injection and realtime event dispatch is @@ -56,7 +56,7 @@ cost of event distribution. The opposite is true for event driven application lo over time and developing application logic becomes ever more complex and expensive to deliver. {: .info } -Fluxtion minimises the cost of developing event driven business logic +Fluxtion combines dependency injection and event dispatch increasing developer productivity {: .fs-4 } # Combining dependency injection and event processing @@ -69,7 +69,7 @@ pattern has the following benefits: - Re-use of industrial quality and predictable event dispatch model {: .info } -Familiar programming model simplifies Fluxtion integration +Fluxtion's familiar dependency injection programming model simplifies integration {: .fs-4 } ## Dependency injection container From 7d16dc4cd2b7d53d72b70d60a38bec036df545c9 Mon Sep 17 00:00:00 2001 From: command-line Date: Wed, 20 Sep 2023 18:59:20 +0100 Subject: [PATCH 204/228] docs --- docs/_config.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index c14c932d5..9e7572f3a 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -25,8 +25,8 @@ title: Fluxtion streaming description: Documentation for Fluxtion event processor remote_theme: pmarsceill/just-the-docs aux_links: - "release 9.0.25": - - "//github.com/v12technology/fluxtion/tree/9.0.25" + "release 9.1.9": + - "//github.com/v12technology/fluxtion/tree/9.1.9" heading_anchors: true # Color scheme supports "light" (default) and "dark" @@ -41,12 +41,12 @@ kramdown: block: line_numbers: true -fluxtion_version: 9.0.25 -fluxtion_src: https://github.com/v12technology/fluxtion/blob/9.0.25 -fluxtion_src_runtime: https://github.com/v12technology/fluxtion/blob/9.0.25/runtime/src/main/java/com/fluxtion/runtime -fluxtion_src_compiler: https://github.com/v12technology/fluxtion/blob/9.0.25/compiler/src/main/java/com/fluxtion/compiler -EventProcessor_link: https://github.com/v12technology/fluxtion/blob/9.0.25/runtime/src/main/java/com/fluxtion/runtime/EventProcessor.java -Fluxtion_link: https://github.com/v12technology/fluxtion/blob/9.0.25/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java +fluxtion_version: 9.1.9 +fluxtion_src: https://github.com/v12technology/fluxtion/blob/9.1.9 +fluxtion_src_runtime: https://github.com/v12technology/fluxtion/blob/9.1.9/runtime/src/main/java/com/fluxtion/runtime +fluxtion_src_compiler: https://github.com/v12technology/fluxtion/blob/9.1.9/compiler/src/main/java/com/fluxtion/compiler +EventProcessor_link: https://github.com/v12technology/fluxtion/blob/9.1.9/runtime/src/main/java/com/fluxtion/runtime/EventProcessor.java +Fluxtion_link: https://github.com/v12technology/fluxtion/blob/9.1.9/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java cookbook_src: https://github.com/v12technology/fluxtion-examples/tree/cook_subscription_example/cookbook/src/main/java/com/fluxtion/example/cookbook/ ga_tracking: G-NGDV621P1P From 04ee8dff486faebeccd59997d87cf59bb942deda Mon Sep 17 00:00:00 2001 From: command-line Date: Fri, 22 Sep 2023 06:38:24 +0100 Subject: [PATCH 205/228] docs --- docs/_config.yml | 3 +- docs/sections/getting-started.md | 10 + .../gettingstarted/5minutetutorial.md | 200 ++++++++++++++++++ .../helloworld_imperative.md | 5 +- 4 files changed, 215 insertions(+), 3 deletions(-) create mode 100644 docs/sections/getting-started.md create mode 100644 docs/sections/gettingstarted/5minutetutorial.md rename docs/sections/{ => gettingstarted}/helloworld_imperative.md (98%) diff --git a/docs/_config.yml b/docs/_config.yml index 9e7572f3a..35810ce24 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -47,7 +47,8 @@ fluxtion_src_runtime: https://github.com/v12technology/fluxtion/blob/9.1.9/runt fluxtion_src_compiler: https://github.com/v12technology/fluxtion/blob/9.1.9/compiler/src/main/java/com/fluxtion/compiler EventProcessor_link: https://github.com/v12technology/fluxtion/blob/9.1.9/runtime/src/main/java/com/fluxtion/runtime/EventProcessor.java Fluxtion_link: https://github.com/v12technology/fluxtion/blob/9.1.9/compiler/src/main/java/com/fluxtion/compiler/Fluxtion.java -cookbook_src: https://github.com/v12technology/fluxtion-examples/tree/cook_subscription_example/cookbook/src/main/java/com/fluxtion/example/cookbook/ +cookbook_src: https://github.com/v12technology/fluxtion-examples/tree/main/cookbook/src/main/java/com/fluxtion/example/cookbook + ga_tracking: G-NGDV621P1P ga_tracking_anonymize_ip: true # Use GDPR compliant Google Analytics settings (true by default) diff --git a/docs/sections/getting-started.md b/docs/sections/getting-started.md new file mode 100644 index 000000000..30ccb8936 --- /dev/null +++ b/docs/sections/getting-started.md @@ -0,0 +1,10 @@ +--- +title: Getting started +has_children: true +nav_order: 2 +published: true +--- + +# Introduction + +Start here \ No newline at end of file diff --git a/docs/sections/gettingstarted/5minutetutorial.md b/docs/sections/gettingstarted/5minutetutorial.md new file mode 100644 index 000000000..9c7eed5e8 --- /dev/null +++ b/docs/sections/gettingstarted/5minutetutorial.md @@ -0,0 +1,200 @@ +--- +title: First app tutorial +parent: Getting started +has_children: false +nav_order: 1 +published: true +--- + +# Introduction + +This tutorial is an introduction to writing event driven application logic using Fluxtion. The reader should be +proficient in Java, maven, git and possess a basic knowledge of Spring dependency injection. The project source can be +found [here.]({{site.cookbook_src}}/lottery) + +Our goal is to build the logic for a simple lottery application that will be connected to request and response queues. +Serialising requests to a queue makes our application event driven and easier to scale in the future, the response queue +stores the output from the application. This example is focused on building event driven processing by wiring together +software components using Fluxtion and not the connection to real queues. + +At the end of this tutorial you should understand how Fuxtion: + +- Exposes service interfaces for managed components +- Calls lifecycle methods on managed components +- Triggers event logic between dependent components +- Wires components together + +# The Lottery game + +A lottery game sells tickets to customers from a ticket shop, the shop is either opened or closed. A customer receives a +receipt for a purchased ticket or a message that no ticket was purchased. Tickets must have six numbers and cannot be +bought when the shop is closed. A lottery machine picks the winning ticket number from the tickets purchased and +publishes the lucky number to a queue. + +# Designing the components + +Our application will be service driven and present api interfaces for the outside world to code against. Fluxtion will +wire up the components later, but we must first think about the design of our services and then the concrete +implementations. + +## Service api + +From our business problem we have identified a concrete data type Ticket and two public services TicketStore and +LotteryMachine. Now we have identified the top level concepts we can create a service api that client code will use to +drive the system. + +{% highlight java %} +public record Ticket(int number, UUID id) { + public Ticket(int number){ + this(number, UUID.randomUUID()); + } +} + +public interface TicketStore { + boolean buyTicket(Ticket ticket); + void openStore(); + void closeStore(); + void setTicketSalesPublisher(Consumer ticketSalesPublisher); +} + +public interface LotteryGame { + void selectWinningTicket(); + void setResultPublisher(Consumer resultPublisher); +} +{% endhighlight %} + +Our interfaces are simple and separate concerns logically, making the api simple to work with. The methods +setTicketSalesPublisher and setResultPublisher connect the results of processing to output queues or a unit test. One +of our goals is to make the logic easy to test with the minimum of infrastructure. + +## Implementing logic + +We implement our two interfaces with concrete classes TicketStoreNode and LotteryGameNode using some lombok annotations +to remove boilerplate code. + +### TicketStoreNode + +The TicketStoreNode implements TicketSore and supports logic to buy and sell tickets depending on the state of the store +. A lifecycle method start is created that checks the ticketSalesPublisher has been set before progressing any further. +TicketStoreNode also implements Supplier which allows any child component to access the last sold ticket without +accessing the concrete type. Making components reference each other through interfaces is good practice. + +{% highlight java %} +@Slf4j +public class TicketStoreNode implements Supplier, TicketStore { + + private boolean storeOpen; + private Consumer ticketSalesPublisher; + private Ticket ticket; + + @Override + public void setTicketSalesPublisher(Consumer ticketSalesPublisher) { + this.ticketSalesPublisher = ticketSalesPublisher; + } + + public void start() { + Objects.requireNonNull(ticketSalesPublisher, "must have a ticketSalesPublisher set"); + storeOpen = false; + } + + @Override + public boolean buyTicket(Ticket ticket) { + if (ticket.number() < 9_99_99 | ticket.number() > 99_99_99) { + ticketSalesPublisher.accept("invalid numbers " + ticket); + this.ticket = null; + } else if (storeOpen) { + ticketSalesPublisher.accept("good luck with " + ticket); + this.ticket = ticket; + } else { + ticketSalesPublisher.accept("store shut - no tickets can be bought"); + this.ticket = null; + } + return this.ticket != null; + } + + @Override + public Ticket get() { + return ticket; + } + + @Override + public void openStore() { + log.info("store opened"); + storeOpen = true; + } + + @Override + public void closeStore() { + log.info("store closed"); + storeOpen = false; + } +} +{% endhighlight %} + +### LotteryGameNode + +The LotteryGameNode implements LotteryGame and supports logic to run the lottery. LotteryGameNode holds a reference to +an instance of Supplier and whenever processNewTicketSale is called, acquires a purchased ticket and adds it +to the internal cache. A lifecycle method start is created that checks the resultPublisher has been set before +progressing any further. + +{% highlight java %} +@Slf4j +@RequiredArgsConstructor +public class LotteryGameNode implements LotteryGame { + + private final Supplier ticketSupplier; + private final transient List ticketsBought = new ArrayList<>(); + private Consumer resultPublisher; + + @Override + public void setResultPublisher(Consumer resultPublisher) { + this.resultPublisher = resultPublisher; + } + + public void start(){ + Objects.requireNonNull(resultPublisher, "must set a results publisher before starting the lottery game"); + log.info("started"); + } + + public boolean processNewTicketSale() { + ticketsBought.add(ticketSupplier.get()); + log.info("tickets sold:{}", ticketsBought.size()); + return false; + } + + @Override + public void selectWinningTicket() { + if(ticketsBought.isEmpty()){ + log.info("no tickets bought - no winning ticket"); + }else { + Collections.shuffle(ticketsBought); + log.info("WINNING ticket {}", ticketsBought.get(0)); + } + ticketsBought.clear(); + } +} +{% endhighlight %} + +The lifecycle methods and how clients access the TicketStore interface are described later on. + +# Building the application +Now we have our service interfaces designed and implemented we need to connect them together and make sure they provide +the functionality required. There are several problems to solve to deliver functionality: + +- How do clients access the components via service interfaces +- How are the lifecycle methods called +- How is LotteryGameNode processNewTicketSale called at the right time +- How are the components wired together + +This is the goal of Fluxtion to solve these four problems for any event driven application. + +## Exporting services + +## Event dispatch + +## Wiring the components together + +# Running the application + + diff --git a/docs/sections/helloworld_imperative.md b/docs/sections/gettingstarted/helloworld_imperative.md similarity index 98% rename from docs/sections/helloworld_imperative.md rename to docs/sections/gettingstarted/helloworld_imperative.md index 39f71fb61..7f17fa3fe 100644 --- a/docs/sections/helloworld_imperative.md +++ b/docs/sections/gettingstarted/helloworld_imperative.md @@ -1,8 +1,9 @@ --- title: Hello fluxtion world +parent: Getting started has_children: false nav_order: 2 -published: true +published: false example_src: https://github.com/v12technology/fluxtion-examples/tree/main/imperative-helloworld/src/main/java/com/fluxtion/example/imperative/helloworld --- @@ -32,7 +33,7 @@ All projects that build a Fluxtion [EventProcessor]({{site.EventProcessor_link}} Graphical representation of the processing graph that Fluxtion will generate. -![](../images/helloworld/helloworld_imperative.png) +![](../../images/helloworld/helloworld_imperative.png) ## Dependencies From 61d9a7bdc61afef97b5439751bac416cd47c7416 Mon Sep 17 00:00:00 2001 From: command-line Date: Fri, 22 Sep 2023 09:15:53 +0100 Subject: [PATCH 206/228] docs --- docs/index.md | 10 +++- .../{5minutetutorial.md => first_tutorial.md} | 59 +++++++++++++++---- 2 files changed, 55 insertions(+), 14 deletions(-) rename docs/sections/gettingstarted/{5minutetutorial.md => first_tutorial.md} (69%) diff --git a/docs/index.md b/docs/index.md index 70bbebd89..0d26f1c0e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,7 +5,7 @@ nav_order: 1 published: true --- -# Introduction +# Introduction Fluxtion is a java development productivity tool that makes writing and maintaining event driven business logic cheaper and quicker. The Fluxtion dependency injection container exposes user beans as event driven service endpoints. A @@ -98,3 +98,11 @@ event handler and trigger methods are dispatch targets. When building a containe calculate the dispatch call trees for the internal dispatcher. A bean can export multiple service interfaces or just a single method. For exported interfaces the container generates proxies that routes calls from the proxy handler methods to the container's dispatcher. + +# Latest release + +| component | maven central | +|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Runtime | [![Fluxtion runtime](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/runtime/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/runtime) | +| Compiler | [![Fluxtion compiler](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/compiler/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/compiler) | + diff --git a/docs/sections/gettingstarted/5minutetutorial.md b/docs/sections/gettingstarted/first_tutorial.md similarity index 69% rename from docs/sections/gettingstarted/5minutetutorial.md rename to docs/sections/gettingstarted/first_tutorial.md index 9c7eed5e8..0efe6e876 100644 --- a/docs/sections/gettingstarted/5minutetutorial.md +++ b/docs/sections/gettingstarted/first_tutorial.md @@ -1,5 +1,5 @@ --- -title: First app tutorial +title: First tutorial parent: Getting started has_children: false nav_order: 1 @@ -17,7 +17,7 @@ Serialising requests to a queue makes our application event driven and easier to stores the output from the application. This example is focused on building event driven processing by wiring together software components using Fluxtion and not the connection to real queues. -At the end of this tutorial you should understand how Fuxtion: +At the end of this tutorial you should understand how Fluxtion: - Exposes service interfaces for managed components - Calls lifecycle methods on managed components @@ -33,9 +33,9 @@ publishes the lucky number to a queue. # Designing the components -Our application will be service driven and present api interfaces for the outside world to code against. Fluxtion will -wire up the components later, but we must first think about the design of our services and then the concrete -implementations. +Our application will be service driven and present api interfaces for the outside world to code against. We must first +think about the design of our services and then the concrete implementations. Once this design is complete we will use +Fluxtion to wire up the components. Fluxtion is low touch allowing engineers and architects to concentrate on components. ## Service api @@ -57,13 +57,13 @@ public interface TicketStore { void setTicketSalesPublisher(Consumer ticketSalesPublisher); } -public interface LotteryGame { +public interface LotteryMachine { void selectWinningTicket(); void setResultPublisher(Consumer resultPublisher); } {% endhighlight %} -Our interfaces are simple and separate concerns logically, making the api simple to work with. The methods +Our interfaces separate concerns logically making the api simple to work with. The methods setTicketSalesPublisher and setResultPublisher connect the results of processing to output queues or a unit test. One of our goals is to make the logic easy to test with the minimum of infrastructure. @@ -133,7 +133,7 @@ public class TicketStoreNode implements Supplier, TicketStore { ### LotteryGameNode -The LotteryGameNode implements LotteryGame and supports logic to run the lottery. LotteryGameNode holds a reference to +The LotteryMachineNode implements LotteryMachine and supports logic to run the lottery. LotteryMachineNode holds a reference to an instance of Supplier and whenever processNewTicketSale is called, acquires a purchased ticket and adds it to the internal cache. A lifecycle method start is created that checks the resultPublisher has been set before progressing any further. @@ -141,7 +141,7 @@ progressing any further. {% highlight java %} @Slf4j @RequiredArgsConstructor -public class LotteryGameNode implements LotteryGame { +public class LotteryMachineNode implements LotteryMachine { private final Supplier ticketSupplier; private final transient List ticketsBought = new ArrayList<>(); @@ -179,17 +179,50 @@ public class LotteryGameNode implements LotteryGame { The lifecycle methods and how clients access the TicketStore interface are described later on. # Building the application -Now we have our service interfaces designed and implemented we need to connect them together and make sure they provide -the functionality required. There are several problems to solve to deliver functionality: +Now we have our service interfaces designed and implemented we need to connect components together and make sure they provide +the functionality required in the expected manner. There are several problems to solve to deliver functionality: - How do clients access the components via service interfaces - How are the lifecycle methods called -- How is LotteryGameNode processNewTicketSale called at the right time +- How is LotteryGameNode#processNewTicketSale called only when a ticket is successfully purchased - How are the components wired together -This is the goal of Fluxtion to solve these four problems for any event driven application. +Fluxtion solves these four problems for any event driven application. ## Exporting services +We want clients to access components via service interface, this is simple to achieve by adding an **ExportService** +annotation to the interface definitions on the concrete classes, as shown below. + +{% highlight java %} +import com.fluxtion.runtime.annotations.ExportService; +public class LotteryMachineNode implements @ExportService LotteryMachine { + //removed for clarity +} + +import com.fluxtion.runtime.annotations.ExportService; +public class TicketStoreNode implements Supplier, @ExportService TicketStore { + //removed for clarity +} +{% endhighlight %} + +Fluxtion will only export annotated interfaces at the container level, in this case Fluxtion will not export the +Supplier interface that TicketStoreNode implements. + +## Accessing exported services +Once the service interface has been marked for export client code can locate it through the EventProcessor instance that +holds the application components by calling EventProcessor#getExportedService. Client code invokes methods on the +interface and Fluxtion container will take care of all method routing. + +{% highlight java %} +public static void start(Consumer ticketReceiptHandler, Consumer resultsPublisher){ + EventProcessor lotteryEventProcessor = FluxtionSpring.interpret( + new ClassPathXmlApplicationContext("com/fluxtion/example/cookbook/lottery/spring-lottery.xml")); + LotteryMachine lotteryMachine = lotteryEventProcessor.getExportedService(); + TicketStore ticketStore = lotteryEventProcessor.getExportedService(); + lotteryMachine.setResultPublisher(resultsPublisher); + ticketStore.setTicketSalesPublisher(ticketReceiptHandler); +} +{% endhighlight %} ## Event dispatch From 1df117460da59fda75904c737eeb613dc0a9c508 Mon Sep 17 00:00:00 2001 From: command-line Date: Fri, 22 Sep 2023 12:29:12 +0100 Subject: [PATCH 207/228] docs --- docs/index.md | 36 +++++ ...chnical-deepdive.md => core-technology.md} | 2 +- docs/sections/deploying-testing.md | 2 +- docs/sections/examples.md | 2 +- .../sections/gettingstarted/first_tutorial.md | 126 +++++++++++++++++- docs/sections/quick-reference.md | 2 +- 6 files changed, 164 insertions(+), 6 deletions(-) rename docs/sections/{technical-deepdive.md => core-technology.md} (99%) diff --git a/docs/index.md b/docs/index.md index 0d26f1c0e..6656681de 100644 --- a/docs/index.md +++ b/docs/index.md @@ -106,3 +106,39 @@ to the container's dispatcher. | Runtime | [![Fluxtion runtime](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/runtime/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/runtime) | | Compiler | [![Fluxtion compiler](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/compiler/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/compiler) | +## Build dependencies + +
+ + +
+
+
+{% highlight xml %} + + + com.fluxtion + runtime + {{site.fluxtion_version}} + + + com.fluxtion + compiler + {{site.fluxtion_version}} + + +{% endhighlight %} +
+
+
+
+{% highlight groovy %} +implementation 'com.fluxtion:runtime:{{site.fluxtion_version}}' +implementation 'com.fluxtion:compiler:{{site.fluxtion_version}}' +{% endhighlight %} +
+
+ + \ No newline at end of file diff --git a/docs/sections/technical-deepdive.md b/docs/sections/core-technology.md similarity index 99% rename from docs/sections/technical-deepdive.md rename to docs/sections/core-technology.md index 69ef8fae0..ba7d03d81 100644 --- a/docs/sections/technical-deepdive.md +++ b/docs/sections/core-technology.md @@ -1,5 +1,5 @@ --- -title: Technical deep dive +title: Core technology has_children: true nav_order: 3 published: true diff --git a/docs/sections/deploying-testing.md b/docs/sections/deploying-testing.md index 387013dc5..d48c0311c 100644 --- a/docs/sections/deploying-testing.md +++ b/docs/sections/deploying-testing.md @@ -1,7 +1,7 @@ --- title: Deploying and testing has_children: true -nav_order: 3 +nav_order: 4 published: true --- diff --git a/docs/sections/examples.md b/docs/sections/examples.md index d227abbc2..c989025e8 100644 --- a/docs/sections/examples.md +++ b/docs/sections/examples.md @@ -1,7 +1,7 @@ --- title: Examples has_children: true -nav_order: 5 +nav_order: 6 published: true --- diff --git a/docs/sections/gettingstarted/first_tutorial.md b/docs/sections/gettingstarted/first_tutorial.md index 0efe6e876..f872ffc5e 100644 --- a/docs/sections/gettingstarted/first_tutorial.md +++ b/docs/sections/gettingstarted/first_tutorial.md @@ -33,9 +33,10 @@ publishes the lucky number to a queue. # Designing the components -Our application will be service driven and present api interfaces for the outside world to code against. We must first +Our application will be event driven through a service interface api for the outside world to code against. We must first think about the design of our services and then the concrete implementations. Once this design is complete we will use -Fluxtion to wire up the components. Fluxtion is low touch allowing engineers and architects to concentrate on components. +Fluxtion to wire up the components. Fluxtion is low touch allowing engineers and architects to concentrate on design and +components with no distraction. ## Service api @@ -224,8 +225,129 @@ public static void start(Consumer ticketReceiptHandler, Consumer } {% endhighlight %} + ## Event dispatch +When a ticket has been successfully purchased the LotteryMachineNode instance method processNewTicketSale is invoked by +Fluxtion. The processNewTicketSale method grabs the last ticket sale from the Supplier reference and adds it to +the cache. Fluxtion knows to trigger a method if it is annotated with @OnTrigger and one of its dependencies has been +triggered from an incoming client service call. + + +{% highlight java %} +@Slf4j +@RequiredArgsConstructor +public class LotteryMachineNode implements LotteryMachine { + //code removed for clarity + + @OnTrigger + public boolean processNewTicketSale() { + ticketsBought.add(ticketSupplier.get()); + log.info("tickets sold:{}", ticketsBought.size()); + return false; + } +} +{% endhighlight %} + +How does Fluxtion know to invoke this method at the correct time? The container knows the dependency relationship between +TicketStoreNode and LotteryMachineNode, so when an exported service method is invoked on TicketStoreNode Fluxtion calls +the processNewTicketSale trigger method on LotteryMachineNode. This is great as it removes the need for the programmer +to manually call the event dispatch call graph. + +The next problem is we only want the processNewTicketSale method called when a ticket is successfully purchased. If we +try to add a ticket when the openStore is called a null pointer exception will be thrown at runtime. How can the +developer control the propagation of calling dependent trigger methods? + +Fluxtion has two ways of managing propagation from an exported service method + +- boolean return type, false indicates no event propagation, true propagates the notification +- annotate the method with **@NoPropagateFunction** annotation + +Both are used in LotteryMachineNode + +{% highlight java %} +public class TicketStoreNode implements Supplier, @ExportService TicketStore { + //code removed for clarity + + @Override + @NoPropagateFunction + public void setTicketSalesPublisher(Consumer ticketSalesPublisher) {} + + public void start() {} + + //triggers event propagation + public boolean buyTicket(Ticket ticket) { + if (ticket.number() < 9_99_99 | ticket.number() > 99_99_99) { + ticketSalesPublisher.accept("invalid numbers " + ticket); + this.ticket = null; + } else if (storeOpen) { + ticketSalesPublisher.accept("good luck with " + ticket); + this.ticket = ticket; + } else { + ticketSalesPublisher.accept("store shut - no tickets can be bought"); + this.ticket = null; + } + return this.ticket != null; + } + + public Ticket get() {} + + @NoPropagateFunction + public void openStore() {} + + @NoPropagateFunction + public void closeStore() {} +} +{% endhighlight %} + +The TicketStoreNode#buyTicket is the only method that will trigger an event notification to LotteryMachineNode and +only if the ticket passes basic validation and the store is open. + +## Lifecycle methods +Applications often benefit from lifecycle methods such as init, start and stop, allowing checks to be carried out before +executing the application. Fluxtion supports init, start and stop by annotating a method with an annotation **@Start @Stop** +or **@Initialise**. We use +the start method in our application to check output receivers ticketSalesPublisher and resultPublisher have been set +by the client code. + + +{% highlight java %} +//code removed for clarity +public class TicketStoreNode implements Supplier, @ExportService TicketStore { + + @Start + public void start() { + Objects.requireNonNull(ticketSalesPublisher, "must have a ticketSalesPublisher set"); + storeOpen = false; + } +} + +public class LotteryMachineNode implements @ExportService LotteryMachine { + + @Start + public void start(){ + Objects.requireNonNull(resultPublisher, "must set a results publisher before starting the lottery game"); + log.info("started"); + } +} +{% endhighlight %} + +Client code invokes the lifecycle method on the container and Fluxtion will ensure all the lifecycle methods registered +by components will be called in the right order. + +{% highlight java %} +public static void start(Consumer ticketReceiptHandler, Consumer resultsPublisher){ + EventProcessor lotteryEventProcessor = FluxtionSpring.interpret( + new ClassPathXmlApplicationContext("com/fluxtion/example/cookbook/lottery/spring-lottery.xml")); + lotteryEventProcessor.init(); + LotteryMachine lotteryMachine = lotteryEventProcessor.getExportedService(); + TicketStore ticketStore = lotteryEventProcessor.getExportedService(); + lotteryMachine.setResultPublisher(resultsPublisher); + ticketStore.setTicketSalesPublisher(ticketReceiptHandler); + lotteryEventProcessor.start(); +} +{% endhighlight %} + ## Wiring the components together # Running the application diff --git a/docs/sections/quick-reference.md b/docs/sections/quick-reference.md index 37fbba956..9fa7c474f 100644 --- a/docs/sections/quick-reference.md +++ b/docs/sections/quick-reference.md @@ -1,7 +1,7 @@ --- title: Quick reference has_children: true -nav_order: 4 +nav_order: 5 published: true --- From a6814c10e8ba6be31d38284eeb1874e775f51300 Mon Sep 17 00:00:00 2001 From: command-line Date: Sat, 23 Sep 2023 06:55:53 +0100 Subject: [PATCH 208/228] docs --- docs/index.md | 4 +- .../sections/gettingstarted/first_tutorial.md | 300 +++++++++++++----- 2 files changed, 218 insertions(+), 86 deletions(-) diff --git a/docs/index.md b/docs/index.md index 6656681de..182570ee9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,7 +5,9 @@ nav_order: 1 published: true --- -# Introduction +# Fluxtion is event driven Java + +--- Fluxtion is a java development productivity tool that makes writing and maintaining event driven business logic cheaper and quicker. The Fluxtion dependency injection container exposes user beans as event driven service endpoints. A diff --git a/docs/sections/gettingstarted/first_tutorial.md b/docs/sections/gettingstarted/first_tutorial.md index f872ffc5e..db54e3ee9 100644 --- a/docs/sections/gettingstarted/first_tutorial.md +++ b/docs/sections/gettingstarted/first_tutorial.md @@ -6,6 +6,16 @@ nav_order: 1 published: true --- +
+ + Table of contents + + {: .text-delta } +1. TOC +{:toc} +
+ + # Introduction This tutorial is an introduction to writing event driven application logic using Fluxtion. The reader should be @@ -46,21 +56,21 @@ drive the system. {% highlight java %} public record Ticket(int number, UUID id) { - public Ticket(int number){ - this(number, UUID.randomUUID()); - } + public Ticket(int number){ + this(number, UUID.randomUUID()); + } } public interface TicketStore { - boolean buyTicket(Ticket ticket); - void openStore(); - void closeStore(); - void setTicketSalesPublisher(Consumer ticketSalesPublisher); + boolean buyTicket(Ticket ticket); + void openStore(); + void closeStore(); + void setTicketSalesPublisher(Consumer ticketSalesPublisher); } public interface LotteryMachine { - void selectWinningTicket(); - void setResultPublisher(Consumer resultPublisher); + void selectWinningTicket(); + void setResultPublisher(Consumer resultPublisher); } {% endhighlight %} @@ -77,7 +87,7 @@ to remove boilerplate code. The TicketStoreNode implements TicketSore and supports logic to buy and sell tickets depending on the state of the store . A lifecycle method start is created that checks the ticketSalesPublisher has been set before progressing any further. -TicketStoreNode also implements Supplier which allows any child component to access the last sold ticket without +TicketStoreNode also implements Supplier<Ticket> which allows any child component to access the last sold ticket without accessing the concrete type. Making components reference each other through interfaces is good practice. {% highlight java %} @@ -135,7 +145,7 @@ public class TicketStoreNode implements Supplier, TicketStore { ### LotteryGameNode The LotteryMachineNode implements LotteryMachine and supports logic to run the lottery. LotteryMachineNode holds a reference to -an instance of Supplier and whenever processNewTicketSale is called, acquires a purchased ticket and adds it +an instance of Supplier<Ticket> and whenever processNewTicketSale is called, acquires a purchased ticket and adds it to the internal cache. A lifecycle method start is created that checks the resultPublisher has been set before progressing any further. @@ -177,11 +187,12 @@ public class LotteryMachineNode implements LotteryMachine { } {% endhighlight %} -The lifecycle methods and how clients access the TicketStore interface are described later on. +The lifecycle methods and how clients access the TicketStore and LotteryMachine services are described below. # Building the application Now we have our service interfaces designed and implemented we need to connect components together and make sure they provide -the functionality required in the expected manner. There are several problems to solve to deliver functionality: +the functionality required in the expected manner. There are several problems to solve to deliver correct event driven +functionality: - How do clients access the components via service interfaces - How are the lifecycle methods called @@ -191,7 +202,7 @@ the functionality required in the expected manner. There are several problems to Fluxtion solves these four problems for any event driven application. ## Exporting services -We want clients to access components via service interface, this is simple to achieve by adding an **ExportService** +We want clients to access components via service interface, this is simple to achieve by adding an **@ExportService** annotation to the interface definitions on the concrete classes, as shown below. {% highlight java %} @@ -206,8 +217,8 @@ public class TicketStoreNode implements Supplier, @ExportService TicketS } {% endhighlight %} -Fluxtion will only export annotated interfaces at the container level, in this case Fluxtion will not export the -Supplier interface that TicketStoreNode implements. +Fluxtion will only export annotated interfaces at the container level, in this case Fluxtion will not export the +Supplier<Ticket> interface that TicketStoreNode implements. ## Accessing exported services Once the service interface has been marked for export client code can locate it through the EventProcessor instance that @@ -216,12 +227,11 @@ interface and Fluxtion container will take care of all method routing. {% highlight java %} public static void start(Consumer ticketReceiptHandler, Consumer resultsPublisher){ - EventProcessor lotteryEventProcessor = FluxtionSpring.interpret( - new ClassPathXmlApplicationContext("com/fluxtion/example/cookbook/lottery/spring-lottery.xml")); - LotteryMachine lotteryMachine = lotteryEventProcessor.getExportedService(); - TicketStore ticketStore = lotteryEventProcessor.getExportedService(); - lotteryMachine.setResultPublisher(resultsPublisher); - ticketStore.setTicketSalesPublisher(ticketReceiptHandler); + EventProcessor lotteryEventProcessor = //removed for clarity + LotteryMachine lotteryMachine = lotteryEventProcessor.getExportedService(); + TicketStore ticketStore = lotteryEventProcessor.getExportedService(); + lotteryMachine.setResultPublisher(resultsPublisher); + ticketStore.setTicketSalesPublisher(ticketReceiptHandler); } {% endhighlight %} @@ -229,14 +239,12 @@ public static void start(Consumer ticketReceiptHandler, Consumer ## Event dispatch When a ticket has been successfully purchased the LotteryMachineNode instance method processNewTicketSale is invoked by -Fluxtion. The processNewTicketSale method grabs the last ticket sale from the Supplier reference and adds it to -the cache. Fluxtion knows to trigger a method if it is annotated with @OnTrigger and one of its dependencies has been +Fluxtion. The processNewTicketSale method grabs the last ticket sale from the Supplier<Ticket> reference and adds it to +the cache. Fluxtion knows to trigger a method if it is annotated with **@OnTrigger** and one of its dependencies has been triggered from an incoming client service call. {% highlight java %} -@Slf4j -@RequiredArgsConstructor public class LotteryMachineNode implements LotteryMachine { //code removed for clarity @@ -249,59 +257,59 @@ public class LotteryMachineNode implements LotteryMachine { } {% endhighlight %} -How does Fluxtion know to invoke this method at the correct time? The container knows the dependency relationship between +How does Fluxtion know to invoke this method at the correct time? The container maps the dependency relationship between TicketStoreNode and LotteryMachineNode, so when an exported service method is invoked on TicketStoreNode Fluxtion calls the processNewTicketSale trigger method on LotteryMachineNode. This is great as it removes the need for the programmer to manually call the event dispatch call graph. The next problem is we only want the processNewTicketSale method called when a ticket is successfully purchased. If we try to add a ticket when the openStore is called a null pointer exception will be thrown at runtime. How can the -developer control the propagation of calling dependent trigger methods? +developer control the propagation of dependent trigger methods? -Fluxtion has two ways of managing propagation from an exported service method +Fluxtion manages exported service event propagation in two ways: -- boolean return type, false indicates no event propagation, true propagates the notification +- boolean return type from the service method, false indicates no event propagation, true propagates the notification - annotate the method with **@NoPropagateFunction** annotation -Both are used in LotteryMachineNode +Both propagation controls are used in LotteryMachineNode ensuring the LotteryMachine is only triggered on successful +ticket purchases. The TicketStoreNode#buyTicket is the only method that will trigger an event notification to +LotteryMachineNode and only if the ticket passes basic validation and the store is open. {% highlight java %} public class TicketStoreNode implements Supplier, @ExportService TicketStore { - //code removed for clarity - - @Override - @NoPropagateFunction - public void setTicketSalesPublisher(Consumer ticketSalesPublisher) {} - - public void start() {} - - //triggers event propagation - public boolean buyTicket(Ticket ticket) { - if (ticket.number() < 9_99_99 | ticket.number() > 99_99_99) { - ticketSalesPublisher.accept("invalid numbers " + ticket); - this.ticket = null; - } else if (storeOpen) { - ticketSalesPublisher.accept("good luck with " + ticket); - this.ticket = ticket; - } else { - ticketSalesPublisher.accept("store shut - no tickets can be bought"); - this.ticket = null; + //code removed for clarity + + @Override + @NoPropagateFunction + public void setTicketSalesPublisher(Consumer ticketSalesPublisher) {} + + public void start() {} + + //return true -> triggers event propagation + public boolean buyTicket(Ticket ticket) { + if (ticket.number() < 9_99_99 | ticket.number() > 99_99_99) { + ticketSalesPublisher.accept("invalid numbers " + ticket); + this.ticket = null; + } else if (storeOpen) { + ticketSalesPublisher.accept("good luck with " + ticket); + this.ticket = ticket; + } else { + ticketSalesPublisher.accept("store shut - no tickets can be bought"); + this.ticket = null; + } + return this.ticket != null; } - return this.ticket != null; - } - - public Ticket get() {} - - @NoPropagateFunction - public void openStore() {} - - @NoPropagateFunction - public void closeStore() {} + + public Ticket get() {} + + @NoPropagateFunction + public void openStore() {} + + @NoPropagateFunction + public void closeStore() {} } {% endhighlight %} -The TicketStoreNode#buyTicket is the only method that will trigger an event notification to LotteryMachineNode and -only if the ticket passes basic validation and the store is open. ## Lifecycle methods Applications often benefit from lifecycle methods such as init, start and stop, allowing checks to be carried out before @@ -312,44 +320,166 @@ by the client code. {% highlight java %} -//code removed for clarity public class TicketStoreNode implements Supplier, @ExportService TicketStore { - - @Start - public void start() { - Objects.requireNonNull(ticketSalesPublisher, "must have a ticketSalesPublisher set"); - storeOpen = false; - } + //code removed for clarity + @Start + public void start() { + Objects.requireNonNull(ticketSalesPublisher, "must have a ticketSalesPublisher set"); + storeOpen = false; + } } public class LotteryMachineNode implements @ExportService LotteryMachine { - - @Start - public void start(){ - Objects.requireNonNull(resultPublisher, "must set a results publisher before starting the lottery game"); - log.info("started"); - } + //code removed for clarity + @Start + public void start(){ + Objects.requireNonNull(resultPublisher, "must set a results publisher before starting the lottery game"); + log.info("started"); + } } {% endhighlight %} -Client code invokes the lifecycle method on the container and Fluxtion will ensure all the lifecycle methods registered -by components will be called in the right order. +Client code invokes the lifecycle method on the container Fluxtion then calls all the lifecycle methods registered +by components in the right order. {% highlight java %} public static void start(Consumer ticketReceiptHandler, Consumer resultsPublisher){ - EventProcessor lotteryEventProcessor = FluxtionSpring.interpret( - new ClassPathXmlApplicationContext("com/fluxtion/example/cookbook/lottery/spring-lottery.xml")); - lotteryEventProcessor.init(); - LotteryMachine lotteryMachine = lotteryEventProcessor.getExportedService(); - TicketStore ticketStore = lotteryEventProcessor.getExportedService(); - lotteryMachine.setResultPublisher(resultsPublisher); - ticketStore.setTicketSalesPublisher(ticketReceiptHandler); - lotteryEventProcessor.start(); + EventProcessor lotteryEventProcessor = //removed for clarity + lotteryEventProcessor.init(); + LotteryMachine lotteryMachine = lotteryEventProcessor.getExportedService(); + TicketStore ticketStore = lotteryEventProcessor.getExportedService(); + lotteryMachine.setResultPublisher(resultsPublisher); + ticketStore.setTicketSalesPublisher(ticketReceiptHandler); + lotteryEventProcessor.start(); } {% endhighlight %} ## Wiring the components together +The dependency injection container wires components depending upon the configuration supplied. As Fluxtion natively supports +spring ApplicationContext we use a spring configuration file in this example to wire the TicketStore to the LotteryMachine. + +{% highlight xml %} + + + + + + + + +{% endhighlight %} + +Fluxtion provides a spring extension for building a container using static helper methods. The built container is free +of any spring dependencies, Fluxtion just reads the spring file to drive its own configuration. To build the container +the tutorial loads the spring file from the classpath: + +{% highlight java %} +public static void start(Consumer ticketReceiptHandler, Consumer resultsPublisher){ + EventProcessor lotteryEventProcessor = FluxtionSpring.interpret( + new ClassPathXmlApplicationContext("com/fluxtion/example/cookbook/lottery/spring-lottery.xml")); + //removed for clarity +} +{% endhighlight %} # Running the application +Running the application requires the following from client code: + +- Building the container using the spring config file +- Call lifecycle methods on the container +- Lookup container exported service interfaces and store the references for use in client code + +The fact the components are managed by a container is completely hidden from the client code, this +makes integrating Fluxtion into an existing system extremely simple as no new programming models need to be adopted. + +In our example the main method only interacts with the business logic via the service interfaces, in a real application +the methods would be invoked by taking commands from an incoming request queue. + +{% highlight java %} +public class LotteryApp { + + private static LotteryMachine lotteryMachine; + private static TicketStore ticketStore; + + public static void main(String[] args) { + start(LotteryApp::ticketReceipt, LotteryApp::lotteryResult); + //try and buy a ticket - store is closed + ticketStore.buyTicket(new Ticket(12_65_56)); + + //open store and buy ticket + ticketStore.openStore(); + ticketStore.buyTicket(new Ticket(12_65_56)); + ticketStore.buyTicket(new Ticket(36_58_58)); + ticketStore.buyTicket(new Ticket(73_00_12)); + //bad numbers + ticketStore.buyTicket(new Ticket(25)); + + //close the store and run the lottery + ticketStore.closeStore(); + + //try and buy a ticket - store is closed + ticketStore.buyTicket(new Ticket(12_65_56)); + + //run the lottery + lotteryMachine.selectWinningTicket(); + } + + public static void start(Consumer ticketReceiptHandler, Consumer resultsPublisher){ + var lotteryEventProcessor = FluxtionSpring.interpret( + new ClassPathXmlApplicationContext("com/fluxtion/example/cookbook/lottery/spring-lottery.xml")); + lotteryEventProcessor.init(); + lotteryMachine = lotteryEventProcessor.getExportedService(); + ticketStore = lotteryEventProcessor.getExportedService(); + lotteryMachine.setResultPublisher(resultsPublisher); + ticketStore.setTicketSalesPublisher(ticketReceiptHandler); + lotteryEventProcessor.start(); + } + + public static void ticketReceipt(String receipt){ + log.info(receipt); + } + + public static void lotteryResult(String receipt){ + log.info(receipt); + } +} +{% endhighlight %} + +Executing our application produces the following output: + +{% highlight console %} +[main] INFO LotteryMachineNode - started +[main] INFO LotteryApp - store shut - no tickets can be bought +[main] INFO TicketStoreNode - store opened +[main] INFO LotteryApp - good luck with Ticket[number=126556, id=77376783-3513-4f22-88be-5ace6cdf5839] +[main] INFO LotteryMachineNode - tickets sold:1 +[main] INFO LotteryApp - good luck with Ticket[number=365858, id=05e6f44e-5938-4b28-a183-047c6e75c532] +[main] INFO LotteryMachineNode - tickets sold:2 +[main] INFO LotteryApp - good luck with Ticket[number=730012, id=30af94d7-7aec-4e82-8159-2cade3b38b2b] +[main] INFO LotteryMachineNode - tickets sold:3 +[main] INFO LotteryApp - invalid numbers Ticket[number=25, id=62afdb45-25f8-4a80-bfba-37c22bfe8bf2] +[main] INFO TicketStoreNode - store closed +[main] INFO LotteryApp - store shut - no tickets can be bought +[main] INFO LotteryMachineNode - WINNING ticket Ticket[number=365858, id=05e6f44e-5938-4b28-a183-047c6e75c532] + +Process finished with exit code 0 +{% endhighlight %} +# Conclusion +We have quite a lot of ground in a seemingly simple event driven application. Hopefully you can see the benefits of using +Fluxtion to write event driven business logic: +- Forcing client code to interact with components through interfaces +- Formal lifecycle phases that are easy to plug in to +- Dispatch of events to any bean managed instance exporting a service +- Automatic dispatch of dependent trigger methods +- Removal of state and conditional dispatch logic from business code +- Deterministic event handling that is well tested +- Control of event propagation with simple boolean returns or annotations +- More time spent writing logic and less time writing infrastructure +- Simple programming model that leverages Spring for quick adoption + +As applications grow and become more complex programming event driven logic becomes ever more expensive. The benefits +of a tool like Fluxtion really shine during the growth and maintenance phase. + +I hope you have enjoyed reading this tutorial, and it has given you an understanding of Fluxtion and a desire to use it +in your applications. Please send me in any comments or suggestions to improve this tutorial \ No newline at end of file From 46523ba6db87ee312a8bb0a329817e783810efab Mon Sep 17 00:00:00 2001 From: command-line Date: Sat, 23 Sep 2023 07:27:58 +0100 Subject: [PATCH 209/228] docs --- README.md | 195 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 115 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 959eeaa1d..f8cfdfae6 100644 --- a/README.md +++ b/README.md @@ -9,66 +9,123 @@ ## [User documentation](https://v12technology.github.io/fluxtion/) -# Lightweight event stream processor -- Pure java in memory complex event processing -- Ultra fast [sub-microsecond response times](http://fluxtion.com/solutions/high-performance-flight-analysis/) -- Ahead of time compiler for fast startup and easy embedding - -# Introduction -Thanks for dropping by, hope we can persuade you to donate your time to investigate Fluxtion further. - -Fluxtion is a fully featured java based event stream processor that brings real-time data processing -inside your application. If you need to build applications that react to complex events and make -fast decisions then Fluxtion is for you. We build stream processing logic free from any messaging -layer. - -Whether you need to process tens of millions of events per -second or write complex rule driven applications that make decisions in microseconds Fluxtion can help. -Built to embed within an applications, invoking user functions as well as publishing data results. - -Uniquely among stream processors Fluxtion employs ahead of time compilation to create a stream processing engine. -Describe your processing and Fluxtion tailors a solution to your needs at build time. -Ahead of time compilation offers several critical advantages over existing products, -- Faster startup times for your application, perfect for serverless architectures -- No vendor lock-in, the engine can be used within any java application -- Compiler optimized code gives higher performance and lower running costs -- Generated source code simplifies debugging and maintenance - -# Uses -- Real-time analytics and processing -- ETL -- Rules engines -- Low response time requirements -- IoT processing - -## Fluxtion application integration -![](docs/images/integration-overview.png) - -A Fluxtion event processor embeds within a user application, processing events, -publishing events to sinks or interacting with user classes. Events are feed from -the application directly into the processor or into a pipeline. A pipeline provides -additional capabilities such as threading, scheduling, auditing, access control - -## Philosophy + + +# Fluxtion is event driven Java + +--- + +Fluxtion is a java development productivity tool that makes writing and maintaining event driven business logic cheaper +and quicker. The Fluxtion dependency injection container exposes user beans as event driven service endpoints. A +container instance can be connected to any event delivery system freeing the business logic from messaging vendor lock-in. + +**Fluxtion minimises the cost of developing and maintaining event driven business logic** + +Developers concentrate on developing and extending business logic, dependency injection and realtime event dispatch is +handled by the container. The container supports: + +
+
+
+
    +
  • Streaming event processing
  • +
  • AOT compilation for fast start
  • +
  • Spring integration
  • +
+
+
+
+
+
    +
  • Low latency microsecond response
  • +
  • Event sourcing compatible
  • +
  • Functional and imperative construction
  • +
+
+
+
+ +# Fluxtion components +There are two major components provided by Fluxtion the developer uses to develop with. + +## Compiler +The compiler analyses the configuration information provided by the programmer and builds a dependency injection container +that houses all the user components or beans combined with pre-calculated event dispatch. Outputs from the compiler +are either +- In memory di container running in an interpreted mode +- A container generated ahead of time and serialised to code + +## Runtime +The runtime provides the dependency injection container with a core set of libraries required at runtime. An AOT generated +container only requires the runtime to function. The compiler is only required + +# Philosophy Our philosophy is to make delivering streaming applications in java simple by employing a -clean modern api similar to the familiar Java streams api. The Fluxtion compiler carries the +clean modern api that requires very little integration effort. The Fluxtion compiler carries the burden of generating simple efficient code that is optimised for your specific application. We pay the cost at compile time only once, so every execution of your stream processor sees benefits in reduced startup time and smaller running costs. -Why concentrate solely on the processing logic? There are many great messaging systems -out there offering scale out to hundreds of millions of events per second. But many reactive -applications do not need that scale, the problem is integrating the event streams from -different messaging systems into a single decision making engine. In cases like these -you want to concentrate on writing the logic. +# The cost of complexity problem + +Increasing system complexity makes delivery of new features expensive and time-consuming to deliver. Efficiently managing +complexity reduces both operational costs and time to market for new functionality, critical for a business to remain +profitable in a competitive environment. + +Event driven systems have two types of complexity to manage: + +- Delivering events to application components in a fault-tolerant predictable fashion. +- Developing application logic responses to events that meets business requirements + +Initially all the project complexity centres on the event delivery system, but over time this system becomes stable and +the complexity demands are minimal. Pre-packaged event delivery systems are a common solution to control complexity and +cost of event distribution. The opposite is true for event driven application logic, functional requirements increase +over time and developing application logic becomes ever more complex and expensive to deliver. + +**Fluxtion combines dependency injection and event dispatch increasing developer productivity** + +# Combining dependency injection and event processing + +The introduction of dependency injection gave developers a consistent approach to linking application components. +Fluxtion extends dependency injection to support container managed event driven beans. Extending a familiar development +pattern has the following benefits: +- Shallow learning curve for developers to use Fluxtion effectively +- Consistent programming model for event driven logic increases developer productivity +- Re-use of industrial quality and predictable event dispatch model + +**Fluxtion's familiar dependency injection programming model simplifies integration** + +## Dependency injection container -## Example -We have a five minute tutorial to dive into [here](https://github.com/v12technology/fluxtion-quickstart/tree/master). +Fluxtion builds a dependency injection container from configuration information given by the programmer. Functions +supported by the container include: creating instances, injecting references between beans, setting properties, calling +lifecycle methods, factory methods, singleton injection, named references, constructor and setter injection. +Configuration data can be programmatic, spring xml config, yaml or custom data format. -The sample below demonstrates the fluent functional api Fluxtion provides to describe data processing logic. The api -should be familiar to anyone who has coded with java 8 streams. +There are three options for building a container: -### Code sample +- Interpreted - built and run in process, uses dynamic dispatch can handle millions of nodes +- Compiled - static analysis, code generated and compiled in process. handles thousands of nodes +- Compiled AOT - code generated at build time, zero cost start time when deployed + +Fluxtion DI containers are very lightweight and designed to be run within an application. Multiple containers can be +used within a single application each container providing specialised business processing logic. + +## Automatic event dispatch + +The container exposes event consumer end-points, routing events as methods calls to beans within the container +via an internal dispatcher. The internal dispatcher propagates event notification through the object graph. + +Fluxtion leverages the familiar dependency injection workflow for constructing the object graph. Annotated +event handler and trigger methods are dispatch targets. When building a container Fluxtion uses the annotations to +calculate the dispatch call trees for the internal dispatcher. A bean can export multiple service interfaces or just a +single method. For exported interfaces the container generates proxies that routes calls from the proxy handler methods +to the container's dispatcher. + + + + +## Code sample ```java /** * Simple Fluxtion hello world stream example. Add two numbers and log when sum > 100 @@ -112,7 +169,7 @@ public class HelloWorld { } ``` -### Execution output +## Execution output ```text rcvd -> Data1[value=20.5] rcvd -> Data2[value=63.0] @@ -123,32 +180,10 @@ Process finished with exit code 0 ``` -## Highlights -### Ahead of time compiler -Fluxtion constructs a model of the stream processor and generates a set of java classes -that meet the requirement. The compiled code is highly optimised for memory and cpu. Small, -compact and jit friendly flxution stream processors get the best out of the JVM, giving -unbeatable performance. -### Pipeline vs graph processing -Fluxtion is built as a graph processor and not a pipeline. A pipeline has a single entry -point and single execution path, a graph processor has multiple entry points multiple execution -paths. Handling heterogeneous event types in a unique fashion is the default behaviour. -In fact the more complex the problem the greater the advantage that Fluxtion displays. -### Integrating with client code -Traditional stream processors have an ingest, transform and publish cycle. When moving -from analytics to actually taking actions there is a barrier to integrating the output -with the client application. With Fluxtion client code is integrated into the generated -processor and invoked directly. -### Describing a processor -Fluxtion constructs an intermediate representation for the ahead of time compiler to process. -The intermediate representation can be built from a variety of forms each with their -own advantages. The following descriptions are supported: -- Declarative or DSL -- Imperative -- Data driven -- Dependency injection based - -## Contributing + + + +# Contributing We welcome contributions to the project. Detailed information on our ways of working will be written in time. In brief our goals are: @@ -156,7 +191,7 @@ be written in time. In brief our goals are: * Author a change with suitabke test case and documentation. * Push your changes to a fork. * Submit a pull request. -## License +# License Fluxtion is licensed under the [Server Side Public License](https://www.mongodb.com/licensing/server-side-public-license). This license is created by MongoDb, for further info see [FAQ](https://www.mongodb.com/licensing/server-side-public-license/faq) and comparison with [AGPL v3.0](https://www.mongodb.com/licensing/server-side-public-license/faq). From c64173784ae51268b3af3641c091849836bba717 Mon Sep 17 00:00:00 2001 From: command-line Date: Sat, 23 Sep 2023 07:34:06 +0100 Subject: [PATCH 210/228] docs --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f8cfdfae6..8231e7aa3 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,10 @@ [![Github build](https://github.com/v12technology/fluxtion/workflows/MavenCI/badge.svg)](https://github.com/v12technology/fluxtion/actions) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/runtime/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.fluxtion/runtime) -## [User documentation](https://v12technology.github.io/fluxtion/) - - +# [USER DOCUMENTATION](https://v12technology.github.io/fluxtion/) # Fluxtion is event driven Java ---- - Fluxtion is a java development productivity tool that makes writing and maintaining event driven business logic cheaper and quicker. The Fluxtion dependency injection container exposes user beans as event driven service endpoints. A container instance can be connected to any event delivery system freeing the business logic from messaging vendor lock-in. @@ -45,8 +41,8 @@ handled by the container. The container supports: -# Fluxtion components -There are two major components provided by Fluxtion the developer uses to develop with. +# Top level components +There are two major components provided by Fluxtion the developer uses build event driven logic. ## Compiler The compiler analyses the configuration information provided by the programmer and builds a dependency injection container From b2feb2f928c9cb39bdce6a87b264e43d21a36624 Mon Sep 17 00:00:00 2001 From: command-line Date: Sat, 23 Sep 2023 07:38:44 +0100 Subject: [PATCH 211/228] docs --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8231e7aa3..0d37b2b6d 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ are either ## Runtime The runtime provides the dependency injection container with a core set of libraries required at runtime. An AOT generated -container only requires the runtime to function. The compiler is only required +container only requires the runtime to function, no compiler libraries are required. # Philosophy Our philosophy is to make delivering streaming applications in java simple by employing a @@ -122,6 +122,9 @@ to the container's dispatcher. ## Code sample +Fluxtion supports both imperative service style and functional patterns. Below is an example of functional coding style +that adds two numbers from independent data streams and logs when the um is greater than 100. + ```java /** * Simple Fluxtion hello world stream example. Add two numbers and log when sum > 100 From 61a120ef76645a40ece845aa9d7dd61a0e8d3d4b Mon Sep 17 00:00:00 2001 From: command-line Date: Sat, 23 Sep 2023 07:40:54 +0100 Subject: [PATCH 212/228] docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d37b2b6d..bc483762d 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ handled by the container. The container supports: # Top level components -There are two major components provided by Fluxtion the developer uses build event driven logic. +There are two major components provided by Fluxtion the developer uses to build event driven logic. ## Compiler The compiler analyses the configuration information provided by the programmer and builds a dependency injection container From 2fd855b26fc50062ac0a34401b597cc6dbd779f2 Mon Sep 17 00:00:00 2001 From: command-line Date: Sat, 23 Sep 2023 07:41:56 +0100 Subject: [PATCH 213/228] docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc483762d..ed39c762d 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ to the container's dispatcher. ## Code sample Fluxtion supports both imperative service style and functional patterns. Below is an example of functional coding style -that adds two numbers from independent data streams and logs when the um is greater than 100. +that adds two numbers from independent data streams and logs when the sum is greater than 100. ```java /** From 8068b91f703b9978922635ab51706ff496c11d0d Mon Sep 17 00:00:00 2001 From: command-line Date: Sat, 30 Sep 2023 12:31:27 +0100 Subject: [PATCH 214/228] Deletes no compile generated backup. Adds a no arg EventProcessorConfig#addAuditor configures auditing with no tracing. Clean formatting in LogRecord --- .../compiler/EventProcessorConfig.java | 7 ++++++ .../compiler/EventProcessorCompilation.java | 12 +++------- .../imperative/FluxtionBuilderTest.java | 24 +++++++++++++++++++ .../com/fluxtion/runtime/audit/LogRecord.java | 6 ++--- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java b/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java index 663745b00..c5b2fe5c4 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java +++ b/compiler/src/main/java/com/fluxtion/compiler/EventProcessorConfig.java @@ -233,6 +233,13 @@ public void addEventAudit(LogLevel tracingLogLevel) { addAuditor(new EventLogManager().tracingOn(tracingLogLevel), EventLogManager.NODE_NAME); } + /** + * Add an {@link EventLogManager} auditor to the generated SEP without method tracing + */ + public void addEventAudit() { + addAuditor(new EventLogManager().tracingOff(), EventLogManager.NODE_NAME); + } + public void addEventAudit(LogLevel tracingLogLevel, boolean printEventToString) { addEventAudit(tracingLogLevel, printEventToString, true); } diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java index 278e79d15..83a80f261 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java @@ -31,15 +31,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.Closeable; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringWriter; -import java.io.Writer; +import java.io.*; import java.nio.file.Files; import java.nio.file.Paths; @@ -159,6 +151,8 @@ private Class generateSep() throws Exception { FileUtils.delete(backupFile); backupFile = null; } + } else if (backupFile != null && formatSuccess) { + FileUtils.delete(backupFile); } if (backupFile != null && !formatSuccess) { FileUtils.delete(backupFile); diff --git a/compiler/src/test/java/com/fluxtion/compiler/builder/imperative/FluxtionBuilderTest.java b/compiler/src/test/java/com/fluxtion/compiler/builder/imperative/FluxtionBuilderTest.java index 4f7f6a97d..699b16395 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/builder/imperative/FluxtionBuilderTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/builder/imperative/FluxtionBuilderTest.java @@ -142,6 +142,30 @@ public void generateToStringWriterAndCompileTest() { assertThat(processor.getNodeById("handler").in, is("HELLO")); } + @Test + @SneakyThrows + public void generateNoCompileTestDeleteBackup() { + String path = new File(OutputRegistry.JAVA_TESTGEN_DIR).getCanonicalPath(); + Fluxtion.compile( + processorCfg -> processorCfg.addNode(new MyStringHandler(), "handler"), + compilerConfig -> { + compilerConfig.setCompileSource(false); + compilerConfig.setPackageName("com.whatever"); + compilerConfig.setClassName("MYProcessor"); + compilerConfig.setGenerateDescription(false); + compilerConfig.setOutputDirectory(path); + }); + Fluxtion.compile( + processorCfg -> processorCfg.addNode(new MyStringHandler(), "handler"), + compilerConfig -> { + compilerConfig.setCompileSource(false); + compilerConfig.setPackageName("com.whatever"); + compilerConfig.setClassName("MYProcessor"); + compilerConfig.setGenerateDescription(false); + compilerConfig.setOutputDirectory(path); + }); + } + @Test public void buildFromFluxtionGraphBuilder() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, IOException, URISyntaxException, NoSuchFieldException { int generationCount = Fluxtion.scanAndCompileFluxtionBuilders( diff --git a/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java b/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java index 2007658d8..8e46cd248 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java +++ b/runtime/src/main/java/com/fluxtion/runtime/audit/LogRecord.java @@ -165,10 +165,10 @@ public void triggerEvent(Event event) { sb.append("\n groupingId: ").append(groupingId); sb.append("\n event: ").append(aClass.getSimpleName()); if (printEventToString) { - sb.append("\n eventToString: {").append(event.toString()).append('}'); + sb.append("\n eventToString: ").append(event.toString()); } if (printThreadName) { - sb.append("\n thread: {").append(Thread.currentThread().getName()).append('}'); + sb.append("\n thread: ").append(Thread.currentThread().getName()); } if (event.filterString() != null && !event.filterString().isEmpty()) { sb.append("\n eventFilter: ").append(event.filterString()); @@ -187,7 +187,7 @@ public void triggerObject(Object event) { sb.append("\n groupingId: ").append(groupingId); sb.append("\n event: ").append(aClass.getSimpleName()); if (printEventToString) { - sb.append("\n eventToString: {").append(event.toString()).append('}'); + sb.append("\n eventToString: ").append(event.toString()); } sb.append("\n nodeLogs: "); } From 3d26f7318fbcff6f53e0c30f28d8f12f68ee62f1 Mon Sep 17 00:00:00 2001 From: runner Date: Sat, 30 Sep 2023 11:43:24 +0000 Subject: [PATCH 215/228] updating poms for 9.1.11-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 71bdc645c..074ac330a 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.10-SNAPSHOT + 9.1.11-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index f1fe52a76..58e8af066 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.10-SNAPSHOT + 9.1.11-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 4e2c07d15..57b9627d0 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.10-SNAPSHOT + 9.1.11-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 8b3e64c63..bbb767752 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.10-SNAPSHOT + 9.1.11-SNAPSHOT ../parent-root/pom.xml From 76dc51db6f899cb6837432482689e77b71c70e71 Mon Sep 17 00:00:00 2001 From: runner Date: Sat, 30 Sep 2023 11:43:34 +0000 Subject: [PATCH 216/228] updating poms for branch'release/9.1.10' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 71bdc645c..cd7055c08 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.10-SNAPSHOT + 9.1.10 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index f1fe52a76..a8d5b0671 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.10-SNAPSHOT + 9.1.10 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 4e2c07d15..192a63a23 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.10-SNAPSHOT + 9.1.10 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 8b3e64c63..374436d6d 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.10-SNAPSHOT + 9.1.10 ../parent-root/pom.xml From f9e413221866503e1e4a22850951aa9be09958f7 Mon Sep 17 00:00:00 2001 From: runner Date: Sat, 30 Sep 2023 11:47:41 +0000 Subject: [PATCH 217/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 074ac330a..cd7055c08 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.11-SNAPSHOT + 9.1.10 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 58e8af066..a8d5b0671 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.11-SNAPSHOT + 9.1.10 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 57b9627d0..192a63a23 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.11-SNAPSHOT + 9.1.10 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index bbb767752..374436d6d 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.11-SNAPSHOT + 9.1.10 ../parent-root/pom.xml From 6afec4c53294e9ea0386c4f84fe56fffdc070dee Mon Sep 17 00:00:00 2001 From: runner Date: Sat, 30 Sep 2023 11:47:42 +0000 Subject: [PATCH 218/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index cd7055c08..074ac330a 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.10 + 9.1.11-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index a8d5b0671..58e8af066 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.10 + 9.1.11-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 192a63a23..57b9627d0 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.10 + 9.1.11-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 374436d6d..bbb767752 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.10 + 9.1.11-SNAPSHOT ../parent-root/pom.xml From b97198c72b2d0444407971121496db7adb498c34 Mon Sep 17 00:00:00 2001 From: greg higgins Date: Tue, 24 Oct 2023 08:43:00 +0100 Subject: [PATCH 219/228] docs (#242) Co-authored-by: greg --- .../fluxtion/compiler/FluxtionCompilerConfig.java | 13 +++++++++++++ .../compiler/EventProcessorCompilation.java | 2 +- .../compiler/EventProcessorGenerator.java | 13 ++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/FluxtionCompilerConfig.java b/compiler/src/main/java/com/fluxtion/compiler/FluxtionCompilerConfig.java index 42b3ff417..25db8b8ab 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/FluxtionCompilerConfig.java +++ b/compiler/src/main/java/com/fluxtion/compiler/FluxtionCompilerConfig.java @@ -94,6 +94,10 @@ public class FluxtionCompilerConfig { * The if {@link #writeSourceToFile} is false this writer will capture the content of the generation process */ private Writer sourceWriter; + /** + * Flag controlling adding build time to generated source files + */ + private boolean addBuildTime; private transient ClassLoader classLoader; @@ -101,6 +105,7 @@ public FluxtionCompilerConfig() { generateDescription = false; writeSourceToFile = false; compileSource = true; + addBuildTime = false; formatSource = true; templateSep = JAVA_TEMPLATE; classLoader = FluxtionCompilerConfig.class.getClassLoader(); @@ -157,6 +162,14 @@ public void setWriteSourceToFile(boolean writeSourceToFile) { this.writeSourceToFile = writeSourceToFile; } + public boolean isAddBuildTime() { + return addBuildTime; + } + + public void setAddBuildTime(boolean addBuildTime) { + this.addBuildTime = addBuildTime; + } + public void setPackageName(String packageName) { this.packageName = packageName; } diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java index 83a80f261..ae0fb81c7 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java @@ -105,7 +105,7 @@ private Class generateSep() throws Exception { } EventProcessorGenerator eventProcessorGenerator = new EventProcessorGenerator(); - eventProcessorGenerator.templateSep(builderConfig, compilerConfig.isGenerateDescription(), writer); + eventProcessorGenerator.templateSep(builderConfig, compilerConfig, writer); GenerationContext generationConfig = GenerationContext.SINGLETON; String fqn = generationConfig.getPackageName() + "." + generationConfig.getSepClassName(); File file = new File(generationConfig.getPackageDirectory(), generationConfig.getSepClassName() + ".java"); diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java index 6bc1ed0c9..5a6f8c2ce 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java @@ -18,6 +18,7 @@ package com.fluxtion.compiler.generation.compiler; import com.fluxtion.compiler.EventProcessorConfig; +import com.fluxtion.compiler.FluxtionCompilerConfig; import com.fluxtion.compiler.builder.factory.NodeFactoryLocator; import com.fluxtion.compiler.builder.factory.NodeFactoryRegistration; import com.fluxtion.compiler.generation.GenerationContext; @@ -63,6 +64,7 @@ public class EventProcessorGenerator { private EventProcessorConfig config; private static final Logger LOG = LoggerFactory.getLogger(EventProcessorGenerator.class); private SimpleEventProcessorModel simpleEventProcessorModel; + private FluxtionCompilerConfig compilerConfig; public InMemoryEventProcessor inMemoryProcessor(EventProcessorConfig config, boolean generateDescription) throws Exception { config.buildConfig(); @@ -95,10 +97,11 @@ public InMemoryEventProcessor inMemoryProcessor(EventProcessorConfig config, boo return new InMemoryEventProcessor(simpleEventProcessorModel, config); } - public void templateSep(EventProcessorConfig config, boolean generateDescription, Writer writer) throws Exception { + public void templateSep(EventProcessorConfig config, FluxtionCompilerConfig compilerConfig, Writer writer) throws Exception { ExecutorService execSvc = Executors.newCachedThreadPool(); config.buildConfig(); this.config = config; + this.compilerConfig = compilerConfig; LOG.debug("init velocity"); initVelocity(); LOG.debug("start graph calc"); @@ -117,7 +120,7 @@ public void templateSep(EventProcessorConfig config, boolean generateDescription simpleEventProcessorModel.generateMetaModel(config.isSupportDirtyFiltering()); //TODO add conditionality for different target languages //buildJava output - if (generateDescription) { + if (compilerConfig.isGenerateDescription()) { execSvc.submit(() -> { LOG.debug("start exporting graphML/images"); exportGraphMl(graph); @@ -190,7 +193,11 @@ private void templateJavaOutput(Writer templateWriter) throws Exception { private void addVersionInformation(Context ctx) { ctx.put("generator_version_information", this.getClass().getPackage().getImplementationVersion()); ctx.put("api_version_information", OnEventHandler.class.getPackage().getImplementationVersion()); - ctx.put("build_time", LocalDateTime.now()); + if (compilerConfig.isAddBuildTime()) { + ctx.put("build_time", LocalDateTime.now()); + } else { + ctx.put("build_time", "Not available"); + } } public static void formatSource(File outFile) { From 1194ed38b04ffb5b33ef8c7901b9971a197e0be7 Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 24 Oct 2023 08:20:15 +0000 Subject: [PATCH 220/228] updating poms for 9.1.12-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 074ac330a..3ae00c815 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.11-SNAPSHOT + 9.1.12-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 58e8af066..c81a26276 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.11-SNAPSHOT + 9.1.12-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 57b9627d0..fb72804dc 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.11-SNAPSHOT + 9.1.12-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index bbb767752..2d2facd4e 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.11-SNAPSHOT + 9.1.12-SNAPSHOT ../parent-root/pom.xml From ea972c023c9ec28d5b710d83cf6e0518e310d7e4 Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 24 Oct 2023 08:20:22 +0000 Subject: [PATCH 221/228] updating poms for branch'release/9.1.11' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 074ac330a..e5a92d8aa 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.11-SNAPSHOT + 9.1.11 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 58e8af066..1f6e4efeb 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.11-SNAPSHOT + 9.1.11 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 57b9627d0..783f20d16 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.11-SNAPSHOT + 9.1.11 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index bbb767752..500a3e2a7 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.11-SNAPSHOT + 9.1.11 ../parent-root/pom.xml From 940234aa0daf88cff0a2f991325ec469e7a801d6 Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 24 Oct 2023 08:27:04 +0000 Subject: [PATCH 222/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 3ae00c815..e5a92d8aa 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.12-SNAPSHOT + 9.1.11 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index c81a26276..1f6e4efeb 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.12-SNAPSHOT + 9.1.11 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index fb72804dc..783f20d16 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.12-SNAPSHOT + 9.1.11 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 2d2facd4e..500a3e2a7 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.12-SNAPSHOT + 9.1.11 ../parent-root/pom.xml From 5ebccebd404600088a4a77a64d82da20f6bc8964 Mon Sep 17 00:00:00 2001 From: runner Date: Tue, 24 Oct 2023 08:27:05 +0000 Subject: [PATCH 223/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index e5a92d8aa..3ae00c815 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.11 + 9.1.12-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 1f6e4efeb..c81a26276 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.11 + 9.1.12-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 783f20d16..fb72804dc 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.11 + 9.1.12-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 500a3e2a7..2d2facd4e 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.11 + 9.1.12-SNAPSHOT ../parent-root/pom.xml From f3d16f1585e30a1c99c4c0d69cde1040d699193f Mon Sep 17 00:00:00 2001 From: command-line Date: Sun, 3 Dec 2023 16:29:34 +0000 Subject: [PATCH 224/228] Adds support in data flow for mapping to sets and lists in FlowBuilder. Compound keys in groupBy are supported with GroupByKey in FlowBuilder. --- .../builder/dataflow/FlowBuilder.java | 168 ++++++++++++++++-- .../builder/dataflow/FlowBuilderBase.java | 4 +- .../serialiser/FieldSerializer.java | 5 + .../dataflow/EventStreamBuildTest.java | 117 ++++++++++-- .../builder/dataflow/GroupByTest.java | 160 +++++++++++++++++ .../builder/dataflow/NestedGroupByTest.java | 4 +- .../function/AggregateToListFlowFunction.java | 2 +- .../function/AggregateToSetFlowFunction.java | 9 +- .../runtime/dataflow/groupby/GroupByKey.java | 109 ++++++++++++ .../runtime/dataflow/helpers/Collectors.java | 21 ++- .../dataflow/helpers/GroupingFactory.java | 2 +- 11 files changed, 561 insertions(+), 40 deletions(-) create mode 100644 runtime/src/main/java/com/fluxtion/runtime/dataflow/groupby/GroupByKey.java diff --git a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilder.java b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilder.java index c4598bd95..6989be7b5 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilder.java +++ b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilder.java @@ -9,16 +9,9 @@ import com.fluxtion.runtime.dataflow.aggregate.function.TimedSlidingWindow; import com.fluxtion.runtime.dataflow.aggregate.function.TumblingWindow; import com.fluxtion.runtime.dataflow.function.BinaryMapFlowFunction.BinaryMapToRefFlowFunction; -import com.fluxtion.runtime.dataflow.function.FlatMapArrayFlowFunction; -import com.fluxtion.runtime.dataflow.function.FlatMapFlowFunction; -import com.fluxtion.runtime.dataflow.function.LookupFlowFunction; -import com.fluxtion.runtime.dataflow.function.MapFlowFunction; +import com.fluxtion.runtime.dataflow.function.*; import com.fluxtion.runtime.dataflow.function.MapFlowFunction.MapRef2RefFlowFunction; -import com.fluxtion.runtime.dataflow.function.MergeFlowFunction; -import com.fluxtion.runtime.dataflow.groupby.GroupBy; -import com.fluxtion.runtime.dataflow.groupby.GroupByFlowFunctionWrapper; -import com.fluxtion.runtime.dataflow.groupby.GroupByTimedSlidingWindow; -import com.fluxtion.runtime.dataflow.groupby.GroupByTumblingWindow; +import com.fluxtion.runtime.dataflow.groupby.*; import com.fluxtion.runtime.dataflow.helpers.Aggregates; import com.fluxtion.runtime.dataflow.helpers.Collectors; import com.fluxtion.runtime.dataflow.helpers.DefaultValue; @@ -80,6 +73,30 @@ public FlowBuilder map(SerializableFunction mapFunction) { return super.mapBase(mapFunction); } + public FlowBuilder> mapToSet() { + return map(Collectors.toSet()); + } + + public FlowBuilder> mapToSet(SerializableFunction mapFunction) { + return map(mapFunction).map(Collectors.toSet()); + } + + public FlowBuilder> mapToList() { + return map(Collectors.toList()); + } + + public FlowBuilder> mapToList(SerializableFunction mapFunction) { + return map(mapFunction).map(Collectors.toList()); + } + + public FlowBuilder> mapToList(int maxElements) { + return map(Collectors.toList(maxElements)); + } + + public FlowBuilder> mapToList(SerializableFunction mapFunction, int maxElements) { + return map(mapFunction).map(Collectors.toList(maxElements)); + } + public FlowBuilder mapBiFunction(SerializableBiFunction int2IntFunction, FlowBuilder stream2Builder) { @@ -130,6 +147,19 @@ public FlowBuilder flatMapFromArray(SerializableFunction iterable new TimedSlidingWindow<>(eventStream, aggregateFunction, bucketSizeMillis, bucketsPerWindow)); } + /** + * Aggregates a flow using a key function to group by and an aggregating function to process new values for a keyed + * bucket. + * + * @param keyFunction The key function that groups and buckets incoming values + * @param valueFunction The value that is extracted from the incoming stream and applied to the aggregating function + * @param aggregateFunctionSupplier A factory that supplies aggregating functions, each function has its own function instance + * @param Value type extracted from the incoming data flow + * @param The type of the key used to group values + * @param The return type of the aggregating function + * @param The aggregating function type + * @return A GroupByFlowBuilder for the aggregated flow + */ public > GroupByFlowBuilder groupBy(SerializableFunction keyFunction, SerializableFunction valueFunction, @@ -139,33 +169,147 @@ public FlowBuilder flatMapFromArray(SerializableFunction iterable return new GroupByFlowBuilder<>(x); } + /** + * Specialisation of groupBy where the value is the identity of the incoming data flow + * + * @param keyFunction The key function that groups and buckets incoming values + * @param aggregateFunctionSupplier A factory that supplies aggregating functions, each function has its own function instance + * @param The type of the key used to group values + * @param The return type of the aggregating function + * @param The aggregating function type + * @return A GroupByFlowBuilder for the aggregated flow + * @see FlowBuilder#groupBy(SerializableFunction, SerializableFunction, SerializableSupplier) + */ public > GroupByFlowBuilder groupBy(SerializableFunction keyFunction, SerializableSupplier aggregateFunctionSupplier) { return groupBy(keyFunction, Mappers::identity, aggregateFunctionSupplier); } + /** + * Specialisation of groupBy where the output of the groupBy is the last value received for a bucket. The value is + * extracted using the value function + * + * @param keyFunction The key function that groups and buckets incoming values + * @param valueFunction The value that is extracted from the incoming stream and applied to the aggregating function + * @param Value type extracted from the incoming data flow + * @param The type of the key used to group values + * @return A GroupByFlowBuilder for the aggregated flow + * @see FlowBuilder#groupBy(SerializableFunction, SerializableFunction, SerializableSupplier) + */ public GroupByFlowBuilder groupBy( SerializableFunction keyFunction, SerializableFunction valueFunction) { return groupBy(keyFunction, valueFunction, Aggregates.identityFactory()); } + /** + * Specialisation of groupBy where the output of the groupBy is the last value received for a bucket, where + * the value is the identity of the incoming data flow + * + * @param keyFunction The key function that groups and buckets incoming values + * @param The type of the key used to group values + * @return A GroupByFlowBuilder for the aggregated flow + */ public GroupByFlowBuilder groupBy(SerializableFunction keyFunction) { return groupBy(keyFunction, Mappers::identity); } + /** + * Creates a GroupByFlowBuilder using a compound key created by a set of method reference accessors to for the value. + * The value is the last value supplied + * + * @param keyFunction key accessor + * @param keyFunctions multi arg key accessors + * @return GroupByFlowBuilder keyed on properties + */ + @SafeVarargs + public final GroupByFlowBuilder, T> groupByFields( + SerializableFunction keyFunction, + SerializableFunction... keyFunctions) { + return groupBy(GroupByKey.build(keyFunction, keyFunctions)); + } + + /** + * Aggregates a flow using a key to group by and an aggregating function to process new values for a keyed + * bucket. The key is a compound key created by a set of method reference accessors to for the value. + * + * @param aggregateFunctionSupplier A factory that supplies aggregating functions, each function has its own function instance + * @param keyFunction key accessor + * @param keyFunctions multi arg key accessors + * @param The return type of the aggregating function + * @param The aggregating function type + * @return A GroupByFlowBuilder for the aggregated flow + * @see FlowBuilder#groupBy(SerializableFunction, SerializableFunction, SerializableSupplier) + */ + @SafeVarargs + public final > GroupByFlowBuilder, A> groupByFieldsAggregate( + SerializableSupplier aggregateFunctionSupplier, + SerializableFunction keyFunction, + SerializableFunction... keyFunctions) { + return groupBy(GroupByKey.build(keyFunction, keyFunctions), aggregateFunctionSupplier); + } + + /** + * Creates a GroupByFlowBuilder using a compound key created by a set of method reference accessors to for the key + * The value is extracted from the input using the value function + * + * @param valueFunction the value that will be stored in the groupBy + * @param keyFunction key accessor + * @param keyFunctions multi arg key accessors + * @return GroupByFlowBuilder keyed on properties + */ + @SafeVarargs + public final GroupByFlowBuilder, V> groupByFieldsAndGet( + SerializableFunction valueFunction, + SerializableFunction keyFunction, + SerializableFunction... keyFunctions) { + return groupBy(GroupByKey.build(keyFunction, keyFunctions), valueFunction); + } + + /** + * Creates a GroupByFlowBuilder using a compound key created by a set of method reference accessors to for the key + * The value is extracted from the input using the value function and is used as an input to the aggregating function + * + * @param valueFunction the value that will be stored in the groupBy + * @param aggregateFunctionSupplier A factory that supplies aggregating functions, each function has its own function instance + * @param keyFunction key accessor + * @param keyFunctions multi arg key accessors + * @param Value type extracted from the incoming data flow + * @param The return type of the aggregating function + * @param The aggregating function type + * @return A GroupByFlowBuilder for the aggregated flow + * @see FlowBuilder#groupBy(SerializableFunction, SerializableFunction, SerializableSupplier) + */ + @SafeVarargs + public final > GroupByFlowBuilder, A> groupByFieldsGetAndAggregate( + SerializableFunction valueFunction, + SerializableSupplier aggregateFunctionSupplier, + SerializableFunction keyFunction, + SerializableFunction... keyFunctions) { + return groupBy(GroupByKey.build(keyFunction, keyFunctions), valueFunction, aggregateFunctionSupplier); + } + public GroupByFlowBuilder> groupByToList(SerializableFunction keyFunction) { - return groupBy(keyFunction, Mappers::identity, Collectors.toList()); + return groupBy(keyFunction, Mappers::identity, Collectors.listFactory()); + } + + public GroupByFlowBuilder> groupByToList( + SerializableFunction keyFunction, SerializableFunction valueFunction) { + return groupBy(keyFunction, valueFunction, Collectors.listFactory()); } public GroupByFlowBuilder> groupByToSet(SerializableFunction keyFunction) { - return groupBy(keyFunction, Mappers::identity, Collectors.toSet()); + return groupBy(keyFunction, Mappers::identity, Collectors.setFactory()); + } + + public GroupByFlowBuilder> groupByToSet(SerializableFunction keyFunction, SerializableFunction valueFunction) { + return groupBy(keyFunction, valueFunction, Collectors.setFactory()); } public GroupByFlowBuilder> groupByToList( SerializableFunction keyFunction, int maxElementsInList) { - return groupBy(keyFunction, Mappers::identity, Collectors.toList(maxElementsInList)); + return groupBy(keyFunction, Mappers::identity, Collectors.listFactory(maxElementsInList)); } public > GroupByFlowBuilder diff --git a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilderBase.java b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilderBase.java index 4b996ef51..382c552e9 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilderBase.java +++ b/compiler/src/main/java/com/fluxtion/compiler/builder/dataflow/FlowBuilderBase.java @@ -129,12 +129,12 @@ public FlowBuilderBase merge(FlowBuilderBase streamToMerge) { public GroupByFlowBuilder> groupByAsList(SerializableFunction keyFunction) { - return groupBy(keyFunction, Mappers::identity, Collectors.toList()); + return groupBy(keyFunction, Mappers::identity, Collectors.listFactory()); } public GroupByFlowBuilder> groupByAsList(SerializableFunction keyFunction, int maxElementsInList) { - return groupBy(keyFunction, Mappers::identity, Collectors.toList(maxElementsInList)); + return groupBy(keyFunction, Mappers::identity, Collectors.listFactory(maxElementsInList)); } public > GroupByFlowBuilder diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/serialiser/FieldSerializer.java b/compiler/src/main/java/com/fluxtion/compiler/generation/serialiser/FieldSerializer.java index 71a7a03dd..f6f635ea7 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/serialiser/FieldSerializer.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/serialiser/FieldSerializer.java @@ -4,6 +4,7 @@ import com.fluxtion.compiler.generation.GenerationContext; import com.fluxtion.compiler.generation.model.Field; import com.fluxtion.compiler.generation.util.ClassUtils; +import com.fluxtion.runtime.dataflow.groupby.GroupByKey; import com.fluxtion.runtime.dataflow.helpers.GroupingFactory; import org.jetbrains.annotations.NotNull; @@ -184,6 +185,10 @@ public String buildTypeDeclaration(Field field, Function, String> class String genericDeclaration = "<" + inputClass + ", " + returnType + ", ?, ?>"; return genericDeclaration; } + if (instance instanceof GroupByKey) { + GroupByKey groupByKey = (GroupByKey) instance; + return "<" + classNameConverter.apply(groupByKey.getValueClass()) + ">"; + } return ""; } diff --git a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/EventStreamBuildTest.java b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/EventStreamBuildTest.java index 2559511c0..f0f3d6f80 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/EventStreamBuildTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/EventStreamBuildTest.java @@ -27,13 +27,7 @@ import org.junit.Test; import java.util.AbstractMap.SimpleEntry; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.concurrent.atomic.LongAdder; import static com.fluxtion.compiler.builder.dataflow.DataFlow.*; @@ -494,7 +488,7 @@ public void aggregateTest() { @Test public void aggregateToLIstTest() { sep(c -> subscribe(String.class) - .aggregate(Collectors.toList(4)) + .aggregate(Collectors.listFactory(4)) .id("myList")); onEvent("A"); @@ -546,6 +540,111 @@ public void tumblingMap() { assertThat(getStreamed("sum"), is(0)); } + @Test + public void testMapToSet() { + sep(c -> DataFlow.subscribe(String.class).mapToSet().id("set")); + HashSet set = new HashSet<>(); + set.add("test"); + onEvent("test"); + onEvent("test"); + assertThat(getStreamed("set"), is(set)); + onEvent("test2"); + set.add("test2"); + assertThat(getStreamed("set"), is(set)); + onEvent("test"); + assertThat(getStreamed("set"), is(set)); + } + + @Test + public void testMapToSetFromProperty() { + sep(c -> DataFlow.subscribe(GroupByTest.Data.class).mapToSet(GroupByTest.Data::getName).id("set")); + HashSet set = new HashSet<>(); + set.add("test"); + onEvent(new GroupByTest.Data("test", 22)); + onEvent(new GroupByTest.Data("test", 31)); + assertThat(getStreamed("set"), is(set)); + onEvent(new GroupByTest.Data("test2", 2334)); + set.add("test2"); + assertThat(getStreamed("set"), is(set)); + onEvent(new GroupByTest.Data("test", 31)); + assertThat(getStreamed("set"), is(set)); + } + + @Test + public void testMapToList() { + sep(c -> DataFlow.subscribe(String.class).mapToList().id("list")); + List list = new ArrayList<>(); + list.add("test"); + list.add("test"); + onEvent("test"); + onEvent("test"); + assertThat(getStreamed("list"), is(list)); + onEvent("test2"); + list.add("test2"); + assertThat(getStreamed("list"), is(list)); + onEvent("test"); + list.add("test"); + assertThat(getStreamed("list"), is(list)); + } + + @Test + public void testMapToList_MaxElements() { + sep(c -> DataFlow.subscribe(String.class).mapToList(2).id("list")); + List list = new ArrayList<>(); + list.add("test"); + list.add("test"); + onEvent("test"); + onEvent("test"); + assertThat(getStreamed("list"), is(list)); + //deleting + onEvent("test2"); + list.add("test2"); + list.remove(0); + assertThat(getStreamed("list"), is(list)); + //deleting + onEvent("test"); + list.add("test"); + list.remove(0); + assertThat(getStreamed("list"), is(list)); + } + + @Test + public void testMapToListFromProperty() { + sep(c -> DataFlow.subscribe(GroupByTest.Data.class).mapToList(GroupByTest.Data::getName).id("list")); + List list = new ArrayList<>(); + list.add("test"); + list.add("test"); + onEvent(new GroupByTest.Data("test", 22)); + onEvent(new GroupByTest.Data("test", 31)); + assertThat(getStreamed("list"), is(list)); + onEvent(new GroupByTest.Data("test2", 2334)); + list.add("test2"); + assertThat(getStreamed("list"), is(list)); + onEvent(new GroupByTest.Data("test3", 3451)); + list.add("test3"); + assertThat(getStreamed("list"), is(list)); + } + + @Test + public void testMapToListFromProperty_MaxElements() { + sep(c -> DataFlow.subscribe(GroupByTest.Data.class).mapToList(GroupByTest.Data::getName, 2).id("list")); + List list = new ArrayList<>(); + list.add("test1"); + list.add("test2"); + onEvent(new GroupByTest.Data("test1", 22)); + onEvent(new GroupByTest.Data("test2", 31)); + assertThat(getStreamed("list"), is(list)); + //deleting + onEvent(new GroupByTest.Data("test3", 2334)); + list.add("test3"); + list.remove(0); + assertThat(getStreamed("list"), is(list)); + //deleting + onEvent(new GroupByTest.Data("tes4", 3451)); + list.add("tes4"); + list.remove(0); + assertThat(getStreamed("list"), is(list)); + } @Value public static class Person { @@ -554,12 +653,10 @@ public static class Person { String gender; } - public static int doubleInt(int value) { return value * 2; } - @Value public static class MergedType { int value; diff --git a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/GroupByTest.java b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/GroupByTest.java index 936831e2a..ff64cc25b 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/GroupByTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/GroupByTest.java @@ -5,13 +5,16 @@ import com.fluxtion.compiler.builder.dataflow.EventStreamBuildTest.MyIntFilter; import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest.SepTestConfig; import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest; +import com.fluxtion.runtime.dataflow.aggregate.AggregateFlowFunction; import com.fluxtion.runtime.dataflow.aggregate.function.primitive.DoubleSumFlowFunction; import com.fluxtion.runtime.dataflow.aggregate.function.primitive.IntSumFlowFunction; import com.fluxtion.runtime.dataflow.groupby.GroupBy; import com.fluxtion.runtime.dataflow.groupby.GroupBy.KeyValue; +import com.fluxtion.runtime.dataflow.groupby.GroupByKey; import com.fluxtion.runtime.dataflow.helpers.Aggregates; import com.fluxtion.runtime.dataflow.helpers.Mappers; import com.fluxtion.runtime.dataflow.helpers.Tuples; +import lombok.Getter; import lombok.Value; import lombok.val; import org.hamcrest.CoreMatchers; @@ -605,6 +608,163 @@ public void maintainModel() { onEvent(new MyEvent(SubSystem.REFERENCE, Change_type.DELETE, "greg-1")); } + @Value + public static class Data3 { + String name; + int value; + int x; + + + } + + @Getter + public static class Data3Aggregate implements AggregateFlowFunction { + int value; + + @Override + public Integer reset() { + return value; + } + + @Override + public Integer get() { + return value; + } + + @Override + public Integer aggregate(Data3 input) { + value += input.getX(); + return get(); + } + } + + @Test + public void groupingKey() { + Map, Data3> expected = new HashMap<>(); + sep(c -> { + subscribe(Data3.class) + .groupByFields(Data3::getName, Data3::getValue) + .map(GroupBy::toMap) + .id("results"); + }); + val keyFactory = GroupByKey.build(Data3::getName, Data3::getValue);//.apply(); + + onEvent(new Data3("A", 10, 1)); + expected.put(keyFactory.apply(new Data3("A", 10, 1)), new Data3("A", 10, 1)); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 data2 = new Data3("A", 10, 2); + onEvent(data2); + expected.put(keyFactory.apply(data2), data2); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 data3 = new Data3("A", 10, 3); + onEvent(data3); + expected.put(keyFactory.apply(data3), data3); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 data4 = new Data3("A", 15, 111); + onEvent(data4); + expected.put(keyFactory.apply(data4), data4); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 dataB1 = new Data3("B", 10, 1); + onEvent(dataB1); + expected.put(keyFactory.apply(dataB1), dataB1); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 dataB2 = new Data3("B", 10, 99); + onEvent(dataB2); + expected.put(keyFactory.apply(dataB2), dataB2); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + } + + @Test + public void aggregateCompoundField() { + Map, Integer> expected = new HashMap<>(); + sep(c -> { + subscribe(Data3.class) + .groupByFieldsAggregate(Data3Aggregate::new, Data3::getName, Data3::getValue) + .map(GroupBy::toMap) + .id("results"); + }); + val keyFactory = GroupByKey.build(Data3::getName, Data3::getValue);//.apply(); + + onEvent(new Data3("A", 10, 1)); + expected.put(keyFactory.apply(new Data3("A", 10, 1)), 1); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 data2 = new Data3("A", 10, 2); + onEvent(data2); + expected.put(keyFactory.apply(data2), 3); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 data3 = new Data3("A", 10, 3); + onEvent(data3); + expected.put(keyFactory.apply(data3), 6); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 data4 = new Data3("A", 15, 111); + onEvent(data4); + expected.put(keyFactory.apply(data4), 111); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 dataB1 = new Data3("B", 10, 1); + onEvent(dataB1); + expected.put(keyFactory.apply(dataB1), 1); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 dataB2 = new Data3("B", 10, 99); + onEvent(dataB2); + expected.put(keyFactory.apply(dataB2), 100); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + } + + @Test + public void aggregateExtractedPropertyCompoundField() { + Map, Integer> expected = new HashMap<>(); + sep(c -> { + subscribe(Data3.class) + .groupByFieldsGetAndAggregate( + Data3::getX, + Aggregates.intSumFactory(), + Data3::getName, Data3::getValue) + .map(GroupBy::toMap) + .id("results"); + }); + val keyFactory = GroupByKey.build(Data3::getName, Data3::getValue);//.apply(); + + onEvent(new Data3("A", 10, 1)); + expected.put(keyFactory.apply(new Data3("A", 10, 1)), 1); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 data2 = new Data3("A", 10, 2); + onEvent(data2); + expected.put(keyFactory.apply(data2), 3); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 data3 = new Data3("A", 10, 3); + onEvent(data3); + expected.put(keyFactory.apply(data3), 6); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 data4 = new Data3("A", 15, 111); + onEvent(data4); + expected.put(keyFactory.apply(data4), 111); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 dataB1 = new Data3("B", 10, 1); + onEvent(dataB1); + expected.put(keyFactory.apply(dataB1), 1); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + + Data3 dataB2 = new Data3("B", 10, 99); + onEvent(dataB2); + expected.put(keyFactory.apply(dataB2), 100); + MatcherAssert.assertThat(getStreamed("results"), is(expected)); + } + + public static MyModel updateItemScalar(MyModel model, MyEvent myEvent) { model.createItem(myEvent.getData()); return model; diff --git a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/NestedGroupByTest.java b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/NestedGroupByTest.java index 2dbe54c78..f0148d4a2 100644 --- a/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/NestedGroupByTest.java +++ b/compiler/src/test/java/com/fluxtion/compiler/builder/dataflow/NestedGroupByTest.java @@ -120,7 +120,7 @@ public void nestedGroupByToList_WithHelper() { @Test public void nestedDataFlowGroupBy_toCollector() { sep(c -> { - DataFlow.groupBy(Person::getCountry, Collectors.groupingBy(Person::getGender, Collectors.toList())) + DataFlow.groupBy(Person::getCountry, Collectors.groupingBy(Person::getGender, Collectors.listFactory())) .sink("groupBy"); }); this.addSink("groupBy", this::convertToMapList); @@ -179,7 +179,7 @@ public void nestedGroupByToCollector_List_WithHelper() { subscribe(Person.class) .groupBy( Person::getCountry, - Collectors.groupingBy(Person::getGender, Collectors.toList())) + Collectors.groupingBy(Person::getGender, Collectors.listFactory())) .sink("groupBy"); }); this.addSink("groupBy", this::convertToMapList); diff --git a/runtime/src/main/java/com/fluxtion/runtime/dataflow/aggregate/function/AggregateToListFlowFunction.java b/runtime/src/main/java/com/fluxtion/runtime/dataflow/aggregate/function/AggregateToListFlowFunction.java index 0bd71d06a..8e723cac2 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/dataflow/aggregate/function/AggregateToListFlowFunction.java +++ b/runtime/src/main/java/com/fluxtion/runtime/dataflow/aggregate/function/AggregateToListFlowFunction.java @@ -7,7 +7,7 @@ public class AggregateToListFlowFunction implements AggregateFlowFunction, AggregateToListFlowFunction> { - private final List list = new ArrayList<>(); + private transient final List list = new ArrayList<>(); private final int maxElementCount; diff --git a/runtime/src/main/java/com/fluxtion/runtime/dataflow/aggregate/function/AggregateToSetFlowFunction.java b/runtime/src/main/java/com/fluxtion/runtime/dataflow/aggregate/function/AggregateToSetFlowFunction.java index 8b33fe38e..405a6c825 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/dataflow/aggregate/function/AggregateToSetFlowFunction.java +++ b/runtime/src/main/java/com/fluxtion/runtime/dataflow/aggregate/function/AggregateToSetFlowFunction.java @@ -7,7 +7,7 @@ public class AggregateToSetFlowFunction implements AggregateFlowFunction, AggregateToSetFlowFunction> { - private final Set list = new HashSet<>(); + private transient final Set list = new HashSet<>(); @Override public Set reset() { @@ -36,11 +36,4 @@ public Set aggregate(T input) { return list; } - - public static class AggregateToSetFactory { - - public AggregateToSetFlowFunction newList() { - return new AggregateToSetFlowFunction<>(); - } - } } diff --git a/runtime/src/main/java/com/fluxtion/runtime/dataflow/groupby/GroupByKey.java b/runtime/src/main/java/com/fluxtion/runtime/dataflow/groupby/GroupByKey.java new file mode 100644 index 000000000..e2e307217 --- /dev/null +++ b/runtime/src/main/java/com/fluxtion/runtime/dataflow/groupby/GroupByKey.java @@ -0,0 +1,109 @@ +package com.fluxtion.runtime.dataflow.groupby; + +import com.fluxtion.runtime.partition.LambdaReflection; +import lombok.Getter; +import lombok.ToString; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +/** + * Constructs a compound key for using on group by constructs in a data flow. The key is composed using method references + * of the type to be grouped by. + * + * @param The type of data flow to create a key for + */ +@ToString(of = {"key", "name"}) +public class GroupByKey { + public final List> accessors; + private final transient StringBuilder keyHolder = new StringBuilder(); + @Getter + private final transient Class valueClass; + @Getter + private transient String key; + private transient final String name; + + public GroupByKey(List> accessorsToAdd) { + this.accessors = new ArrayList<>(); + String tmpName = ""; + for (LambdaReflection.SerializableFunction element : accessorsToAdd) { + if (!accessors.contains(element)) { + accessors.add(element); + tmpName += "_" + element.method().getName(); + } + } + valueClass = (Class) accessors.get(0).method().getDeclaringClass(); + name = valueClass.getName() + tmpName; + } + + public GroupByKey(LambdaReflection.SerializableFunction accessor) { + this(Arrays.asList(accessor)); + } + + @SafeVarargs + public GroupByKey(LambdaReflection.SerializableFunction... accessorList) { + this(Arrays.asList(accessorList)); + } + + private GroupByKey(GroupByKey toClone) { + accessors = toClone.accessors; + valueClass = toClone.getValueClass(); + name = toClone.name; + } + + public static LambdaReflection.SerializableFunction> build(LambdaReflection.SerializableFunction accessor) { + return new GroupByKey<>(accessor)::toKey; + } + + @SafeVarargs + public static LambdaReflection.SerializableFunction> build( + LambdaReflection.SerializableFunction accessor, + LambdaReflection.SerializableFunction... accessorList) { + List> accessors = new ArrayList<>(); + accessors.add(accessor); + accessors.addAll(Arrays.asList(accessorList)); + GroupByKey accessorKey = new GroupByKey<>(accessors); + return accessorKey::toKey; + } + + + public boolean keyPresent(LambdaReflection.SerializableFunction keyToCheck) { + return accessors.contains(keyToCheck); + } + + public GroupByKey toKey(T input) { + //TODO add object pooling + GroupByKey cloned = new GroupByKey<>(this); + cloned.keyHolder.setLength(0); + for (int i = 0, accessorsSize = accessors.size(); i < accessorsSize; i++) { + LambdaReflection.SerializableFunction accessor = accessors.get(i); + cloned.keyHolder.append(accessor.apply(input).toString()); + cloned.keyHolder.append("_"); + } + cloned.key = cloned.keyHolder.toString(); + return cloned; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GroupByKey that = (GroupByKey) o; + + if (!valueClass.equals(that.valueClass)) return false; + if (!Objects.equals(key, that.key)) return false; + return name.equals(that.name); + } + + @Override + public int hashCode() { + int result = valueClass.hashCode(); + result = 31 * result + (key != null ? key.hashCode() : 0); + result = 31 * result + name.hashCode(); + return result; + } + +} diff --git a/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/Collectors.java b/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/Collectors.java index fa2990506..bb8765007 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/Collectors.java +++ b/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/Collectors.java @@ -10,18 +10,31 @@ import com.fluxtion.runtime.partition.LambdaReflection.SerializableSupplier; import java.util.List; +import java.util.Set; public interface Collectors { - static SerializableSupplier> toList(int maximumElementCount) { + static SerializableFunction> toSet() { + return new AggregateToSetFlowFunction()::aggregate; + } + + static SerializableFunction> toList() { + return new AggregateToListFlowFunction()::aggregate; + } + + static SerializableFunction> toList(int maxElements) { + return new AggregateToListFlowFunction(maxElements)::aggregate; + } + + static SerializableSupplier> listFactory(int maximumElementCount) { return new AggregateToListFactory(maximumElementCount)::newList; } - static SerializableSupplier> toList() { - return toList(-1); + static SerializableSupplier> listFactory() { + return listFactory(-1); } - static SerializableSupplier> toSet() { + static SerializableSupplier> setFactory() { return AggregateToSetFlowFunction::new; } diff --git a/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/GroupingFactory.java b/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/GroupingFactory.java index 464639661..73311bb9e 100644 --- a/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/GroupingFactory.java +++ b/runtime/src/main/java/com/fluxtion/runtime/dataflow/helpers/GroupingFactory.java @@ -31,7 +31,7 @@ public SerializableFunction getKeyFunction() { } public GroupByFlowFunctionWrapper, AggregateToListFlowFunction> groupByToList() { - SerializableSupplier> list = Collectors.toList(); + SerializableSupplier> list = Collectors.listFactory(); return new GroupByFlowFunctionWrapper<>(keyFunction, Mappers::identity, list); } From 7cfed43479c5c206d405d116d312a9e5818f8eed Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 3 Dec 2023 16:41:05 +0000 Subject: [PATCH 225/228] updating poms for 9.1.13-SNAPSHOT development --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 3ae00c815..fbdac11fc 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.12-SNAPSHOT + 9.1.13-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index c81a26276..0c1c2e13f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.12-SNAPSHOT + 9.1.13-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index fb72804dc..9aaa76c78 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.12-SNAPSHOT + 9.1.13-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 2d2facd4e..8e5cc5d18 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.12-SNAPSHOT + 9.1.13-SNAPSHOT ../parent-root/pom.xml From 527b7adcb31bd3c3fc08753a5564e8666cf0848d Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 3 Dec 2023 16:41:10 +0000 Subject: [PATCH 226/228] updating poms for branch'release/9.1.12' with non-snapshot versions --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 3ae00c815..5861d091e 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.12-SNAPSHOT + 9.1.12 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index c81a26276..caabbd24d 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.12-SNAPSHOT + 9.1.12 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index fb72804dc..a166a81d4 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.12-SNAPSHOT + 9.1.12 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 2d2facd4e..a3ae13d79 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.12-SNAPSHOT + 9.1.12 ../parent-root/pom.xml From 2a0f90070238bd2cd6047a9ed8e522d34f6ad4dc Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 3 Dec 2023 16:44:18 +0000 Subject: [PATCH 227/228] updating develop poms to master versions to avoid merge conflicts --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index fbdac11fc..5861d091e 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.13-SNAPSHOT + 9.1.12 ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index 0c1c2e13f..caabbd24d 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.13-SNAPSHOT + 9.1.12 pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index 9aaa76c78..a166a81d4 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.13-SNAPSHOT + 9.1.12 pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index 8e5cc5d18..a3ae13d79 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.13-SNAPSHOT + 9.1.12 ../parent-root/pom.xml From c63671cca7bd4526aa6448f5ec4755d0bc64128c Mon Sep 17 00:00:00 2001 From: runner Date: Sun, 3 Dec 2023 16:44:19 +0000 Subject: [PATCH 228/228] Updating develop poms back to pre merge state --- compiler/pom.xml | 2 +- parent-root/pom.xml | 2 +- pom.xml | 2 +- runtime/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/pom.xml b/compiler/pom.xml index 5861d091e..fbdac11fc 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -19,7 +19,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.12 + 9.1.13-SNAPSHOT ../parent-root/pom.xml diff --git a/parent-root/pom.xml b/parent-root/pom.xml index caabbd24d..0c1c2e13f 100644 --- a/parent-root/pom.xml +++ b/parent-root/pom.xml @@ -21,7 +21,7 @@ 4.0.0 com.fluxtion root-parent-pom - 9.1.12 + 9.1.13-SNAPSHOT pom fluxtion :: poms :: parent root diff --git a/pom.xml b/pom.xml index a166a81d4..9aaa76c78 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ along with this program. If not, see 4.0.0 com.fluxtion fluxtion.master - 9.1.12 + 9.1.13-SNAPSHOT pom fluxtion diff --git a/runtime/pom.xml b/runtime/pom.xml index a3ae13d79..8e5cc5d18 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -20,7 +20,7 @@ Copyright (C) 2018 V12 Technology Ltd. com.fluxtion root-parent-pom - 9.1.12 + 9.1.13-SNAPSHOT ../parent-root/pom.xml